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=502&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 6292 results for "api"(832ms)

sonnetmain.tsx9 matches

@manyone•Updated 5 months ago
3export default async function generatePoem() {
4 try {
5 // Retrieve the Anthropic API key from environment variables
6 const apiKey = Deno.env.get("ANTHROPIC_API_KEY");
7
8 // Check if API key is present
9 if (!apiKey) {
10 throw new Error("Anthropic API key is missing. Please set the ANTHROPIC_API_KEY environment variable.");
11 }
12
13 // Create Anthropic instance with the API key
14 const anthropic = new Anthropic({
15 apiKey: apiKey,
16 });
17
18 console.log("Anthropic API Key Status: Present ✅");
19 console.log("Attempting to create message...");
20
64 // More detailed error logging
65 if (error.response) {
66 console.error("API Response Error Details:", {
67 status: error.response.status,
68 body: error.response.body,

Jokesmain.tsx1 match

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

gregariousIvoryOstrichmain.tsx3 matches

@danieladmsf•Updated 5 months ago
230 <head>
231 <title>Seller Dashboard</title>
232 <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap" rel="stylesheet">
233 <style>${css}</style>
234 </head>
323 margin-bottom: 10px;
324 opacity: 0.7;
325 text-transform: capitalize;
326 }
327
414 text-align: left;
415 font-weight: 500;
416 text-transform: capitalize;
417 border-bottom: 2px solid #E0E4E8;
418 }

twitterAlertREADME.md3 matches

@nick•Updated 5 months ago
4
5This val gets Twitter data via [SocialData](https://socialdata.tools) via
6@stevekrouse/socialDataProxy. Val Town Pro users can call this API
7100 times per day, so be sure not to set this cron to run more than once every 15 min.
8If you want to use it more, get your own [SocialData](https://socialdata.tools)
9API token and pay for it directly.
10
11## 1. Query
13Change the `query` variable for what you want to get notified for.
14
15You can use [Twitter's search operators](https://developer.twitter.com/en/docs/twitter-api/v1/rules-and-filtering/search-operators) to customize your query, for some collection of keywords, filtering out others, and much more!
16
17## 2. Notification

memorySampleSummarymain.tsx2 matches

@toowired•Updated 5 months ago
69export async function memoryBankDemo() {
70 // Add some memories
71 await addMemory("Create a RESTful API using Express.js and PostgreSQL");
72 await addMemory("Implement user authentication with JWT tokens");
73 await addMemory("Set up a WebSocket server for real-time communication");
74
75 // Retrieve similar memories
76 const query = "How to create a backend API?";
77 const similarMemories = await getSimilarMemories(query);
78

sqlitemain.tsx4 matches

@toowired•Updated 5 months ago
1import { API_URL } from "https://esm.town/v/std/API_URL";
2import { LibsqlError, type ResultSet, type Row, type TransactionMode } from "npm:@libsql/client";
3import { z } from "npm:zod";
35
36async function execute(statement: InStatement, args?: InArgs): Promise<ResultSet> {
37 const res = await fetch(`${API_URL}/v1/sqlite/execute`, {
38 method: "POST",
39 headers: {
50
51async function batch(statements: InStatement[], mode?: TransactionMode): Promise<ResultSet[]> {
52 const res = await fetch(`${API_URL}/v1/sqlite/batch`, {
53 method: "POST",
54 headers: {
78
79/* Val Town's Turso Proxy returns rows as an array of values
80 * Yet the LibSQL API has a Row type which behave as an array or object,
81 * ie you can access it via numerical index or string
82 */

redditSearchmain.tsx5 matches

@cofsana•Updated 5 months ago
11interface RedditSearchOptions {
12 query: string;
13 apiKey?: string;
14}
15
17export async function redditSearch({
18 query,
19 apiKey = Deno.env.get("BROWSERBASE_API_KEY"),
20}: RedditSearchOptions): Promise<ThreadResult[]> {
21 if (!apiKey) {
22 throw new Error("BrowserBase API key is required");
23 }
24
25 const puppeteer = new PuppeteerDeno({ productName: "chrome" });
26 const browser = await puppeteer.connect({
27 browserWSEndpoint: `wss://connect.browserbase.com?apiKey=${apiKey}&enableProxy=true`,
28 ignoreHTTPSErrors: true,
29 });

aqiREADME.md1 match

@daabin•Updated 5 months ago
8
91. Click `Fork`
102. Change `location` (Line 4) to describe your location. It accepts fairly flexible English descriptions which it turns into locations via [nominatim's geocoder API](https://www.val.town/v/stevekrouse/nominatimSearch).
113. Click `Run`
12

TaylorSwiftMomentsmain.tsx10 matches

@vawogbemi•Updated 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") {

toowiredmemoriesmain.tsx35 matches

@toowired•Updated 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": {

daily-advice-app1 file match

@dcm31•Updated 8 hours ago
Random advice app using Advice Slip API

runValAPIEx2 file matches

@charmaine•Updated 1 day ago
rapilot330
YoungPapi