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.
wikidata
@stevekrouse
Script
Query Wikidata via SPARQL Usage // get the death date for a person
@stevekrouse.wikidata(`SELECT ?person ?personLabel ?death_date WHERE {
?person rdfs:label "Henry Kissinger"@en;
wdt:P31 wd:Q5 . # Ensure the entity is a human
OPTIONAL {
?person wdt:P570 ?death_date . # Try to find a date of death
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}`) Learn more https://agg-shashank.medium.com/an-introduction-to-using-wikidata-apis-a678ee6d2968
pug
@wilt
Script
Pug HTML Template Renderer This function is equivalent to pug.render - it takes a Pug template string and renders it to an HTML string. import(npm:pug) doesn't work in Val.Town due to Pug's usage of new Function , which is forbidden for security reasons, so this function uses Val.Town's eval API instead. Example const myEndpoint = async (req: express.Request, res: express.Response) => {
const html = await @wilt.pug("p Hello #{name}!", {name: "Pug"});
res.status(200);
res.send(html);
}
pekoExample
@tmcw
HTTP (deprecated)
peko This is an example of using the tiny peko example with Val Town - it's a small router that lets you build web apps using the standard Request & Response objects. Peko just provides routing - matching URLs with functions - and lets you create your own Response object. Server examples Hono Peko Itty Router Nhttp