Val Town Code SearchReturn to Val Town

API Access

You can access search results via JSON API by adding format=json to your query:

https://codesearch.val.run/?q=api&page=459&format=json

For typeahead suggestions, use the /typeahead endpoint:

https://codesearch.val.run/typeahead?q=api

Returns an array of strings in format "username" or "username/projectName"

Found 5057 results for "api"(388ms)

translatorREADME.md1 match

@stevekrouse•Updated 11 months ago
3The app is set up so you can easily have a conversation between two people. The app will translate between the two selected languages, in each voice, as the speakers talk.
4
5Add your OpenAI API Key, and make sure to open in a separate window for Mic to work.
6
7Migrated from folder: Archive/translator

valwritermain.tsx1 match

@stevekrouse•Updated 11 months ago
106 console.log(result.rows[0]);
107
108 // Blob storage API
109 import { blob } from "https://esm.town/v/std/blob";
110 const key = "blob_test";

createValmain.tsx1 match

@stevekrouse•Updated 11 months ago
30
31export function createVal({ token, ...data }: { token?: string } & CreateValArgs): Promise<ValResponse> {
32 return fetchJSON("https://api.val.town/v1/vals", {
33 bearer: token || Deno.env.get("valtown"),
34 method: "PUT",

stockPricemain.tsx1 match

@stevekrouse•Updated 11 months ago
4async function alphaVantage(symbol: string) {
5 let data = await fetchJSON(
6 `https://www.alphavantage.co/query?function=GLOBAL_QUOTE&symbol=${symbol}&apikey=${Deno.env.get("alphaVantage")}`,
7 );
8 return data;

currencymain.tsx2 matches

@stevekrouse•Updated 11 months ago
6
7export let currency = async (desired, base = "usd", amount = 1) => {
8 let { rates } = await fetchJSON(`https://open.er-api.com/v6/latest/${base}`);
9 if (rates && rates[desired.toUpperCase()]) return amount * (rates[desired.toUpperCase()]);
10 else {
11 let { rates } = await fetchJSON("https://api.coingecko.com/api/v3/exchange_rates");
12 return amount * rates[desired.toLowerCase()]?.value / rates[base.toLowerCase()]?.value;
13 }

pipedreammain.tsx2 matches

@stevekrouse•Updated 11 months ago
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=44";
2import { google } from "npm:googleapis";
3
4export async function getAccessToken(accountId: string, bearer = Deno.env.get("pipedream")) {
5 const response = await fetchJSON(
6 `https://api.pipedream.com/v1/accounts/${accountId}?include_credentials=1`,
7 { bearer },
8 );

pipedreamREADME.md3 matches

@stevekrouse•Updated 11 months ago
1# Pipedream helpers
2
3Pipedream offers an Accounts API to handle OAuth for you, automatically, and for free. [How to do it is covered in this guide](https://docs.val.town/integrations/google-sheets/#use-pipedreams-accounts-api).
4
5The 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:
6
7```ts
37```
38
39In order for this to work you need to follow the instructions in [this guide](https://docs.val.town/integrations/google-sheets/#use-pipedreams-accounts-api) to save your pipedream API key into your [Val Town Environment Variables](/settings/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!
40
41Migrated from folder: Archive/pipedream

limit_model_forkmain.tsx5 matches

@std•Updated 11 months ago
1import { parseBearerString } from "https://esm.town/v/andreterron/parseBearerString";
2import { API_URL } from "https://esm.town/v/std/API_URL?v=5";
3import { RateLimit } from "npm:@rlimit/http";
4
24 const authHeader = req.headers.get("Proxy-Authorization") || req.headers.get("Authorization");
25 const token = authHeader ? parseBearerString(authHeader) : undefined;
26 const meRes = await fetch(`${API_URL}/v1/me`, { headers: { Authorization: `Bearer ${token}` } });
27 if (!meRes.ok) {
28 return new Response("Unauthorized", { status: 401 });
38
39 // Proxy the request
40 const url = new URL("." + pathname, "https://api.openai.com");
41 url.search = search;
42
43 const headers = new Headers(req.headers);
44 headers.set("Host", url.hostname);
45 headers.set("Authorization", `Bearer ${Deno.env.get("OPENAI_API_KEY")}`);
46 headers.set("OpenAI-Organization", Deno.env.get("OPENAI_API_ORG"));
47
48 const openAIRes = await fetch(url, {

limit_model_forkREADME.md1 match

@std•Updated 11 months ago
1# OpenAI Proxy
2
3This OpenAI API proxy injects Val Town's API keys. For usage documentation, check out https://www.val.town/v/std/openai

val_town_clientmain.tsx7 matches

@stevekrouse•Updated 12 months ago
1import { paths } from "https://esm.town/v/pomdtr/openapi_schema";
2import createClient2 from "npm:openapi-fetch";
3
4/**
5 * Create a Valtown API client
6 * @param options - Valtown API client options
7 * @param options.baseUrl - API base URL
8 * @param options.token - API token (if null, no token will be used, if undefined, the token from the environment variable "valtown" will be used)
9 */
10export default function createClient(options: {
13} = {}) {
14 return createClient2<paths>({
15 baseUrl: options?.baseUrl ?? "https://api.val.town",
16 headers: options?.token === null ? {} : { Authorization: `Bearer ${options.token ?? Deno.env.get("valtown")}` },
17 });

runValAPIEx2 file matches

@charmaine•Updated 14 hours ago

PassphraseAPI2 file matches

@wolf•Updated 3 days ago
artivilla
founder @outapint.io vibe coding on val.town. dm me to build custom vals: https://artivilla.com
fiberplane
Purveyors of Hono tooling, API Playground enthusiasts, and creators of 🪿 HONC 🪿 (https://honc.dev)