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.
willthereader
versionLoggger
Script
This helper function logs the version number of the val. import { logUrlVersion } from "https://esm.town/v/stevekrouse/versionLoggger";
logUrlVersion(import.meta.url); Or if you want a one liner with no imports: console.log("Version: " + import.meta.url.match(/[?&]v=([^&]*)/)?.at(1));
1
![ljus avatar](https://images.clerk.dev/oauth_github/img_2StAle958YILzP3bMSycX2AA4Tu.png)
ljus
weatherGPT
HTTP
WeatherGPT Using OpenAI chat completion (GPT3) with function calls to SMHI api The API is instructed to use the current time in Europe/Stockholm timezone.
If the message can not be handled with the weather API endpoint, the Open AI assistant will reply instead. Relevant API documentation SMHI, forecast documentation OPEN AI, GPT function calling documentation How to use this endpoint GET: RUN_ENDPOINT?args=["A weather question"] Response {
answer?: string // If the message could not be answered with the SMHI API
error?:string //
data?: unknown // the actual data returned from SMHI, if the API is called
summary?: string // a summary of the data, by GPT API
} Examples How is the weather in the Capital of Sweden tomorrow. How is the weather at Liseberg on Friday. Packages used zod: for describing the SMHI API response and function API input zod-to-json-schema: Transform the zod schema to json schema (readable by the GPT API) gpt3-tokenizer: count the number of tokens date-fns-tz: To handle dates in a specific timezone (Europe/Stockholm)
0
weaverwhale
GistGPT
HTTP
GistGPT A helpful assistant who provides the gist of a gist How to use / and /gist - Default response is to explain this file. I believe this is effectively real-time recursion ? /gist?url={URL} - Provide a RAW file URL from Github, BitBucket, GitLab, Val Town, etc. and GistGPT will provide you the gist of the code. /about - "Tell me a little bit about yourself"
0
devdoshi
whatIsMyIp
Script
I wanted to see if val.town forwards my client IP Address using the x-forwarded-for header, which it does, but cloudflare provides the True-Client-IP header as well. When you run a val on the website, it is actually running from val's servers so it won't come from your client IP. You'll need to copy the express fetch and run that from your client.
0
dthyresson
graphQLYoga
HTTP
GraphQL Yoga Server GraphQL Yoga from The Guild is a batteries-included cross-platform GraphQL over HTTP spec-compliant GraphQL server
powered by Envelop
and GraphQL Tools focused on easy setup, performance and great developer experience. Usage To access GraphiQL - the GraphQL Playground - visit the / route.
That's what you see in the preview pane below. Configuration and Documentation See the GraphQL Yoga documentation for configuration and all the bells and whistles. Endpoint For this example, we'll set to / to make it easier to demo. However, by default, the GraphQL route is configured to be on /graphql which is more common. const yoga = createYoga({
schema,
}) You can set a custom endpoint: const yoga = createYoga({
schema,
graphqlEndpoint: "/my-gql",
}) Landing Page A landing page is shown be default whenever a 404 is hit. You can disable it via the landingPage option. const yoga = createYoga({
schema,
landingPage: false
})
0