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/$%7Bsuccess?q=api&page=954&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 12844 results for "api"(1512ms)

VALLErunmain.tsx11 matches

@cofsanaUpdated 8 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

@amppUpdated 9 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

@pinjasaurUpdated 9 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

@mvmattgrayUpdated 9 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

@cjpaisUpdated 9 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

@ilikescienceUpdated 9 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

@allUpdated 9 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 {

violetKoalamain.tsx5 matches

@voidUpdated 9 months ago
1async function fetchWeather() {
2 const API_KEY = "439d4b804bc8187953eb36d2a8c26a02"; // Example key, replace with your own
3 const LAT = 51.5074; // London latitude
4 const LON = -0.1278; // London longitude
5 const url =
6 `https://api.openweathermap.org/data/2.5/onecall?lat=${LAT}&lon=${LON}&exclude=hourly,daily&units=metric&appid=${API_KEY}`;
7
8 console.log("Fetching weather from URL:", url); // Log the full URL
25 if (!weather || !weather.current) {
26 console.error("Weather data not available");
27 return `<div>You are API forb off...</div>`;
28 }
29
55 </div>
56 <div style="margin-top: 20px; font-size: 12px; word-break: break-all;">
57 <strong>API URL:</strong> ${url}
58 </div>
59 </div>
63export default async function main(req) {
64 const weather = await fetchWeather();
65 const url = `http://api.openweathermap.org/data/2.5/forecast/daily?q=London&appid=439d4b804bc8187953eb36d2a8c26a02`;
66 const html = generateHTML(weather, url);
67

notionGetDatabasemain.tsx2 matches

@ttodosiUpdated 9 months ago
4 filter?: any;
5}) => {
6 const { Client, collectPaginatedAPI } = await import(
7 "https://deno.land/x/notion_sdk/src/mod.ts"
8 );
9 const notion = new Client({ auth });
10 return collectPaginatedAPI(notion.databases.query, {
11 database_id: databaseId,
12 filter,

VALLEREADME.md3 matches

@ttodosiUpdated 9 months ago
6* Fork this val to your own profile.
7* Make a folder for the temporary vals that get generated, take the ID from the URL, and put it in `tempValsParentFolderId`.
8* If you want to use OpenAI models you need to set the `OPENAI_API_KEY` [env var](https://www.val.town/settings/environment-variables).
9* If you want to use Anthropic models you need to set the `ANTHROPIC_API_KEY` [env var](https://www.val.town/settings/environment-variables).
10* Create a [Val Town API token](https://www.val.town/settings/api), open the browser preview of this val, and use the API token as the password to log in.
11
12<img width=500 src="https://imagedelivery.net/iHX6Ovru0O7AjmyT5yZRoA/7077d1b5-1fa7-4a9b-4b93-f8d01d3e4f00/public"/>

vapi-minutes-db1 file match

@henrywilliamsUpdated 1 day ago

vapi-minutes-db2 file matches

@henrywilliamsUpdated 1 day ago
papimark21
socialdata
Affordable & reliable alternative to Twitter API: ➡️ Access user profiles, tweets, followers & timeline data in real-time ➡️ Monitor profiles with nearly instant alerts for new tweets, follows & profile updates ➡️ Simple integration