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=470&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 5369 results for "api"(885ms)

git_jiggymain.tsx2 matches

@stevekrouse•Updated 7 months ago
344 <style>${css}</style>
345 <meta name="viewport" content="width=device-width, initial-scale=1.0">
346 <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet">
347 </head>
348 <body>
381 `;
382
383 const response = await fetch("https://api.github.com/graphql", {
384 method: "POST",
385 headers: {

js_auth_authenticatemain.tsx2 matches

@marcomontalbano•Updated 7 months ago
1import { authenticate, getCoreApiBaseEndpoint, jwtVerify } from "jsr:@commercelayer/js-auth";
2
3const auth = await authenticate("client_credentials", {
12if ("organization" in decodedJWT.payload) {
13 console.log("organization slug is", decodedJWT.payload.organization.slug);
14 console.log("base endpoint is", getCoreApiBaseEndpoint(auth.accessToken));
15}

freesoundSearchmain.tsx3 matches

@sedson•Updated 7 months ago
7import * as qs from "https://deno.land/x/querystring@v1.0.2/mod.js";
8
9const FREESOUND_API_KEY = Deno.env.get("FREESOUND_API_KEY");
10const BASE_URL = "https://freesound.org/apiv2";
11
12interface FreeSoundResponse {
28 const queryString = qs.stringify({
29 query: query,
30 token: FREESOUND_API_KEY,
31 fields: "id,name,previews",
32 page_size: 1,

iframeGridInfinitemain.tsx4 matches

@maxm•Updated 7 months ago
142 setIsLoading(true);
143 try {
144 const response = await fetch('/api/submit-url', {
145 method: 'POST',
146 headers: {
162 const loadUrlDatabase = async () => {
163 try {
164 const response = await fetch('/api/load-urls');
165 if (!response.ok) throw new Error('Failed to load URLs');
166 const loadedUrls = await response.json();
256
257async function server(request: Request): Promise<Response> {
258 if (request.method === 'POST' && new URL(request.url).pathname === '/api/submit-url') {
259 return handleSubmitUrl(request);
260 }
261
262 if (request.method === 'GET' && new URL(request.url).pathname === '/api/load-urls') {
263 return handleLoadUrls();
264 }

drumMachinemain.tsx1 match

@sedson•Updated 7 months ago
1// A web audio drum machine that pulls samples from the Freesound search API.
2// A 16-step step sequencer with 4 sampled voices. Each sample is the first two
3// seconds of a Freesound search result. Tweaking the search string a little bit

githubreposearchmain.tsx3 matches

@toowired•Updated 7 months ago
7 const order = "desc";
8
9 const url = `https://api.github.com/search/repositories?q=${encodeURIComponent(query)}&sort=${sort}&order=${order}`;
10
11 const response = await fetch(url, {
12 headers: {
13 "Accept": "application/vnd.github.v3+json",
14 "User-Agent": "Deno-GitHub-Repo-Fetcher", // GitHub API requires a user-agent header
15 },
16 });
17
18 if (!response.ok) {
19 throw new Error(`GitHub API responded with status: ${response.status}`);
20 }
21

gptMemoryManagerREADME.md20 matches

@toowired•Updated 7 months ago
1A simple Rest API that allows for you GPT to save and recall snippets of data (memories). You can read my blog post explaining it in detail here: [xkonti.tech](https://xkonti.tech/blog/giving-gpt-memory/)
2
3# Demonstration
7![FirstConversation.png](https://imagedelivery.net/iHX6Ovru0O7AjmyT5yZRoA/78c48b8b-8a1b-4caf-ef23-2ad78be3a100/public)
8
9What GPT sent do the API:
10
11```json
24# Setup
25
26There are several steps to set up the API:
27- deploy and configure the API
28- create the API key for your GPT
29- add an action for the API in you GPT
30- add prompt section to your GPT so that it can use it properly
31
32## Deploying the API on Val Town
33
34Deploy your own memory API. You can fork the following Val to do it: https://www.val.town/v/xkonti/memoryApiExample
35
36In the code configure the appropriate values:
37
38- `apiName` the name of your API - used in the Privacy Policy (eg. `Memory API`)
39- `contactEmail` - the email to provide for contact in the Privacy Policy (eg. `some@email.com`)
40- `lastPolicyUpdate` - the date the Privacy Policy was last updated (eg. `2023-11-28`)
41- `blobKeyPrefix` - the prefix for the blob storage keys used by your API - more info below (eg. `gpt:memories:`)
42- `apiKeyPrefix` - the prefix for you API Keys secrets - more info below (eg. `GPTMEMORYAPI_KEY_`)
43
44## Create API keys
45
46The Memory API is designed to serve multiple GPTs at the same time. Each GPT should have it's own unique **name** and **API key**.
47
48The **name** is used for identifying the specific GPT and appended to both:
49- `blobKeyPrefix`- to maintain separate memory storage from other GPTs
50- `apiKeyPrefix` - to maintain separate API key for each GPT
51
521. Please pick a unique alphanumeric name for your GPT. For example `personaltrainer`.
532. Generate some alphanumeric API key for your GPT. For example `Wrangle-Chapped-Monkhood4-Domain-Suspend`
543. Add a new secret to your Val.town secrets storage. The Key should be the picked name prefixed by `apiKeyPrefix`. Using the default it would be `GPTMEMORYAPI_KEY_personaltrainer`. The value of the secret should be the API key itself.
55
56The memories of the GPT will be stored in the blob storage under the key `blobKeyPrefix + name`, for example: `gpt:memories:personaltrainer`.
59
601. Add a new action in your GPT.
612. Get the OpenAPI spefication by calling the `/openapi` endpoint of your API
623. Change all `<APIURL>` instances within the specification to the url of your deployed API. For example `https://xkonti-memoryapiexample.web.val.run`
634. Set the authentication method to basic and provide a [base64 encoded](https://www.base64encode.org/) version of the `<name>:<apiKey>`. For example: `personaltrainer:Wrangle-Chapped-Monkhood4-Domain-Suspend` -> `cGVyc29uYWx0cmFpbmVyOldyYW5nbGUtQ2hhcHBlZC1Nb25raG9vZDQtRG9tYWluLVN1c3BlbmQ=`
645. Add the link to the privacy policy, which is the `/privacy` endpoint of your API. For example: `https://xkonti-memoryapiexample.web.val.run/privacy`
65
66## Adding the prompt section

gptMemoryManagermain.tsx24 matches

@toowired•Updated 7 months ago
1import * as uuid from "https://deno.land/std/uuid/mod.ts";
2import { blob } from "https://esm.town/v/std/blob";
3import { getPolicy } from "https://esm.town/v/xkonti/memoryApiPolicy";
4import { Hono } from "npm:hono@3";
5
6export const handleMemoryApiRequest = async (
7 req: Request,
8 apiName: string,
9 contactEmail: string,
10 lastPolicyUpdate: string,
11 blobKeyPrefix: string,
12 apiKeyPrefix: string,
13) => {
14 // ==== HELPERS ====
27
28 const verifyRequest = (c): { memoriesKey: string; error: any } => {
29 // Verify API key coming as a Bearer header
30 const authHeader = c.req.headers.get("Authorization");
31 if (!authHeader || !authHeader.startsWith("Basic ")) {
43 return { memoriesKey: "", error: c.text("Forbidden", 403) };
44 }
45 const expectedKey = Deno.env.get(apiKeyPrefix + key) ?? null;
46 if (token !== expectedKey) {
47 console.error("Invalid API KEY header");
48 return { memoriesKey: "", error: c.text("Forbidden", 403) };
49 }
51 };
52
53 // API
54
55 const app = new Hono();
209 // PRIVACY POLICY
210 app.get("/privacy", async (c) => {
211 const policy = getPolicy(apiName, contactEmail, lastPolicyUpdate);
212 c.header("Content-Type", "text/html");
213 return c.html(policy);
214 });
215
216 app.get("/openapi", async (c) => {
217 const specification = `
218{
219 "openapi": "3.1.0",
220 "info": {
221 "title": "Memories API",
222 "description": "API for managing and storing long-term memories.",
223 "version": "1.0.0"
224 },
225 "servers": [
226 {
227 "url": "<APIURL>"
228 }
229 ],
238 },
239 "401": {
240 "description": "Unauthorized - Missing or invalid API key."
241 },
242 "403": {
243 "description": "Forbidden - Invalid API key."
244 }
245 },
272 },
273 "401": {
274 "description": "Unauthorized - Missing or invalid API key."
275 },
276 "403": {
277 "description": "Forbidden - Invalid API key."
278 }
279 },
328 },
329 "401": {
330 "description": "Unauthorized - Missing or invalid API key."
331 },
332 "403": {
333 "description": "Forbidden - Invalid API key."
334 }
335 },
375 },
376 "401": {
377 "description": "Unauthorized - Missing or invalid API key."
378 },
379 "403": {
380 "description": "Forbidden - Invalid API key."
381 }
382 },
406 },
407 "401": {
408 "description": "Unauthorized - Missing or invalid API key."
409 },
410 "403": {
411 "description": "Forbidden - Invalid API key."
412 }
413 },

gpt_memoryREADME.md20 matches

@toowired•Updated 7 months ago
1A simple Rest API that allows for you GPT to save and recall snippets of data (memories). You can read my blog post explaining it in detail here: [xkonti.tech](https://xkonti.tech/blog/giving-gpt-memory/)
2
3# Demonstration
7![FirstConversation.png](https://imagedelivery.net/iHX6Ovru0O7AjmyT5yZRoA/78c48b8b-8a1b-4caf-ef23-2ad78be3a100/public)
8
9What GPT sent do the API:
10
11```json
24# Setup
25
26There are several steps to set up the API:
27- deploy and configure the API
28- create the API key for your GPT
29- add an action for the API in you GPT
30- add prompt section to your GPT so that it can use it properly
31
32## Deploying the API on Val Town
33
34Deploy your own memory API. You can fork the following Val to do it: https://www.val.town/v/xkonti/memoryApiExample
35
36In the code configure the appropriate values:
37
38- `apiName` the name of your API - used in the Privacy Policy (eg. `Memory API`)
39- `contactEmail` - the email to provide for contact in the Privacy Policy (eg. `some@email.com`)
40- `lastPolicyUpdate` - the date the Privacy Policy was last updated (eg. `2023-11-28`)
41- `blobKeyPrefix` - the prefix for the blob storage keys used by your API - more info below (eg. `gpt:memories:`)
42- `apiKeyPrefix` - the prefix for you API Keys secrets - more info below (eg. `GPTMEMORYAPI_KEY_`)
43
44## Create API keys
45
46The Memory API is designed to serve multiple GPTs at the same time. Each GPT should have it's own unique **name** and **API key**.
47
48The **name** is used for identifying the specific GPT and appended to both:
49- `blobKeyPrefix`- to maintain separate memory storage from other GPTs
50- `apiKeyPrefix` - to maintain separate API key for each GPT
51
521. Please pick a unique alphanumeric name for your GPT. For example `personaltrainer`.
532. Generate some alphanumeric API key for your GPT. For example `Wrangle-Chapped-Monkhood4-Domain-Suspend`
543. Add a new secret to your Val.town secrets storage. The Key should be the picked name prefixed by `apiKeyPrefix`. Using the default it would be `GPTMEMORYAPI_KEY_personaltrainer`. The value of the secret should be the API key itself.
55
56The memories of the GPT will be stored in the blob storage under the key `blobKeyPrefix + name`, for example: `gpt:memories:personaltrainer`.
59
601. Add a new action in your GPT.
612. Get the OpenAPI spefication by calling the `/openapi` endpoint of your API
623. Change all `<APIURL>` instances within the specification to the url of your deployed API. For example `https://xkonti-memoryapiexample.web.val.run`
634. Set the authentication method to basic and provide a [base64 encoded](https://www.base64encode.org/) version of the `<name>:<apiKey>`. For example: `personaltrainer:Wrangle-Chapped-Monkhood4-Domain-Suspend` -> `cGVyc29uYWx0cmFpbmVyOldyYW5nbGUtQ2hhcHBlZC1Nb25raG9vZDQtRG9tYWluLVN1c3BlbmQ=`
645. Add the link to the privacy policy, which is the `/privacy` endpoint of your API. For example: `https://xkonti-memoryapiexample.web.val.run/privacy`
65
66## Adding the prompt section

bookReservationOnResymain.tsx7 matches

@ireneg•Updated 7 months ago
30}) => {
31 const { z } = await import("npm:zod");
32 const RESY_API_URL = "https://api.resy.com";
33 const RESY_DEFAULT_HEADERS = {
34 accept: "application/json, text/plain, */*",
35 "accept-encoding": "gzip, deflate, br",
36 "accept-language": "en-US,en;q=0.9",
37 authorization: "ResyAPI api_key=\"VbWk7s3L4KiK5fzlO7JD3Q5EYolJI7n5\"",
38 "x-origin": "https://resy.com",
39 origin: "https://resy.com/",
145 )
146 }&password=${encodeURIComponent(params.password)}`;
147 const response = await fetch(`${RESY_API_URL}/3/auth/password`, {
148 method: "POST",
149 body: body,
166 seats: number;
167 }) => {
168 const url = `${RESY_API_URL}/3/details`;
169 const response = await fetch(url.toString(), {
170 method: "POST",
185 seats: number;
186 }) => {
187 const url = `${RESY_API_URL}/4/find`;
188 const searchParams = new URLSearchParams();
189 searchParams.set("lat", "0");
208 city: string;
209 }) => {
210 const url = `${RESY_API_URL}/3/venue`;
211 const searchParams = new URLSearchParams();
212 searchParams.set("url_slug", params.slug);
224 authToken: string;
225 }) => {
226 const response = await fetch(`${RESY_API_URL}/3/book`, {
227 method: "POST",
228 headers: {

runValAPIEx2 file matches

@charmaine•Updated 1 day ago

PassphraseAPI2 file matches

@wolf•Updated 3 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)