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=767&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 11714 results for "api"(907ms)

sqliteExplorerAppmain.tsx2 matches

@thesolarmonkUpdated 5 months ago
27 <head>
28 <title>SQLite Explorer</title>
29 <link rel="preconnect" href="https://fonts.googleapis.com" />
30
31 <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
32 <link
33 href="https://fonts.googleapis.com/css2?family=Fira+Code:wght@300..700&family=Source+Sans+3:ital,wght@0,200..900;1,200..900&display=swap"
34 rel="stylesheet"
35 />

TaylorSwiftMomentsmain.tsx10 matches

@vawogbemiUpdated 5 months ago
207 const fetchImages = async () => {
208 try {
209 const response = await fetch("/api/images");
210 const images = await response.json();
211 setGalleryImages(images);
220 try {
221 // Enhance the prompt using the server-side endpoint
222 const enhancedPromptResponse = await fetch("/api/enhance-prompt", {
223 method: "POST",
224 headers: { "Content-Type": "application/json" },
232
233 const fal = createFalClient({
234 proxyUrl: "/api/fal/proxy",
235 });
236
260 const likeImage = async (imageId) => {
261 try {
262 await fetch(`/api/images/${imageId}/like`, { method: "POST" });
263 fetchImages(); // Refresh the gallery after liking
264 } catch (error) {
269 const deleteImage = async (imageId) => {
270 try {
271 await fetch(`/api/images/${imageId}`, { method: "DELETE" });
272 fetchImages(); // Refresh the gallery after deleting
273 } catch (error) {
278 const addToGallery = async () => {
279 try {
280 await fetch("/api/images", {
281 method: "POST",
282 headers: { "Content-Type": "application/json" },
439 }
440
441 if (url.pathname === "/api/fal/proxy") {
442 return falProxyRequest(req);
443 }
444
445 if (url.pathname === "/api/enhance-prompt") {
446 if (req.method === "POST") {
447 const { prompt, era } = await req.json();
471 }
472
473 if (url.pathname === "/api/images") {
474 if (req.method === "GET") {
475 const images = await sqlite.execute(`
495 }
496
497 if (url.pathname.startsWith("/api/images/")) {
498 const id = url.pathname.split("/")[3];
499 if (url.pathname.endsWith("/like") && req.method === "POST") {

vigilantRedHamstermain.tsx1 match

@timmymattenUpdated 5 months ago
5async function fetchRandomJoke() {
6 const response = await fetch(
7 "https://official-joke-api.appspot.com/random_joke",
8 );
9 return response.json();

toowiredmemoriesmain.tsx35 matches

@toowiredUpdated 5 months ago
1import { v1 as uuidv1 } from "https://esm.sh/uuid@9.0.0";
2import { blob } from "https://esm.town/v/std/blob";
3import { getPolicy } from "https://esm.town/v/xkonti/memoryApiPolicy";
4import { Hono } from "https://esm.sh/hono@3.5.4";
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 ====
47 }
48
49 const expectedKey = Deno.env.get(apiKeyPrefix + key);
50 if (token !== expectedKey) {
51 return { memoriesKey: "", error: c.text("Forbidden", 403) };
55 };
56
57 // API
58
59 const app = new Hono();
283
284 app.get("/privacy", async (c) => {
285 const policy = getPolicy(apiName, contactEmail, lastPolicyUpdate);
286 c.header("Content-Type", "text/html");
287 return c.html(policy);
288 });
289
290 app.get("/openapi", async (c) => {
291 const specification = `
292{
293 "openapi": "3.1.0",
294 "info": {
295 "title": "Memories and Conversations API",
296 "description": "API for managing and storing long-term memories, AI conversations, and file attachments.",
297 "version": "1.3.0"
298 },
299 "servers": [
300 {
301 "url": "<APIURL>"
302 }
303 ],
327 },
328 "401": {
329 "description": "Unauthorized - Missing or invalid API key."
330 },
331 "403": {
332 "description": "Forbidden - Invalid API key."
333 }
334 },
372 },
373 "401": {
374 "description": "Unauthorized - Missing or invalid API key."
375 },
376 "403": {
377 "description": "Forbidden - Invalid API key."
378 }
379 },
423 },
424 "401": {
425 "description": "Unauthorized - Missing or invalid API key."
426 },
427 "403": {
428 "description": "Forbidden - Invalid API key."
429 },
430 "404": {
483 },
484 "401": {
485 "description": "Unauthorized - Missing or invalid API key."
486 },
487 "403": {
488 "description": "Forbidden - Invalid API key."
489 }
490 },
513 },
514 "401": {
515 "description": "Unauthorized - Missing or invalid API key."
516 },
517 "403": {
518 "description": "Forbidden - Invalid API key."
519 },
520 "404": {
563 },
564 "401": {
565 "description": "Unauthorized - Missing or invalid API key."
566 },
567 "403": {
568 "description": "Forbidden - Invalid API key."
569 }
570 },
613 },
614 "401": {
615 "description": "Unauthorized - Missing or invalid API key."
616 },
617 "403": {
618 "description": "Forbidden - Invalid API key."
619 },
620 "404": {
673 },
674 "401": {
675 "description": "Unauthorized - Missing or invalid API key."
676 },
677 "403": {
678 "description": "Forbidden - Invalid API key."
679 },
680 "404": {
724 },
725 "401": {
726 "description": "Unauthorized - Missing or invalid API key."
727 },
728 "403": {
729 "description": "Forbidden - Invalid API key."
730 },
731 "404": {
743 "get": {
744 "summary": "Get privacy policy",
745 "description": "Retrieve the privacy policy for the API.",
746 "responses": {
747 "200": {
758 }
759 },
760 "/openapi": {
761 "get": {
762 "summary": "Get OpenAPI specification",
763 "description": "Retrieve the OpenAPI specification for the API.",
764 "responses": {
765 "200": {
766 "description": "Successful retrieval of the OpenAPI specification.",
767 "content": {
768 "application/json": {

toowiredmemoriesREADME.md21 matches

@toowiredUpdated 5 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
86```
87
88Migrated from folder: APIs/toowiredmemories

fetchNewPublicGitHubReposmain.tsx3 matches

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

honoOpenaiREADME.md1 match

@wizosUpdated 5 months ago
3The app is set up so you can easily have a conversation between two people. The app will translate between the two selected languages, in each voice, as the speakers talk.
4
5Add your OpenAI API Key, and make sure to open in a separate window for Mic to work.

honoOpenaimain.tsx4 matches

@wizosUpdated 5 months ago
6
7const app = new Hono();
8const openai = new OpenAI(Deno.env.get("OPENAI_API_KEY_VOICE"));
9
10class TranscriptionService {
19 return transcription;
20 } catch (error) {
21 console.error("OpenAI API error:", error);
22 throw error;
23 }
423 return c.text(translation);
424 } catch (error) {
425 console.error("OpenAI API error:", error);
426 return c.text("Error occurred during translation", 500);
427 }
450 });
451 } catch (error) {
452 console.error("OpenAI API error:", error);
453 return c.text("Error occurred during speech generation", 500);
454 }

sendNotificationREADME.md1 match

@wizosUpdated 5 months ago
1# Push Notification Sender
2
3This val can be used in other vals to send notifications to a segment using [OneSignal's REST API](https://documentation.onesignal.com/reference/create-notification)
4
5This is really handy if you want to send push notifications to your phone without building a native app! I built a barebones React PWA that asks for a password then loads the OneSignal Web SDK that I deployed to [Netlify](https://www.netlify.com/) for free. OneSignal has [easy to follow docs](https://documentation.onesignal.com/docs/web-sdk-setup) so you can build this functionality into a React, Angular, Vue app or even Wordpress! Then [install the PWA](https://www.bitcot.com/how-to-install-a-pwa-to-your-device/) on your platform of choice and you're off to the races!

sendNotificationmain.tsx1 match

@wizosUpdated 5 months ago
6const defaultSegment = [Deno.env.get("DEFAULT_ONESIGNAL_SEGMENT")];
7
8const onesignalURL = "https://onesignal.com/api/v1/notifications";
9
10/**

gpt-image-test

@CaptainJackUpdated 27 mins ago
测试 gpt image 的不同 api 能否满足图片生成要求

new-val-api-21 file match

@shouserUpdated 1 day ago
This is an example of using the API to create a val.
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