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.
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
ayrtonlacerda avatar
ayrtonlacerda
getDetailsPlaystore
HTTP
Function that fetches app data from the playstore through bundleId
0
pomdtr avatar
pomdtr
API_URL
Script
Forked from std/API_URL
0
syncretizm avatar
syncretizm
singleformulaEndpoint
HTTP
An interactive, runnable TypeScript val by syncretizm
0
vtdocs avatar
vtdocs
resyAuth
Script
(Part of: https://www.val.town/v/vtdocs.resyBot) Get a user's auth token and payment methods.
0
arfan avatar
arfan
zARCHIVE_html_Pages
HTTP
// Shared HTML components
0
pomdtr avatar
pomdtr
auth_middleware
Script
Authentication middleware Guards your public http vals behind a login page. This val use a json web token stored as an http-only cookie to persist authentication. Usage Set an AUTH_SECRET_KEY env variable (used to sign/verify jwt tokens) to a random string . Then use an API token to authenticate. import { auth } from "https://esm.town/v/pomdtr/auth_middleware"; async function handler(req: Request): Promise<Response> { return new Response("You are authenticated!"); } export default auth(handler); See @pomdtr/test_auth for an example ⚠️ Make sure to only provides your api token to vals you trust (i.e. your own), as it gives access to your whole account.
1
pomdtr avatar
pomdtr
testBasicAuth
HTTP
An interactive, runnable TypeScript val by pomdtr
2
stevekrouse avatar
stevekrouse
handleFormExample
Script
An interactive, runnable TypeScript val by stevekrouse
0
rozek avatar
rozek
GDI_ClientInfoService
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 accepts any kind of HTTP request and responds with a JSON Structure containing some interesting details about the client and its request. This val is the companion of https://rozek-gdi_clientinfo.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
karfau avatar
karfau
getRedirectToValResponse
Script
Forked from neverstew/thisValUrl
0