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/$2?q=api&page=1461&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 18048 results for "api"(1529ms)

sqlitemain.tsx4 matches

@nkohari•Updated 9 months ago
1import { API_URL } from "https://esm.town/v/std/API_URL";
2import { LibsqlError, type ResultSet, type Row, type TransactionMode } from "npm:@libsql/client";
3import { z } from "npm:zod";
35
36async function execute(statement: InStatement, args?: InArgs): Promise<ResultSet> {
37 const res = await fetch(`${API_URL}/v1/sqlite/execute`, {
38 method: "POST",
39 headers: {
50
51async function batch(statements: InStatement[], mode?: TransactionMode): Promise<ResultSet[]> {
52 const res = await fetch(`${API_URL}/v1/sqlite/batch`, {
53 method: "POST",
54 headers: {
78
79/* Val Town's Turso Proxy returns rows as an array of values
80 * Yet the LibSQL API has a Row type which behave as an array or object,
81 * ie you can access it via numerical index or string
82 */

genimagemain.tsx1 match

@motyar•Updated 9 months ago
1// This program creates an image generation service using the maxm-imggenurl API.
2// It provides a simple HTML interface for users to enter a prompt and generate an image.
3// The generated images are displayed in a grid, and clicking on an image shows a popup with the image and prompt.

stagingdailyschedulemain.tsx3 matches

@keenanzucker•Updated 9 months ago
10 const tomorrow = addDays(today, 1);
11 const data = await fetch(
12 `https://api.stage.teamsurfboard.com/api/v1/schedule?start=${today.toISOString()}&end=${tomorrow.toISOString()}`,
13 {
14 headers: {
15 // ADD YOUR API TOKEN INTO THE ENV VARIABLES
16 "Authorization": `Bearer ${Deno.env.get("TEAMSURFBOARD_API_TOKEN")}`,
17 },
18 },

concentricCirclesAppmain.tsx2 matches

@kaz•Updated 9 months ago
197 <head>
198 <title>Know Your Boundaries</title>
199 <link rel="preconnect" href="https://fonts.googleapis.com">
200 <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
201 <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet">
202 <meta name="viewport" content="width=device-width, initial-scale=1.0">
203 <style>${css}</style>

dailyDadJokeREADME.md2 matches

@davidpadbury•Updated 9 months ago
113. 🤣🤣🤣🤣
12
13## API
14
15This val uses the [icanhazdadjoke API](https://icanhazdadjoke.com/api). You can find [more docs here](https://github.com/15Dkatz/official_joke_api), such as how to [filter by type](https://github.com/15Dkatz/official_joke_api?tab=readme-ov-file#grab-jokes-by-type).

dailyDadJokemain.tsx1 match

@davidpadbury•Updated 9 months ago
3
4export async function dailyDadJoke() {
5 let { setup, punchline } = await fetchJSON("https://official-joke-api.appspot.com/random_joke");
6 return email({
7 text: punchline,

githubRepoViewermain.tsx4 matches

@ejfox•Updated 9 months ago
2 const url = new URL(request.url);
3
4 if (url.pathname === "/api/files") {
5 const user = url.searchParams.get("user");
6 const repo = url.searchParams.get("repo");
10 }
11
12 const apiUrl = `https://api.github.com/repos/${user}/${repo}/contents`;
13 const response = await fetch(apiUrl);
14 const contents = await response.json();
15
56 result.innerHTML = 'Loading...';
57
58 const response = await fetch(\`/api/files?user=\${user}&repo=\${repo}\`);
59 const html = await response.text();
60 result.innerHTML = html;

pushSendNotificationmain.tsx1 match

@jrmann100•Updated 9 months ago
8 ...params: Parameters<ServiceWorkerRegistration["showNotification"]>
9) => {
10 webPush.setVapidDetails(url, pubKey, privKey);
11 if (!subscription) throw new Error("subscription is falsy");
12 await webPush.sendNotification(

pushSendNotification_negrelmain.tsx7 matches

@jrmann100•Updated 9 months ago
1import * as webpush from "jsr:@negrel/webpush@^0.3.0";
2
3// https://github.com/web-push-libs/web-push/blob/v3.4.4/README.md#using-vapid-key-for-applicationserverkey
4function urlBase64ToUint8Array(b64) {
5 const padding = "=".repeat((4 - (b64.length % 4)) % 4);
44}
45
46const vapidKeysAlgo = {
47 name: "ECDSA",
48 namedCurve: "P-256",
49};
50
51async function importVapidKeys(
52 exportedKeys: { pubKey: string; privKey: string },
53 { crypto = globalThis.crypto.subtle, extractable = false }: {
60 "raw",
61 urlBase64ToUint8Array(exportedKeys.pubKey),
62 vapidKeysAlgo,
63 true,
64 ["verify"],
67 "jwk",
68 getPrivKeyJWK(exportedKeys),
69 vapidKeysAlgo,
70 extractable,
71 ["sign"],
81 ...params: PushParams
82) => {
83 const vapidKeys = await importVapidKeys({ pubKey, privKey }, {
84 extractable: false,
85 });
87 const appServer = await webpush.ApplicationServer.new({
88 contactInformation: url,
89 vapidKeys,
90 });
91

testplaywrightmain.tsx5 matches

@alexdphan•Updated 9 months ago
5console.info("Launching browser...");
6
7// Use Deno.env to get the API key
8const apiKey = Deno.env.get("BROWSERBASE_API_KEY");
9if (!apiKey) {
10 console.error("BROWSERBASE_API_KEY environment variable is not set");
11 Deno.exit(1);
12}
14try {
15 const browser = await chromium.connectOverCDP(
16 `wss://connect.browserbase.com?apiKey=${apiKey}`,
17 );
18 console.info("Connected!");

Apiify11 file matches

@wolf•Updated 8 hours ago

dailyQuoteAPI

@Souky•Updated 2 days ago
Kapil01
apiv1