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/image-url.jpg%20%22Optional%20title%22?q=fetch&page=877&format=json

For typeahead suggestions, use the /typeahead endpoint:

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

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

Found 9060 results for "fetch"(816ms)

YoutubeTranscriptmain.tsx11 matches

@zzz•Updated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export const YoutubeTranscript = async (url: string, metadata = true) => {
76 }
77 /**
78 * An extensible class to fetch a transcript from a given YouTube Video
79 */
80 class YoutubeTranscript {
81 /**
82 * Fetch a transcript from a YouTube Video which includes the text and timestamp metadata
83 * @param videoId Video url or video identifier
84 * @param config Options for specifying a Country and Language ISO
85 */
86 static async fetchTranscript(
87 videoId: string,
88 config?: TranscriptConfig,
90 const identifier = this.extractVideoId(videoId);
91 try {
92 const textResponse = await fetch(
93 `https://www.youtube.com/watch?v=${identifier}`,
94 );
100 );
101 }
102 const transcriptResponse = await fetch(
103 `https://www.youtube.com/youtubei/v1/get_transcript?key=${apiKey}`,
104 {
123 }
124 /**
125 * Fetch only the transcript text from a YouTube Video
126 * @param videoId Video url or video identifier
127 * @param config Options for specifying a Country and Language ISO
128 */
129 static async fetchTranscriptText(
130 videoId: string,
131 config?: TranscriptConfig,
132 ): Promise<string> {
133 const segments = await this.fetchTranscript(videoId, config);
134 let out = "";
135 for (const { text } of segments) {
283 }
284 if (metadata)
285 return await YoutubeTranscript.fetchTranscript(url);
286 return await YoutubeTranscript.fetchTranscriptText(url);
287};

hnTopStoriesmain.tsx5 matches

@csshsh•Updated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3// forked from @healeycodes.hnTopStories
5// hi florian
6export const hnTopStories = async () => {
7 let valTownFetchLimit = 1;
8 const topStories: Number[] = await fetch(
9 "https://hacker-news.firebaseio.com/v0/topstories.json?print=pretty"
10 ).then((res) => res.json());
11 valTownFetchLimit--;
12 const id = topStories[0];
13 console.log({ id });
19 score: number;
20 by: string;
21 } = await fetch(
22 `https://hacker-news.firebaseio.com/v0/item/${id}.json?print=pretty`
23 ).then((res) => res.json());

ratelimitmain.tsx2 matches

@rlimit•Updated 1 year ago
1import { parentReference } from "https://esm.town/v/stevekrouse/parentReference?v=3";
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
3import { runVal } from "https://esm.town/v/std/runVal";
4
12 // use user's rlimit.com namespace if defined
13 if (namespaceId) {
14 return await fetchJSON(
15 `https://rlimit.com/${namespaceId}/${max}/${interval}/${key}?password=${namespacePassword}&region=global`,
16 );

replitGetmain.tsx2 matches

@claytn•Updated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export let replitGet = (REPLIT_DB_URL, key) => fetch(`${REPLIT_DB_URL}/${key}`);

pollVotingJobmain.tsx2 matches

@pranjaldotdev•Updated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3let { failureCount } = await import("https://esm.town/v/pranjaldotdev/failureCount");
20 const token =
21 "eyJhbGciOiJIUzI1NiJ9.eyJwbGF0Zm9ybSI6Imppb3Zvb3QiLCJ1c2VyaWR0eXBlIjoidXVpZCIsImlzSmlvVXNlciI6ZmFsc2UsImlzR3Vlc3QiOmZhbHNlLCJwaG9uZU5vIjoiMzM2NjBiNzQtM2U5YS00ZWJhLTlmMTMtNzBkNTQ3NmUwOTNkIiwicHJvZmlsZUlkIjoiMTE1ODc3YWQtZDE3Mi00YTAwLWI2OTMtMDlkZmNjNTEwOTMyIiwiaWF0IjoxNjg5NzA0MzA0LCJleHAiOjE2ODk3OTA3MDR9.ICKpSLJJexKR0wjDYDMpctvdTV33P0J6pxL3MAxWJyg";
22 const response = await fetch(votingURL, {
23 method: "POST",
24 headers: {

getWeathermain.tsx4 matches

@sdan•Updated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export async function getWeather(city: string) {
4 try {
5 const response = await fetch(`https://wttr.in/${city}?format=j1`);
6 if (!response.ok) {
7 throw new Error(`Failed to fetch data for ${city}`);
8 }
9 const jsonData = await response.json();
14 }
15 catch (error) {
16 throw new Error(`Failed to fetch weather data: ${error}`);
17 }
18}

big_storymain.tsx2 matches

@tmcw•Updated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2import { big_stories_ranks } from "https://esm.town/v/tmcw/big_stories_ranks";
3import process from "node:process";
5export let big_story = (async () => {
6 const nytimes =
7 await (await fetch(
8 `https://api.nytimes.com/svc/topstories/v2/home.json?api-key=${process.env.nytimes_api_key}`,
9 )).json();

testVTClientmain.tsx1 match

@stevekrouse•Updated 1 year ago
5 const apiClient = createApiClient("https://api.val.town");
6 const params = {
7 params: { username: "stevekrouse", val_name: "fetchJSON" },
8 };
9 const user = await apiClient.getValname(params);

testMutateSemanticsmain.tsx4 matches

@stevekrouse•Updated 1 year ago
1import process from "node:process";
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
3
4export async function testMutateSemantics({
17 authenticated: boolean;
18}) {
19 const { data: last } = await fetchJSON(
20 `${api}/eval/${stateName}`
21 );
22 const now = Date.now();
23 await fetchJSON(
24 `${api}/eval/${mutator(now)}`,
25 authenticated
29 : undefined
30 );
31 const { data: next } = await fetchJSON(
32 `${api}/eval/${stateName}`
33 );

chatGPTPluginmain.tsx4 matches

@stevekrouse•Updated 1 year ago
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2import { openaiOpenAPI } from "https://esm.town/v/stevekrouse/openaiOpenAPI";
3
13Vals are JavaScript & TypeScript code.
14They run server-side on Deno.
15\`fetch\` is in the environment to access any PUBLIC real-time APIs or data feeds.
16Answer any questions about times after your cut off date by querying PUBLIC APIs.
17Do NOT use any API that requires a secret key.
18Only use PUBLIC APIs.
19Do NOT use \`YOUR_API_KEY\`.
20Do NOT import axios or node-fetch. Instead use \`fetch\`.
21Do NOT use newlines. Just use semicolons.
22You can import libraries from npm: \`const {default: _} = await import("npm:lodash")\`
44 try {
45 console.log(req.body);
46 let result = await fetchJSON(
47 "https://api.val.town/v1/eval",
48 { method: "POST", body: JSON.stringify(req.body) },

proxyFetch2 file matches

@vidar•Updated 1 hour ago

TAC_FetchBasic2 file matches

@A7_OMC•Updated 16 hours ago