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=1250&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 19255 results for "api"(2817ms)

utilsREADME.md1 match

@alexwein•Updated 2 months ago
1# Val Town Project Utilities
2
3These utils are very rapidly developing, so expect breaking changes.
4
5* file - reading files and directories in Projects

HTTP101PUT4 matches

@willthereader•Updated 2 months ago
27 <a href="https://github.com/wkrouse">Github</a>
28 </nav>
29 <h1>How to make a PUT request with the Fetch API</h1>
30 <p> This page is a guide on how to PUT request with the Fetch API. First I'm going to
31 explain what why we're using the Fetch API. Then I'll explain what it is and the Val Town variant.
32 Finally I'll walk you through modifying the code example so that it allows you to replacing name with a
33 different name.</p>
34
35 <p>The reason we need to use the Fetch API is that the HTML form only works
36 for GET and POST methods. </p>
37

spacex_migratedmain.tsx2 matches

@moe•Updated 2 months ago
1/** @jsxImportSource npm:hono@3/jsx */
2import { frameHtml } from "https://esm.town/v/moe/frameHtml";
3import { getLaunches } from "https://esm.town/v/moe/spacexapi";
4import { spacexCalendar } from "https://esm.town/v/moe/spacexcalendar";
5import { getChartUrl } from "https://esm.town/v/moe/spacexchart";
83 {
84 /* <div class="mb-3">
85 <a href="/api" target="_blank">API</a>
86 </div>
87 <div class="mb-4">
askSMHI

askSMHIREADME.md19 matches

@ljus•Updated 2 months ago
1# askSMHI
2Using OpenAI chat completion with function calls to [SMHI](https://en.wikipedia.org/wiki/Swedish_Meteorological_and_Hydrological_Institute) api
3
4The API is instructed to use the current time in Europe/Stockholm timezone.
5If the message can not be handled with the weather API endpoint, the Open AI assistant will reply instead.
6
7
8## Relevant API documentation
9* [SMHI, forecast documentation](https://opendata.smhi.se/apidocs/metfcst/get-forecast.html)
10* [OPEN AI, GPT function calling documentation](https://platform.openai.com/docs/guides/function-calling?api-mode=chat&lang=javascript)
11
12## How to use this endpoint
17```typescript
18{
19answer?: string // If the message could not be answered with the SMHI API
20error?:string //
21data?: unknown // the actual data returned from SMHI, if the API is called
22summary?: string // a summary of the data, by GPT API
23 }
24```
26
27### Examples
28* How is the weather in the Capital of Sweden tomorrow.
29* How is the weather at Liseberg on Friday.
30
31## How it works
321. Handle the API request and count the tokens in the question.
332. Send the question to Open AI API moderation
343. Create tool calling by converting schema to JSON schema
354. Send the question to Open AI Chat Completion and expose tool calling
365. Make the API call to the SMHI API with parameters from OPEN AI
376. Add additional information to the SMHI response (converting numerical categories to text)
387. Remove data from the response that was not requested by the Open AI parameters.
398. Send the modified response to Open AI API together with the SMHI response JSON Schema.
409. Send a summary of the forcast (by Open AI API) together with the forecast data as a response to the initial request.
41
42## Enviroment variables
43* OPENAI_CHAT: Needs to be authorized to write chat completions and to the moderation API.
44## Packages used
45* openai: For typesafe API request and responses
46* valibot: for describing the SMHI API response and function API input
47* valibot/to-json-schema: Transform the schema to json schema (readable by the GPT API)
48* gpt-tokenizer: count the number of tokens
49* formkit/temporal: To handle dates in a specific timezone (Europe/Stockholm)
askSMHI

askSMHIservice1 match

@ljus•Updated 2 months ago
42 }[],
43 };
44 const openai = new OpenAI({ apiKey: process.env.OPENAI_CHAT });
45
46 const completion = await openai.chat.completions.create({
askSMHI

askSMHIfetcher1 match

@ljus•Updated 2 months ago
11 }
12 const response = await fetch(
13 `https://opendata-download-metfcst.smhi.se/api/category/pmp3g/version/2/geotype/point/lon/${lon}/lat/${lat}/data.json`,
14 );
15
askSMHI

askSMHImoderation1 match

@ljus•Updated 2 months ago
9 Authorization: `Bearer ${openAIKey}`,
10 };
11 const openai = new OpenAI({ apiKey: process.env.OPENAI_CHAT });
12 const responseData = await openai.moderations.create({ input: publicMessages });
13 return { flagged: responseData.results.some((r) => r.flagged) };

newCerebrasModelAlertmain.tsx2 matches

@stevekrouse•Updated 2 months ago
7 const historicalModels = await blob.getJSON("cerebras-models.json");
8
9 const currentModels = await fetchJSON("https://api.cerebras.ai/v1/models", {
10 bearer: Deno.env.get("CEREBRAS_API_KEY"),
11 });
12 await blob.setJSON("cerebras-models.json", currentModels);

OpenTowniesoundEffects.ts4 matches

@stevekrouse•Updated 2 months ago
4
5/**
6 * Plays a bell sound notification using the Web Audio API
7 * @returns A Promise that resolves when the sound has started playing
8 */
13 const AudioContext = window.AudioContext || (window as any).webkitAudioContext;
14 if (!AudioContext) {
15 console.warn("Web Audio API not supported in this browser");
16 resolve();
17 return;
65
66/**
67 * Plays a simple notification sound using the Web Audio API
68 * This is a simpler, shorter bell sound
69 * @returns A Promise that resolves when the sound has started playing
75 const AudioContext = window.AudioContext || (window as any).webkitAudioContext;
76 if (!AudioContext) {
77 console.warn("Web Audio API not supported in this browser");
78 resolve();
79 return;

instagramScrapingREADME.md1 match

@wolf•Updated 2 months ago
6
7- `/` - Main application page
8- `/extract?url={instagram_url}` - API endpoint to extract post data
9- `/extract?url={instagram_url}&proxyImage=true` - Endpoint to proxy Instagram images
10

api_ianmenethil_com133 file matches

@ianmenethil•Updated 8 hours ago

api_ianmenethil_com74 file matches

@ianmenethil•Updated 16 hours ago
apiry
snartapi