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.
iamseeley
Server2
HTTP
🚧 hono + htmx web app 🚧 idea: linktree-esque profile page w/ widgets powered by vals setup: fork the val and uncomment the /signup and /login routes create a jwt secret token environment variable go to the db setup val and run it to create the tables (as the site is right now, you can only add/edit users and add/edit/delete user links) to do: [ ] create some val town apis for the profile widgets (add vals people have already made) [ ] add profile image (will probably point to val town profile pic) [ ] add delete profile handler [ ] finish public profile page [ ] 🎨🎨🎨🎨🎨
2
andreterron
renderFormAndSaveData
HTTP
Render form and save data This val provides a web-based interface for collecting email addresses. It features a dual-functionality approach: when accessed via a web browser using a GET request, it serves an HTML form where users can submit their email address. If the script receives a POST request, it implies that the form has been submitted, and it proceeds to handle the incoming data. Fork this val to customize it and use it on your account.
4
tmcw
jsYAMLExample
Script
js-yaml YAML is a popular format for data which is an alternative to JSON . In contrast to JSON, YAML can look more user-friendly: you can write text without worrying about quoting strings You can write comments in YAML But, on the other side, it's more possible to write YAML that is parsed in an unexpected way. JSON is more explicit and predictable. js-yaml is the most popular YAML parser for JavaScript.
0
charmaine
townieIllustratorPrompt
Script
Add this to Townie's System prompt by going into Townie's Settings —
First ask a user what app they would like you to illustrate. Then create an app outline generator for any app that is requested that produces a simplified, visual representation of the app's interface.
Core Functionality
- Accept an app name as input (e.g., "Zoom", "Slack", "Discord")
- Generate a single val that renders a minimal, branded mockup of the app's main interface
- Allow the user to export a png screenshot with transparent background with rounded corners (8px radius)
- Move the `html2canvas` import inside the `client()` function.
- Wrap the `exportAsPNG` function in a `useEffect` hook to ensure it's only defined on the client-side.
- Use dynamic import for `html2canvas` inside the `exportAsPNG` function.
- Make sure html2canvas is only loaded and used on the client-side
Visual Requirements
- Match the app's primary brand colors (limit to 2-3 colors)
- Do light or dark mode of the app depending on which is the default for that app
- Use placeholder blocks in light gray (#E5E5E5) for text and controls
- Include key structural elements specific to the app (e.g., sidebars, headers, content areas), refrain from including text
- Use SVG for any icons or logos, built into the component, if needed.
- Apply consistent spacing (16px grid)
- Ensure the generated outline is compact (around 280x220 pixels) for easy sharing and quick visualization.
1
tmcw
zodExample
Script
Zod Zod works great out-of-the-box with Val Town: just import it as npm:zod and parse something! Here's an example below. Tips Right now it's not possible to create a script val that immediately returns a Zod parser because its parsers can't be serialized. It's best to either expose a method that returns a parser, or to create and use the parser in the same val.
0
jxnblk
middleware
Script
Minimal middleware for val town Demo Usage import { app, Middleware } from "https://esm.town/v/jxnblk/middleware";
const robots: Middleware = async (req, res, ctx) => {
const url = new URL(req.url);
if (url.pathname === "/robots.txt") {
return new Response("User-agent: *\nAllow: /");
}
return null;
}
const getData: Middleware = async (req, res, ctx) => {
// do async work here...
// add data to context
ctx.hello = `hello ${new Date().toLocaleDateString()}`;
// set headers
res.headers.set("X-Hello", ctx.hello);
// return null to pass to the next middleware
return null;
}
const renderHTML: Middleware = async (req, res, ctx) => {
const html = `
<h1>${ctx.hello}</h1>
`
return new Response(html, {
headers: {
"Content-Type": "text/html",
},
});
}
export default app([
robots,
getData,
renderHTML,
])
0