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=364&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 4592 results for "api"(635ms)

spagindex.html3 matches

@froos•Updated 1 month ago
231 uploadButton.disabled = true;
232 uploadButton.textContent = "Uploading...";
233 const response = await fetch("/api/upload", {
234 method: "POST",
235 body,
252
253 async function fetchUploads() {
254 const response = await fetch("/api/list");
255 const data = await response.json();
256 return data.rows;
396 deleteButton.textContent = "Deleting...";
397 const response = await fetch(
398 `/api/delete`,
399 {
400 method: "POST",

spagserver.ts3 matches

@froos•Updated 1 month ago
18 return serveFile(path, import.meta.url);
19 }
20 if (path.startsWith("/api/list")) {
21 // Get all rows from lab_upload_blobs
22 const response = await sqlite.execute(`
26 return Response.json({ ok: true, rows: response.rows });
27 }
28 if (path.startsWith("/api/upload")) {
29 return upload(req);
30 }
31 if (path.startsWith("/api/delete")) {
32 return _delete(req);
33 }

OpenTownieCreateBranch.tsx1 match

@stevekrouse•Updated 1 month ago
43
44 try {
45 const response = await fetch("/api/create-branch", {
46 method: "POST",
47 headers: {

apricothello.http.ts2 matches

@maxm•Updated 1 month ago
7 <meta name="viewport" content="width=device-width, initial-scale=1.0">
8 <title>Cremini</title>
9 <link rel="preconnect" href="https://fonts.googleapis.com">
10 <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
11 <link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;700&display=swap" rel="stylesheet">
12 <style>
13 body {

HTTP101POSTrequestFormGuide1 match

@willthereader•Updated 1 month ago
61 I'm being so specific with the name of the variable because that's industry standard.</li>
62 <li>The next step is to manipulate the request so it can be useful. There are a lot
63 of ways to manipulate the object and if you're curious read <a href="https://developer.mozilla.org/en-US/docs/Web/API/FormData#instance_methodsrun">this documentation</a>.
64 The way we're using is .getAll(). The name of the const variable doesn't matter. The input to .getAll()
65 is the value of the name attribute. Since I realized my description might not be clear,

utilsREADME.md1 match

@alexwein•Updated 1 month 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 1 month 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
askSMHI

askSMHIREADME.md19 matches

@ljus•Updated 1 month 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 1 month 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 1 month 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

PassphraseAPI2 file matches

@wolf•Updated 2 days ago

openapi2 file matches

@stevekrouse•Updated 4 days ago
artivilla
founder @outapint.io vibe coding on val.town. dm me to build custom vals: https://artivilla.com
fiberplane
Purveyors of Hono tooling, API Playground enthusiasts, and creators of 🪿 HONC 🪿 (https://honc.dev)