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.
openai
std
openai
OpenAI - Docs ↗ Use OpenAI's chat completion API with std/openai . This integration enables access to OpenAI's language models without needing to acquire API keys. For free Val Town users, all calls are sent to gpt-4o-mini . Basic Usage import { OpenAI } from "https://esm.town/v/std/openai"; const openai = new OpenAI(); const completion = await openai.chat.completions.create({ messages: [ { role: "user", content: "Say hello in a creative way" }, ], model: "gpt-4", max_tokens: 30, }); console.log(completion.choices[0].message.content); Images To send an image to ChatGPT, the easiest way is by converting it to a data URL, which is easiest to do with @stevekrouse/fileToDataURL . import { fileToDataURL } from "https://esm.town/v/stevekrouse/fileToDataURL"; const dataURL = await fileToDataURL(file); const response = await chat([ { role: "system", content: `You are an nutritionist. Estimate the calories. We only need a VERY ROUGH estimate. Respond ONLY in a JSON array with values conforming to: {ingredient: string, calories: number} `, }, { role: "user", content: [{ type: "image_url", image_url: { url: dataURL, }, }], }, ], { model: "gpt-4o", max_tokens: 200, }); Limits While our wrapper simplifies the integration of OpenAI, there are a few limitations to keep in mind: Usage Quota : We limit each user to 10 requests per minute. Features : Chat completions is the only endpoint available. If these limits are too low, let us know! You can also get around the limitation by using your own keys: Create your own API key on OpenAI's website Create an environment variable named OPENAI_API_KEY Use the OpenAI client from npm:openai : import { OpenAI } from "npm:openai"; const openai = new OpenAI(); 📝 Edit docs
Script
dot_com
aginfer
dot_com
Remix of: stevekrouse/dot_com
HTTP
redSwan
ianvph
redSwan
Remix of: ianvph/posthogGitHubStarCapture
HTTP
codeOnValTown
stevekrouse
codeOnValTown
Remix of: andreterron/codeOnValTown
Script
roughVizPlayground
dcm31
roughVizPlayground
roughViz Playground This val creates an interactive playground for exploring the roughViz library by Jared Wilber. roughViz is a JavaScript library for creating sketchy/hand-drawn styled charts in the browser, based on D3.js, roughjs, and handy. Features Interactive controls to adjust chart parameters: Roughness: Controls how "sketchy" the charts appear Fill Style: Different fill patterns (hachure, cross-hatch, dots, etc.) Bowing: Controls the "bending" of lines Fill Weight: Controls the thickness of fill patterns Demonstrates six chart types: Bar Chart Donut Chart Pie Chart Scatter Chart Horizontal Bar Chart Line Chart Includes code examples for each chart type that update with your selected parameters Usage The playground provides a user interface to adjust various parameters and see how they affect the appearance of different chart types. Simply adjust the sliders and dropdown, then click "Apply Settings" to see the changes. Resources roughViz GitHub Repository roughViz Demo Site
HTTP
dailyDadJoke
stevekrouse
dailyDadJoke
Daily Dad Joke How do you make a programmer laugh every morning? A dad joke cron job! Setup Fork this val Click Create fork 🤣🤣🤣🤣 API This val uses the icanhazdadjoke API . You can find more docs here , such as how to filter by type .
Cron
scrape2md
taras
scrape2md
This is a deno/valtown port in progress of https://github.com/tarasglek/scrape2md License: MIT Handy script to scrape various data sources into markdown. Intended to feed llms in https://chatcraft.org Usage: https://taras-scrape2md.web.val.run/ + URL_TO_SCRAPE Or just visit in browser and paste your url TODO https://chatcraft.org/api/share/tarasglek/IDYChVAilfePgVZb_T5pH POST from browser https://www.val.town/v/nbbaier/valToGH sync to github Metadata for use with https://github.com/tarasglek/valtown2js: { "typeCheck": false, "mappings": { "https://esm.sh/linkedom": { "name": "linkedom", "version": "^0.16.8" } }, "package": { "name": "scrape2md", "version": "1.0.0", "devDependencies": { "@types/turndown": "^5.0.4" } } }
HTTP
workers
temptemp
workers
Remix of: tempdev/workers
HTTP
test_SignatureCheck
karfau
test_SignatureCheck
An interactive, runnable TypeScript val by karfau
Script
steel_puppeteer_starter
steel
steel_puppeteer_starter
Steel + Puppeteer Starter This template shows you how to use Steel with Puppeteer to run browser automations in the cloud on Val Town. It includes session management, error handling, and a basic example you can customize. This starter templated was ported from this one on Github . Quick start The script shows you how to: Create and manage a Steel browser session Connect Puppeteer to the session Navigate to a website (Hacker News in this example) Extract data from the page (top 5 stories) Handle errors and cleanup properly View your live session in Steel's session viewer To run it: Get your free Steel API key at https://app.steel.dev/settings/api-keys Add it to your Val Town Environment Variables as STEEL_API_KEY Click Fork on this val Click Run on this val Writing your automation Find this section in the script: // ============================================================ // Your Automations Go Here! // ============================================================ // Example automation (you can delete this) await page.goto('https://news.ycombinator.com'); // ... rest of example code You can replace the code here with whatever automation scripts you want to run. Configuration The template includes common Steel configurations you can enable: const session = await client.sessions.create({ useProxy: true, // Use Steel's proxy network solveCaptcha: true, // Enable CAPTCHA solving sessionTimeout: 1800000, // 30 minute timeout (default: 15 mins) userAgent: 'custom-ua', // Custom User-Agent }); Error handling The template includes error handling and cleanup: try { // Your automation code } finally { // Cleanup runs even if there's an error if (browser) await browser.close(); if (session) await client.sessions.release(session.id); } Support Steel Documentation API Reference Discord Community
Script
linkInBioTemplate
hbcoop
linkInBioTemplate
Remix of: stevekrouse/linkInBioTemplate
HTTP
linkInBioTemplate
gigmx
linkInBioTemplate
Remix of: stevekrouse/linkInBioTemplate
HTTP
publicDocumentEditor
tr3ntg
publicDocumentEditor
An interactive, runnable TypeScript val by tr3ntg
Script
codeOnValTown
vladimyr
codeOnValTown
Remix of: andreterron/codeOnValTown
Script
sqliteExplorerApp
nbbaier
sqliteExplorerApp
SQLite Explorer View and interact with your Val Town SQLite data. It's based off Steve's excellent SQLite Admin val, adding the ability to run SQLite queries directly in the interface. This new version has a revised UI and that's heavily inspired by LibSQL Studio by invisal . This is now more an SPA, with tables, queries and results showing up on the same page. Install Install the latest stable version (v86) by forking this val: Authentication Login to your SQLite Explorer with password authentication with your Val Town API Token as the password. Todos / Plans [ ] improve error handling [ ] improve table formatting [ ] sticky table headers [x] add codemirror [ ] add loading indication to the run button (initial version shipped) [ ] add ability to favorite queries [ ] add saving of last query run for a table (started) [ ] add visible output for non-query statements [ ] add schema viewing [ ] add refresh to table list sidebar after CREATE/DROP/ALTER statements [ ] add automatic execution of initial select query on double click [x] add views to the sidebar [ ] add triggers to sidebar [ ] add upload from SQL, CSV and JSON [ ] add ability to connect to a non-val town Turso database [x] fix wonky sidebar separator height problem (thanks to @stevekrouse) [x] make result tables scrollable [x] add export to CSV, and JSON (CSV and JSON helper functions written in this val . Thanks to @pomdtr for merging the initial version!) [x] add listener for cmd+enter to submit query
HTTP
blog_mdx
pomdtr
blog_mdx
@jsxImportSource https://esm.sh/preact
HTTP