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.
threedEmoji
@iamseeley
Script
3️⃣ 🇩 create 3d emojis and text with three.js example usage: include a container in your HTML <div id="3d-emoji" style="width: 300px; height: 300px;"></div> call the function after the DOM has loaded import { create3DEmoji } from 'https://esm.town/v/iamseeley/threedEmoji';
document.addEventListener('DOMContentLoaded', () => {
create3DEmoji('😊', 300, 300);
});
databin
@jamiedubs
HTTP (deprecated)
a super simple JSON setter/getter using valtown blobs. use GET to fetch it, use POST to set it. expects the inbound data to be JSON for simplicity. use ?key=foobar to specify different storage locations. set: curl -s -X POST -d '{"lol": "wut"}' https://jamiedubs-databin.web.val.run?key=foobar get: curl -s https://jamiedubs-databin.web.val.run?key=foobar
# {"lol":"wut"}
renderFormAndSaveData
@andreterron
HTTP (deprecated)
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.
pipedream
@stevekrouse
Script
Pipedream helpers Pipedream offers an Accounts API to handle OAuth for you, automatically, and for free. How to do it is covered in this guide . The helper functions below can make it easier to work with various Google API. For example, I used them like so to get all my free/busy times for this week from all my google calendars: import { pipeDreamGoogle } from "https://esm.town/v/stevekrouse/pipedream";
const accountId = "REPLACE_WITH_YOUR_GCAL_ACCOUNT_ID_FROM_PIPEDREAM";
const calendar = await pipeDreamGoogle("calendar", accountId);
// Function to get free/busy information
async function getFreeBusyTimes(calendarId: string) {
const now = new Date();
const startOfWeek = new Date(now);
startOfWeek.setDate(now.getDate() - now.getDay());
const endOfWeek = new Date(startOfWeek);
endOfWeek.setDate(startOfWeek.getDate() + 6);
const requestBody = {
timeMin: startOfWeek.toISOString(),
timeMax: endOfWeek.toISOString(),
items: [{ id: calendarId }],
};
const freeBusyResponse = await calendar.freebusy.query({
requestBody,
});
return freeBusyResponse.data.calendars[calendarId].busy;
}
const calendars = (await calendar.calendarList.list()).data.items;
const freeBusy = await Promise.all(calendars.map(calendar => getFreeBusyTimes(calendar.id)));
console.log(freeBusy); In order for this to work you need to follow the instructions in this guide to save your pipedream API key into your Val Town Environment Variables under pipedream , then connect the google account you care about to Pipedream, and copy it's Pipedream "account id" into your val code. Let me know if you need any help by commenting on this val!