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=823&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 11605 results for "api"(1895ms)

dailyDadJokemain.tsx1 match

@frobyteUpdated 8 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,

dailyDadJokeREADME.md2 matches

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

@njuribarriUpdated 8 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,

blob_adminREADME.md1 match

@tr11Updated 8 months ago
9[![](https://stevekrouse-button.express.val.run/Install)](https://www.val.town/v/stevekrouse/blob_admin_app/fork)
10
11It uses [basic authentication](https://www.val.town/v/pomdtr/basicAuth) with your [Val Town API Token](https://www.val.town/settings/api) as the password (leave the username field blank).
12
13# TODO

dailyDadJokeREADME.md2 matches

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

@megafredrikUpdated 8 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,

VALLEREADME.md3 matches

@liviuUpdated 8 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"/>

claudeForwardermain.tsx14 matches

@prabhanshuUpdated 8 months ago
1// This val implements a function to call the Claude API using fetch.
2// It handles the API request and response processing.
3// The Claude API key is expected to be provided in the request headers.
4// CORS is enabled for all origins.
5
11 "Access-Control-Allow-Origin": "*",
12 "Access-Control-Allow-Methods": "POST, OPTIONS",
13 "Access-Control-Allow-Headers": "Content-Type, x-api-key",
14 },
15 });
20 }
21
22 const apiKey = req.headers.get("x-api-key");
23 if (!apiKey) {
24 return new Response("Claude API key not provided in headers", { status: 400 });
25 }
26
30 const systemPrompt = params["system_prompt"];
31 const userPrompt = params["user_prompt"];
32 const claudeResponse = await callClaudeApi(systemPrompt, userPrompt, apiKey);
33 return new Response(claudeResponse, {
34 headers: {
48}
49
50async function callClaudeApi(systemPrompt: string, userPrompt: string, apiKey: string): Promise<string> {
51 const url = "https://api.anthropic.com/v1/messages";
52 const headers = {
53 "Content-Type": "application/json",
54 "x-api-key": apiKey,
55 "anthropic-version": "2023-06-01",
56 "anthropic-beta": "prompt-caching-2024-07-31",
83
84 const responseData = await response.json();
85 console.log("Claude API response:", responseData);
86
87 if (response.ok) {
88 return responseData.content[0].text;
89 } else {
90 throw new Error(`API Error: ${response.status}, ${JSON.stringify(responseData)}`);
91 }
92 } catch (error) {
93 console.error("Error calling Claude API:", error);
94 throw error;
95 }

valleGetValsContextWindowmain.tsx7 matches

@roadlabsUpdated 8 months ago
13 const readmeVals: any = await (await fetch("https://janpaul123-readmevals.web.val.run/")).json();
14
15 const API_URL = "https://api.val.town";
16
17 const sections = [
129 {
130 prompt: "Write a val that accesses environment variables",
131 code: `const res = await fetch("${API_URL}/v1/me", {
132 headers: {
133 Authorization: \`Bearer \${Deno.env.get("valtown")}\`,
141 code: `import process from "node:process";
142
143 const res = await fetch("${API_URL}/v1/me", {
144 headers: {
145 Authorization: \`Bearer \${process.env.valtown}\`,
310 You can attach files to your emails by using the \`attachments\` field.
311 Attachments need to be [Base64](https://en.wikipedia.org/wiki/Base64) encoded,
312 which is that the [btoa](https://developer.mozilla.org/en-US/docs/Web/API/btoa)
313 method is doing in this example:
314
412 \`\`\`
413
414 ### Lower-level API
415
416 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.
417
418 - \`async get(key: string)\`: Retrieves a blob for a given key.
419 - \`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).
420
421 ### Limitations
458 role: "assistant",
459 content:
460 "```ts\nexport default async function(req: Request): Promise<Response> {\n const apiKey = Deno.env.get(\"METEO_KEY\");\n const apiUrl = `https://api.open-meteo.com/v1/forecast?latitude=40.6782&longitude=-73.9442&hourly=temperature_2m&current_weather=true&apikey=${apiKey}`;\n\n const response = await fetch(apiUrl);\n const weatherData = await response.json();\n\n return new Response(JSON.stringify(weatherData), { headers: { \"Content-Type\": \"application/json\" } });\n}\n```",
461 },
462 {

valleBlogV0README.md1 match

@wlxiaozhzhUpdated 8 months ago
1* Fork this val to your own profile.
2* 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.
3

new-val-api-21 file match

@shouserUpdated 14 hours ago
This is an example of using the API to create a val.

gptApiTemplate2 file matches

@charmaineUpdated 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