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.
unionTypeScriptSDK
@git
Script
Union TypeScript SDK Example Usage import { http } from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { createUnionClient, hexStringToUint8Array } from "@union/client";
const PRIVATE_KEY = process.env.PRIVATE_KEY;
const account = privateKeyToAccount(`0x${PRIVATE_KEY}`);
const client = createUnionClient({
account,
chainId: "80084",
transport: http("https://bartio.rpc.berachain.com"),
});
const transfer = await client.transferAsset({
amount: 1n,
autoApprove: true,
destinationChainId: "stride-internal-1",
recipient: "stride14qemq0vw6y3gc3u3e0aty2e764u4gs5l66hpe3",
denomAddress: "0x0E4aaF1351de4c0264C5c7056Ef3777b41BD8e03", // HONEY
});
if (transfer.isErr()) {
console.error("Transfer failed", transfer.error);
}
console.info("Transfer successful", transfer.value);
easyAQI
@stevekrouse
Script
easyAQI Get the Air Quality Index (AQI) for a location via open data sources. It's "easy" because it strings together multiple lower-level APIs to give you a simple interface for AQI. Accepts a location in basically any string format (ie "downtown manhattan") Uses Nominatim to turn that into longitude and latitude Finds the closest sensor to you on OpenAQ Pulls the readings from OpenAQ Calculates the AQI via EPA's NowCAST algorithm Uses EPA's ranking to classify the severity of the score (ie "Unhealthy for Sensitive Groups") It uses blob storage to cache the openai location id for your location string to skip a couple steps for the next time. Example usage @stevekrouse.easyAQI({ location: "brooklyn navy yard" })
// Returns { "aqi": 23.6, "severity": "Good" } Forkable example: val.town/v/stevekrouse.easyAQIExample Also useful for getting alerts when the AQI is unhealthy near you: https://www.val.town/v/stevekrouse.aqi