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.
![rlesser avatar](https://images.clerk.dev/uploaded/img_2QGEZ0ui5UEoQpzrCTbFslYSosv.jpeg)
rlesser
getNextSSR
Script
getNextSSR - fetch data from Next.js SSR-based sites Many modern websites use Next.js and Server-side Rendering (SSR) to serve their website and the data to populate it. Instead of standard API calls, this manifests in the browser as calls routed through dynamic endpoints. This val handles the url construction and response parsing, giving you access to the endpoint and data. Input websiteUrl - The website's url, like google.com or val.town
let getNextSSR: (websiteUrl: string) => Promise<(endpoint: string) => Promise<Record<string, any>>> Returns fetching function - A function that takes in an endpoint and returns the endpoint's response data: Input endpoint - The endpoint string, like results.json or trending.json?page=2 Returns data - The endpoint response data, without NextJS artifacts. Example const fetch = await @rlesser.getNextSSR("example.com");
const data = fetch("results.json");
return data;
0
![vtdocs avatar](https://images.clerk.dev/uploaded/img_2RCZq1QXONdaqPE472xAyQkVaqx.png)
vtdocs
resyBot
Script
Resy bot This bot books restaurant reservations via Resy. Use it to snipe reservations at your favorite restaurant! How to use it Set up a scheduled val to call it like this: import { resyBot } from "https://esm.town/v/stevekrouse/resyBot?v=2";
import { email } from "https://esm.town/v/std/email?v=13";
export default async function (interval: Interval) {
const bookingInfo = await resyBot( {
slug: 'amaro-bar',
city: 'ldn',
day: '2023-07-05',
start: '19:00',
end: '21:00',
partySize: 2,
// Use https://www.val.town/settings/secrets for these!
email: Deno.env.get("resyEmail"),
password: Deno.env.get("resyPassword"),
})
// If the val doesn't error, it successfully made a booking!
// Send yourself an email like this:
await email({ text: bookingInfo, subject: 'resy bot made a booking for you!' })
} How it works This val makes the same requests that your browser would make when you reserve a slot on Resy (that's why it needs your login info – to request an auth token). When there isn't a matching slot, this val errors and nothing else happens. When a booking is available, this val books it and returns a description of the booking so you can email it to yourself (Resy will also email you). This val will then stop attempting bookings for you until you change one of the arguments you're passing (it concats the non-sensitive arguments and uses this as a key). Credit to @rlesser and @alp for their existing Resy vals (search for resy on here).
7
![saolsen avatar](https://images.clerk.dev/oauth_github/img_2QtXHzN3gDPhKsBOvKsst8LTxC5.png)
saolsen
prune_val
Script
Prune a val's versions. Useful if you want to delete a bunch of versions. All versions before keep_since that aren't in keep_versions will be deleted !!! You can run it without passing commit to see a preview of what will happen. Example await prune_val("abcdefg", [3,6,8], 12, true); Could output Val: untitled_peachTakin, Current Version: 15
Deleting Versions: [ 1, 2, 4, 5, 7, 8, 9, 10, 11 ]
Deleting Version 1
Deleted
Deleting Version 2
Deleted
Deleting Version 4
Deleted
Deleting Version 5
Deleted
Deleting Version 6
Deleted
Deleting Version 7
Version already deleted, skipping
Deleting Version 8
Deleted
Deleting Version 9
Deleted
Deleting Version 10
Deleted
Deleting Version 11
Deleted
2
roramigator
lootGenAPI
HTTP
Loot Generator API How It Works Components The Loot Generator API creates random loot items by combining: 30 adjectives 29 materials 15 item types resulting in 13,050 possible items. Legendary Items Occasionally, a rare legendary item is generated. An item becomes legendary if all three components are rare. Rarity is determined by a threshold: Threshold = max(1,⌊log(length)×0.6⌋) Probability of a legendary item with the default settings: P(Legendary) = 1/13,050 ≈ 0.00766% Only one legendary item is possible: ✨💎 Arcane Diamond Rock . Customization You can expand the lists or adjust the 0.6 multiplier to control rarity.
1