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=996&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 10973 results for "api"(1434ms)

myApimain.tsx1 match

@valtism•Updated 1 year ago
1export function myApi(name) {
2 return "hi " + name;
3}

myApimain.tsx1 match

@cat•Updated 1 year ago
1export function myApi(name) {
2 return "hi " + name;
3}

lichessTVGamesmain.tsx2 matches

@jdan•Updated 1 year ago
8 | "Computer"
9 | "Horde"
10 | "Rapid"
11 | "Atomic"
12 | "Crazyhouse"
30type Games = Record<GameType, Entry>;
31export async function lichessTVGames(): Promise<Games> {
32 const channels = await fetch("https://lichess.org/api/tv/channels");
33 return await channels.json();
34}

YoutubeTranscriptmain.tsx7 matches

@zzz•Updated 1 year ago
5 /(?:youtube\.com\/(?:[^\/]+\/.+\/|(?:v|e(?:mbed)?)\/|.*[?&]v=)|youtu\.be\/)([^"&?\/\s]{11})/i;
6 const YouTubeKey = {
7 apiKey: "INNERTUBE_API_KEY",
8 serializedShareEntity: "serializedShareEntity",
9 visitorData: "VISITOR_DATA",
94 );
95 const body = await textResponse.text();
96 const apiKey = this.extractValue(body, YouTubeKey.apiKey);
97 if (!apiKey || !apiKey.length) {
98 throw new YoutubeTranscriptError(
99 `Failed to extract ${YouTubeKey.apiKey}`,
100 );
101 }
102 const transcriptResponse = await fetch(
103 `https://www.youtube.com/youtubei/v1/get_transcript?key=${apiKey}`,
104 {
105 method: "POST",
158 }
159 /**
160 * Generate tracking params for YouTube API
161 * @param page
162 * @param config
229 }
230 /**
231 * Generate nonce for clientScreenNonce as part of YouTube API
232 */
233 static generateNonce() {

pollVotingJobmain.tsx1 match

@pranjaldotdev•Updated 1 year ago
17 try {
18 const votingURL =
19 "https://jc-voting-prod.api.engageapps.jio/api/voting/questions/q-e4d1acfe-abd5-4417-a80b-1a9e0f54174a/answer";
20 const token =
21 "eyJhbGciOiJIUzI1NiJ9.eyJwbGF0Zm9ybSI6Imppb3Zvb3QiLCJ1c2VyaWR0eXBlIjoidXVpZCIsImlzSmlvVXNlciI6ZmFsc2UsImlzR3Vlc3QiOmZhbHNlLCJwaG9uZU5vIjoiMzM2NjBiNzQtM2U5YS00ZWJhLTlmMTMtNzBkNTQ3NmUwOTNkIiwicHJvZmlsZUlkIjoiMTE1ODc3YWQtZDE3Mi00YTAwLWI2OTMtMDlkZmNjNTEwOTMyIiwiaWF0IjoxNjg5NzA0MzA0LCJleHAiOjE2ODk3OTA3MDR9.ICKpSLJJexKR0wjDYDMpctvdTV33P0J6pxL3MAxWJyg";

big_storymain.tsx1 match

@tmcw•Updated 1 year ago
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();
10 const now = Date.now();

testVTClientmain.tsx3 matches

@stevekrouse•Updated 1 year ago
1export const testVTClient = (async () => {
2 const { createApiClient } = await import(
3 "https://esm.sh/gh/nbbaier/valtown-zodios@main/src/spec/valtown-client.ts"
4 );
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);
10 return user;
11})();

testMutateSemanticsmain.tsx5 matches

@stevekrouse•Updated 1 year ago
4export async function testMutateSemantics({
5 stateName,
6 api,
7 mutateExpected,
8 expected,
11}: {
12 stateName: string;
13 api: string;
14 mutateExpected?: boolean;
15 expected?: (old, next) => 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
26 ? {
30 );
31 const { data: next } = await fetchJSON(
32 `${api}/eval/${stateName}`
33 );
34 const mutated = next === now;

notionGetDatabasemain.tsx2 matches

@stevekrouse•Updated 1 year 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,

chatGPTPluginmain.tsx14 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
4// https://stevekrouse-chatgptplugin.express.val.run/.well-known/ai-plugin.json
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.
25 "type": "none",
26 },
27 "api": {
28 "type": "openapi",
29 "url": "/openapi",
30 },
31 "logo_url":
35 });
36 }
37 else if (req.path === "/openapi") {
38 // OpenAPI Spec
39 // only POST /v1/eval for now
40 res.send(openaiOpenAPI);
41 }
42 else if (req.path === "/v1/eval") {
43 // Proxy /v1/eval to api.val.town
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) },
49 );

daily-advice-app1 file match

@dcm31•Updated 2 days ago
Random advice app using Advice Slip API

gptApiTemplate1 file match

@charmaine•Updated 3 days ago
apiv1
papimark21