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/$%7Bsuccess?q=api&page=939&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 13058 results for "api"(2102ms)

gptMemoryManagerREADME.md20 matches

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

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

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

gptMemoryManagerREADME.md20 matches

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

@amoz1Updated 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 },

lightGrayCrowmain.tsx1 match

@jeffreyyoungUpdated 7 months ago
1// This cron emails Hacker News stories from its API every 3 days.
2
3import { email } from "https://esm.town/v/std/email";

hackerNewsDigestmain.tsx1 match

@jeffreyyoungUpdated 7 months ago
1// This cron emails Hacker News stories from its API every 3 days.
2
3import { email } from "https://esm.town/v/std/email";

bookReservationOnResymain.tsx7 matches

@irenegUpdated 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: {

v2FanFicScrapermain.tsx30 matches

@willthereaderUpdated 7 months ago
11 e.preventDefault();
12 setLoading(true);
13 console.log(`Submitting URL for scraping: ${url}`);
14
15 const maxRetries = 3;
28 if (!response.ok) {
29 if (response.status === 400) {
30 throw new APIError("Bad request. Check your parameters.", response.status);
31 } else if (response.status === 401) {
32 throw new APIError("No more credit available. Please upgrade your plan.", response.status);
33 } else if (response.status === 404) {
34 throw new APIError("Requested URL not found.", response.status);
35 } else if (response.status === 429) {
36 throw new APIError("Too many concurrent requests. Please upgrade your plan.", response.status);
37 } else {
38 throw new APIError(`HTTP error! status: ${response.status}`, response.status);
39 }
40 }
44 break; // Exit the loop if successful
45 } catch (error) {
46 console.log(`Error occurred while scraping URL: ${url}. Error details: ${error.message}`);
47
48 if (error.name === "TypeError" && error.message === "Failed to fetch") {
76 />
77 <button type="submit" disabled={loading}>
78 {loading ? "Scraping..." : "Scrape"}
79 </button>
80 </form>
130async function scrapePage(url) {
131 console.log(`Starting to scrape page: ${url}`);
132 const apiKey = await getApiKey();
133
134 url = normalizeUrl(url);
135 console.log(`Normalized URL for scraping: ${url}`);
136
137 const extractRules = {
161 };
162
163 const result = await scrapePageWithRules(url, apiKey, extractRules);
164 return processResults(result);
165}
186}
187
188class APIError extends Error {
189 constructor(message, status) {
190 super(message);
191 this.name = "APIError";
192 this.status = status;
193 }
201}
202
203async function scrapePageWithRules(url, apiKey, extractRules) {
204 console.log(`Sending request to ScrapingBee API for URL: ${url}`);
205 try {
206 const response = await fetch(
207 `https://app.scrapingbee.com/api/v1/?api_key=${apiKey}&url=${
208 encodeURIComponent(url)
209 }&render_js=true&json_response=true&extract_rules=${encodeURIComponent(JSON.stringify(extractRules))}`,
211
212 if (!response.ok) {
213 throw new APIError(`HTTP error! status: ${response.status}`, response.status);
214 }
215
216 console.log("Response received from ScrapingBee API");
217 console.log(`Cost: ${response.headers.get("Spb-cost")}`);
218 console.log(`Initial status code: ${response.headers.get("Spb-initial-status-code")}`);
226 }
227
228 console.log("ScrapingBee API response parsed successfully");
229 return result;
230 } catch (error) {
231 if (error instanceof TypeError) {
232 console.error("Network error:", error.message);
233 throw new NetworkError("Failed to connect to the API");
234 } else if (error instanceof APIError) {
235 console.error("API error:", error.message, "Status:", error.status);
236 throw error;
237 } else if (error instanceof ParsingError) {
286}
287
288async function getApiKey() {
289 const apiKey = Deno.env.get("ScrapingBeeAPIkey");
290 if (!apiKey) {
291 console.log("ScrapingBee API key not found in environment variables");
292 throw new Error("ScrapingBee API key not found in environment variables");
293 }
294 return apiKey;
295}
296
302 const result = await scrapePage(url);
303 console.log(`Successfully scraped URL: ${url}`);
304 console.log(`Scraping completed for URL: ${url}
305 Result summary:
306 Title: ${result.title}
312 console.log(`Error occurred while processing request. Error details: ${error.message}`);
313 console.log(`Error stack trace: ${error.stack}`);
314 console.error(`Error occurred during scraping operation:
315 Error message: ${error.message}
316 Stack trace:

zottifymain.tsx1 match

@rapflUpdated 8 months ago
5
6const replicate = new Replicate({
7 auth: Deno.env.get("REPLICATE_API_TOKEN"),
8});
9

vapi-minutes-db1 file match

@henrywilliamsUpdated 2 days ago

vapi-minutes-db2 file matches

@henrywilliamsUpdated 2 days 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