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.

vladimyr
googleFeelingLucky
Google Feeling Lucky auto-redirect !lucky DuckDuckGo !Bangs offer the following shortcuts for Google's Feeling Lucky (going straight to the first result) search option: !fl - http://www.google.com/search?btnI&q={{{s}}} !gifl - http://google.com/search?btnI=1&q={{{s}}} !gluck - http://www.google.com/search?q={{{s}}}&btnI !lucky - http://www.google.com/search?q={{{s}}}&btnI Unfortunately, they don't work anymore due to redirect notices that get shown. This service enables you to skip redirect notice by altering your search from the original query e.g.: https://www.google.com/search?q=site:developer.mozilla.org+Object.hasOwn&btnI To the modified one made against this val's HTTP endpoint: https://vladimyr-googlefeelinglucky.web.val.run/?q=site:developer.mozilla.org+Object.hasOwn Additionally, you can define custom search shortcut inside your browser to allow a local bang-like experience: Name: Google Feeling Lucky Shortcut: !lucky URL with %s in place of query: https://vladimyr-googlefeelinglucky.web.val.run/?q=%s
postpostscript
fetchWorker
fetchWorker: communicate with a worker over a fetch -like interface! Example: import { fetchWorker } from "https://esm.town/v/postpostscript/fetchWorker";
using worker = await fetchWorker({
url: "https://esm.town/v/postpostscript/fetchWorkerExample",
handler: "handler",
});
const res = await worker.fetch("/", {
method: "POST",
body: JSON.stringify({
test: 1,
}),
headers: {
"Content-Type": "application/json",
},
});
console.log(await res.json());
// {
// method: "POST",
// url: "https://7ae81ab0-04cf-485a-ae09-054c4d3be6b3.val.town/",
// text: { test: 1 },
// headers: { "content-type": "application/json" }
// } Full Example Options: url ( string , required): URL that the worker will fetch the handler from handler ( string , defaults to default ): name of export that will execute the request
postpostscript
reactiveStateBlob
reactiveStateBlob: wrap blob state in a proxy to autosave it on changes Examples (full example at @postpostscript/reactiveStateBlobExample ) import { reactiveStateBlob } from "https://esm.town/v/postpostscript/reactiveStateBlob"
using state = await reactiveStateBlob({
viewCount: 0,
rows: [] as {
x: number;
y: number;
}[],
});
state.viewCount += 1;
state.rows.push({
x: Math.random(),
y: Math.random(),
}); This infers the key from the name of the val that uses it. To specify it, pass the key option: using state = await reactiveStateBlob({
viewCount: 0,
rows: [] as {
x: number;
y: number;
}[],
}, {
key: 'reactiveStateBlobExample.state',
}); Updating Schema If you want to update the schema, or always verify the state that is pulled from the job, pass a function as the first argument: using state = await reactiveStateBlob((existingState) => {
return {
viewCount: (existingState.viewCount ?? 0) as number,
rows: (existingState.rows ?? []) as {
x: number;
y: number;
}[],
someNewField: (existingState.someNewField ?? "") as string,
}
}) Options using state = await reactiveStateBlob<{
value: number;
}>({
value: 0,
}, {
log: true, // log when saving
key: "blobKey", // blob key to fetch/save to
timeout: 100, // ms, defaults to 10
lock: true, // or LockOptions (see https://www.val.town/v/postpostscript/lock#options)
}) See Also @postpostscript/counter (example at @postpostscript/counterExample )