Back to APIs list

US Congress Stock Trading API examples & templates

Use these vals as a playground to view and fork US Congress Stock Trading API examples and templates on Val Town. Run any example below or find templates that can be used as a pre-built solution.
pomdtr avatar
pomdtr
ejm
HTTP
An interactive, runnable TypeScript val by pomdtr
0
manyone avatar
manyone
spanishPoeticClock
HTTP
@jsxImportSource https://esm.sh/react
0
stevekrouse avatar
stevekrouse
compress_response
HTTP
Compress Response Isn't it cool that browsers can natively decompress stuff? There are a couple of supported compression algorithms: gzip (used below), compress , deflate , br . Learn more: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding If you don't add the content-encoding header, the gzip result looks like: ��������� �� �.���� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������YDA��"�� Which is incredibly short for a 500kb string! (Which shouldn't be surprising because it's just "hi" 250k times)
1
rozek avatar
rozek
GDI_AITranslatorService
HTTP
This val is part of a series of examples to introduce "val.town" in my computer science course at Stuttgart University of Applied Sciences . The idea is to motivate even first-semester students not to wait but to put their ideas into practice from the very beginning and implement web apps with frontend and backend. It contains a simple HTTP end point which expects a POST request with a text body. That text is translated to english with the help of OpenAI and sent back to the client This val is the companion of https://rozek-gdi_aitranslator.web.val.run/ which contains the browser part (aka "frontend") for this example. The code was created using Townie - with only a few small manual corrections. This val is licensed under the MIT License.
0
neverstew avatar
neverstew
blobDirList
Script
List things in a blob directory Blobs can be organised using "directories" e.g. /animals all-animals.txt /dogs sausage.txt /cats tom.txt is really only three files: /animals/all-animals.txt , /animals/dogs/sausage.txt and /animals/cats/tom.txt because directories don't really exist, we're just making longer filenames. When you want to list things only "in a directory" and none of the child "directories", you can use this val. import { blobDirList } from "https://esm.town/v/neverstew/blobDirList"; console.log(await blobDirList("/animals")); // returns only "/animals/all-animals.txt"
2
hunty avatar
hunty
bumpyGreenAntelope
HTTP
Forked from hunty/Fetch
0
cufaoil avatar
cufaoil
setTemp
HTTP
An interactive, runnable TypeScript val by cufaoil
0
pomdtr avatar
pomdtr
http_request_example
Script
#example
0
kora avatar
kora
ownOpenAI
Script
Use my own OpenAI API key to avoid limit
0
nbbaier avatar
nbbaier
paginatedResponse
Script
Return a paginated response A helper function to take an array and return a paginated response. This is useful when defining one's own folders for pomdtr's vscode extension . Usage: const data = [...] export default async function(req: Request): Promise<Response> { return paginatedResponse(req, data); } For demo usage in the context of the vscode extension see this val .
1
rozek avatar
rozek
GDI_FileUploadService
HTTP
This val is part of a series of examples to introduce "val.town" in my computer science course at Stuttgart University of Applied Sciences . The idea is to motivate even first-semester students not to wait but to put their ideas into practice from the very beginning and implement web apps with frontend and backend. It contains a very simple HTTP end point which expects an uploaded file and responds with a JSON structure containg name, type and size of that file. This val is the companion of https://rozek-gdi_fileupload.web.val.run/ which contains the user interface (aka "frontend") for this example. The code was created using Townie - with only a few small manual corrections. This val is licensed under the MIT License.
0
stevekrouse avatar
stevekrouse
editRedirect
Script
Redirect to Val Page Redirect from web val to val page by adding /edit to the URL. Convention by pomdtr . Usage import { editRedirect } from "https://esm.town/v/stevekrouse/editRedirect"; import { Hono } from "npm:hono@3"; const app = new Hono(); app.get("/", (c) => c.text("Hello world!")); app.get("/edit", (c) => editRedirect()); export default app.fetch; TODO [ ] turn this into middleware in the style of @pomdtr/basicAuth Live: https://stevekrouse-edit_redirect_example.web.val.run/edit
0
pomdtr avatar
pomdtr
publicRouteTest
HTTP
An interactive, runnable TypeScript val by pomdtr
0
kaleidawave avatar
kaleidawave
httpBasicAuthenticationExample
HTTP
An interactive, runnable TypeScript val by kaleidawave
0
stevekrouse avatar
stevekrouse
formData
Script
An interactive, runnable TypeScript val by stevekrouse
0
rozek avatar
rozek
Authorization_from_Blob_Test
HTTP
Here are some tests for val Authorization_from_Blob Test Cases Here are the rewritten test cases to fit the generated code that uses Blob storage instead of environment variables: Positive Test Cases Valid token with defined Blob BlobName: "VALID_TOKEN" Blob value: "secret123" Authorization header: "Bearer secret123" Mode: "forbid-if-not-defined" Expected result: true Valid token with allow-if-not-defined mode BlobName: "VALID_TOKEN" Blob value: "secret123" Authorization header: "Bearer secret123" Mode: "allow-if-not-defined" Expected result: true Valid token with missing mode (default behavior) BlobName: "VALID_TOKEN" Blob value: "secret123" Authorization header: "Bearer secret123" Mode: undefined Expected result: true Negative Test Cases Invalid token BlobName: "VALID_TOKEN" Blob value: "secret123" Authorization header: "Bearer wrongtoken" Mode: "forbid-if-not-defined" Expected result: false No Authorization header BlobName: "VALID_TOKEN" Blob value: "secret123" Authorization header: undefined Mode: "forbid-if-not-defined" Expected result: false Blob not defined, forbid mode BlobName: "UNDEFINED_TOKEN" Blob value: undefined Authorization header: "Bearer anytoken" Mode: "forbid-if-not-defined" Expected result: false Blob not defined, allow mode BlobName: "UNDEFINED_TOKEN" Blob value: undefined Authorization header: "Bearer anytoken" Mode: "allow-if-not-defined" Expected result: true Error Cases Invalid Blob name BlobName: "1INVALID" Blob value: "secret123" Authorization header: "Bearer secret123" Mode: "forbid-if-not-defined" Expected result: Error thrown Invalid Mode BlobName: "VALID_TOKEN" Blob value: "secret123" Authorization header: "Bearer secret123" Mode: "invalid-mode" Expected result: Error thrown Edge Cases Empty string as token BlobName: "EMPTY_TOKEN" Blob value: "" Authorization header: "Bearer " Mode: "forbid-if-not-defined" Expected result: true Case-sensitive token comparison BlobName: "CASE_TOKEN" Blob value: "Secret123" Authorization header: "Bearer secret123" Mode: "forbid-if-not-defined" Expected result: false Non-Bearer authorization type BlobName: "VALID_TOKEN" Blob value: "secret123" Authorization header: "Basic secret123" Mode: "forbid-if-not-defined" Expected result: false
0