Back to APIs list

Github API examples & templates

Use these vals as a playground to view and fork Github API examples and templates on Val Town. Run any example below or find templates that can be used as a pre-built solution.
tmcw avatar
tmcw
getDuckDB
Script
Get a DuckDB database This method sets up a duckdb-wasm database that you can then use to store and retrieve data.
5
iamseeley avatar
iamseeley
thomasResumeConfig
Script
Forked from iamseeley/resumeConfig
0
nbbaier avatar
nbbaier
sqliteWriter
Script
SQLite QueryWriter The QueryWriter class is a utility for generating and executing SQL queries using natural language and OpenAI. It provides a simplified interface for interacting with your Val Town SQLite database and generating SQL queries based on user inputs. This val is inspired by prisma-gpt . PRs welcome! See Todos below for some ideas I have. Usage Import the QueryWriter class into your script: import { QueryWriter } from "https://esm.town/v/nbbaier/sqliteWriter"; Create an instance of QueryWriter, providing the desired table and an optional model: const writer = new QueryWriter({ table: "my_table", model: "gpt-4-1106-preview" }); Call the writeQuery() method to generate an SQL query based on a user input string: const userInput = "Show me all the customers with more than $1000 in purchases."; const query = await writer.writeQuery(userInput); Alternatively, use the gptQuery() method to both generate and execute the SQL query: const userInput = "Show me all the customers with more than $1000 in purchases."; const result = await writer.gptQuery(userInput); Handle the generated query or query result according to your application's needs. API new QueryWriter(args: { table: string; model?: string }): QueryWriter Creates a new instance of the QueryWriter class. table : The name of the database table to operate on. model (optional): The model to use for generating SQL queries. Defaults to "gpt-3.5-turbo". apiKey (optional): An OpenAI API key. Defaults to Deno.env.get("OPENAI_API_KEY") . writeQuery(str: string): Promise<string> Generates an SQL query based on the provided user input string. str : The user input string describing the desired query. Returns a Promise that resolves to the generated SQL query. gptQuery(str: string): Promise<any> Generates and executes an SQL query based on the provided user input string. str : The user input string describing the desired query. Returns a Promise that resolves to the result of executing the generated SQL query. Todos [ ] Handle multiple tables for more complex use cases [ ] Edit prompt to allow for more than just SELECT queries [ ] Allow a user to add to the system prompt maybe? [ ] Expand usage beyond just Turso SQLite to integrate with other databases
0
vladimyr avatar
vladimyr
lowdb_example
Script
Forked from pomdtr/lowdb_example
0
nbbaier avatar
nbbaier
lowdbTest
HTTP
Forked from pomdtr/lowdb_example
0
tmcw avatar
tmcw
nhttpExample
HTTP
nhttp example This uses the tiny nhttp framework with the Val Town Web API . New frameworks like nhttp works really well with our system because they rely on the standard Request & Response objects! Server examples Hono Peko Itty Router Nhttp
0
pomdtr avatar
pomdtr
copy_val_slug
Script
This val is supposed to be used with the val.town extension. See the extension readme for installation instructions.
0
saolsen avatar
saolsen
example_rust_http_val
Script
Built from https://gist.github.com/saolsen/294683088bae9a8f9a8cf93e2b392729 See https://gist.github.com/saolsen/d273bb1baba5e912e4dc2b187511affa for how to build a rust val. See https://www.val.town/v/saolsen/use_example_rust_http_val for how to use this.
0
stevekrouse avatar
stevekrouse
demoSDK
Script
Val Town REST API TypeScript SDK Demos This val demonstrates basic usage of the the Val Town JS/TS SDK. You can fork this val to your account to quickly try it out. Authentication is automatically set by the VAL_TOWN_API_KEY environment variable, which is automatically set within Val Town. You can control the API scopes of that key in your val's settings page. Learn more Reference docs
2
stevekrouse avatar
stevekrouse
lucia_adapter_base
Script
Forked from pomdtr/lucia_adapter_base
1
pomdtr avatar
pomdtr
lucia_adapter_base
Script
Copied from https://github.com/lucia-auth/lucia/blob/main/packages/adapter-sqlite/src/base.ts
0
vtdocs avatar
vtdocs
helloWorldPDF
Express (deprecated)
You can render PDFs on Val Town using the jspdf library (and presumably other libraries too!)
1
tmcw avatar
tmcw
nanoidExample
Script
nanoid nanoid is like a shorter, more fashionable alternative to UUIDs. Versus UUIDs: They're shorter, with a more customizable alphabet. They use more different characters by default. Unlike UUIDs, there aren't custom types for nanoids in databases Nanoids never contain information. UUIDs sometimes do: some UUIDs contain timestamps and MAC addresses.
0
pomdtr avatar
pomdtr
astro
HTTP
Astro served from Val Town (with SSR) ! The ultimate goal would be to serve it if from jsr, but the deno astro adapter still relies on deno.land.
5
saolsen avatar
saolsen
connect4_mcts_agent
HTTP
Connect4 agent that uses Monte-Carlo tree search to simulate 10,000 random games from each possible action and pick the one with the highest win rate. Ported from a version I made in rust. https://github.com/saolsen/connect4 https://www.steveindusteves.com/p/connect4-mcts
0
zzz avatar
zzz
Tokenizer
Script
An interactive, runnable TypeScript val by zzz
0