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/$%7Bart_info.art.src%7D?q=api&page=1645&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 19785 results for "api"(8391ms)

lovelyBeigeSolemain.tsx1 match

@meglado•Updated 10 months ago
96 const data = await response;
97 const update = await fetch(
98 `https://discord.com/api/v10/webhooks/${body.application_id}/${body.token}/messages/@original`,
99 {
100 method: "PATCH",

discordBotmain.tsx1 match

@meglado•Updated 10 months ago
96 const data = await response;
97 const update = await fetch(
98 `https://discord.com/api/v10/webhooks/${body.application_id}/${body.token}/messages/@original`,
99 {
100 method: "PATCH",

password_authREADME.md1 match

@cofsana•Updated 10 months ago
19```
20
21If you want to use an [api token](https://www.val.town/settings/api) to authenticate:
22
23```ts

VALLErunmain.tsx11 matches

@cofsana•Updated 10 months ago
211 Make an HTTP val (other vals are currently not supported to run, even though we have examples for them).
212 Start your response with a comment explaining how your approach will work, what libraries or
213 API calls you will use, and any tradeoffs you're making. Then write the code in a consise way,
214 the simplest way to achieve the goal, though you can add some inline comments to explain your
215 reasoning (not for every line, but for major groups of lines). Don't use any environment variables
216 unless strictly necessary, for example use APIs that don't require a key, prefer internal function
217 imports (using esm.town), and prefer putting API keys as inline variables. Use built-in Deno
218 functions where possible. Unless specified, don't add error handling,
219 make sure that errors bubble up to the caller.
220 Avoid external images or base64 images, use emojis, unicode symtols, or icon fonts/libraries instead, unless that's
221 not practical for the user's request (e.g. if they ask for a particular animated gif).
222 If the user asks for something that requires persistence, use the Val Town Blob storage API, unless
223 explicitly specified otherwise. Use the current val name for the storage key, which you can get
224 using the "pomdtr/extractValInfo" val, which you can call like this:
273Make an HTTP val (other vals are currently not supported to run, even though we have examples for them).
274Add comments at the top of the file explaining how your approach works, what libraries or
275API calls you will use, and any tradeoffs you're making. Then write the code in a consise way,
276the simplest way to achieve the goal, though you can add some inline comments to explain your
277reasoning (not for every line, but for major groups of lines). Don't use any environment variables
278unless strictly necessary, for example use APIs that don't require a key, prefer internal function
279imports (using esm.town), and prefer putting API keys as inline variables. Use built-in Deno
280functions where possible. Unless specified, don't add error handling,
281make sure that errors bubble up to the caller.
282Avoid external images or base64 images, use emojis, unicode symtols, or icon fonts/libraries instead, unless that's
283not practical for the user's request (e.g. if they ask for a particular animated gif).
284If the user asks for something that requires persistence, use the Val Town Blob storage API, unless
285explicitly specified otherwise. Use the current val name for the storage key, which you can get
286using the "pomdtr/extractValInfo" val, which you can call like this:
389 \`\`\`
390
391 ### Lower-level API
392
393 We do provide access to the lower-level getter and setters, which are useful if you are storing non-JSON or binary data, need to stream in your response or request data, or do anything else lower-level.
394
395 - \`async get(key: string)\`: Retrieves a blob for a given key.
396 - \`async set(key: string, value: string | BodyInit)\`: Sets the blob value for a given key. See [BodyInit](https://deno.land/api@v1.38.1?s=BodyInit).
397
398 ### Limitations
1204
1205 const tempValName = `valle_tmp_${Math.random() * 10}`.replaceAll(".", "");
1206 // Errors in running the val bubble up through this API, so ignore them.
1207 await vt.vals.create({ name: tempValName, code: newCode, type: "http" as any, privacy: "unlisted" }).catch(
1208 (error) => {

WikiImagemain.tsx29 matches

@ampp•Updated 10 months ago
36
37async function enhancedWikipediaSearch(pageName: string): Promise<any | null> {
38 const apiUrl = new URL("https://en.wikipedia.org/w/api.php");
39 apiUrl.searchParams.append("action", "query");
40 apiUrl.searchParams.append("list", "search");
41 apiUrl.searchParams.append("srsearch", pageName);
42 apiUrl.searchParams.append("srnamespace", "0");
43 apiUrl.searchParams.append("srlimit", "1");
44 apiUrl.searchParams.append("format", "json");
45
46 const response = await fetch(apiUrl.toString());
47 const data = await response.json();
48
60 }
61
62 const apiUrl = new URL("https://en.wikipedia.org/w/api.php");
63 apiUrl.searchParams.append("action", "query");
64 apiUrl.searchParams.append("titles", searchResult.title);
65 apiUrl.searchParams.append("prop", "pageimages|extracts|info|images|pageprops");
66 apiUrl.searchParams.append("piprop", "original|name");
67 apiUrl.searchParams.append("pithumbsize", "1000");
68 apiUrl.searchParams.append("pilimit", "1");
69 apiUrl.searchParams.append("exintro", "1");
70 apiUrl.searchParams.append("explaintext", "1");
71 apiUrl.searchParams.append("redirects", "1");
72 apiUrl.searchParams.append("inprop", "url");
73 apiUrl.searchParams.append("format", "json");
74
75 const response = await fetch(apiUrl.toString());
76 const data = await response.json();
77
78 console.log("API Response:", JSON.stringify(data, null, 2));
79
80 if (!data.query || !data.query.pages) {
134 filename = filename.replace(/^File:/, "");
135
136 const apiUrl = new URL("https://en.wikipedia.org/w/api.php");
137 apiUrl.searchParams.append("action", "query");
138 apiUrl.searchParams.append("titles", `File:${filename}`);
139 apiUrl.searchParams.append("prop", "imageinfo");
140 apiUrl.searchParams.append("iiprop", "url|size");
141 apiUrl.searchParams.append("format", "json");
142
143 const response = await fetch(apiUrl.toString());
144 const data = await response.json();
145

twitchmain.tsx2 matches

@pinjasaur•Updated 10 months ago
14 }
15 try {
16 // https://api.twitch.tv/helix/schedule/icalendar?broadcaster_id=95536715
17 const url = new URL("https://api.twitch.tv/helix/schedule/icalendar");
18 url.searchParams
19 .set("broadcaster_id", params.get("broadcaster_id"));

YouTubeSubmissionsmain.tsx3 matches

@mvmattgray•Updated 10 months ago
2// We'll use the built-in Request and Response objects for handling HTTP.
3// The form fields are customized for video information collection.
4// We'll add JSON API endpoints for Framer Fetch integration.
5
6import { blob } from "https://esm.town/v/std/blob";
11 const url = new URL(req.url);
12
13 // API endpoints for Framer Fetch
14 if (url.pathname === "/api/entries") {
15 if (req.method === "GET") {
16 const entries = await blob.getJSON(KEY).catch(() => []) || [];

getWeatherForecastmain.tsx3 matches

@cjpais•Updated 10 months ago
10 }
11
12 const weatherApiUrl = `https://wttr.in/${encodeURIComponent(city)}?format=j1`;
13
14 try {
15 const weatherResponse = await fetch(weatherApiUrl);
16 if (!weatherResponse.ok) {
17 throw new Error(`Weather API request failed with status: ${weatherResponse.status}`);
18 }
19 const weatherData = await weatherResponse.json();

modifyImageREADME.md1 match

@ilikescience•Updated 10 months ago
1Code from https://deno.com/blog/build-image-resizing-api
2
3Useful for compressing an image before sending to chatgpt4v, for example

Countdown2main.tsx1 match

@all•Updated 10 months ago
10 <meta name="viewport" content="width=device-width, initial-scale=1.0">
11 <title>Countdown to 2025 Event Kickoff</title>
12 <link href="https://fonts.googleapis.com/css2?family=Merriweather:wght@700&display=swap" rel="stylesheet">
13 <style>
14 body {
Plantfo

Plantfo8 file matches

@Llad•Updated 1 day ago
API for AI plant info

scrapeCraigslistAPI1 file match

@shapedlines•Updated 3 days ago
apiry
snartapi