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/$2?q=api&page=9&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 15416 results for "api"(2073ms)

api2 file matches

@campsite•Updated 7 months ago

strivingSilverTapir1 file match

@dcm31•Updated 7 months ago

api

@romanewmedia•Updated 7 months ago

pageSpeedAPI1 file match

@eligosmlytics•Updated 7 months ago

getAirtableDataAPI1 file match

@stnkvcs•Updated 7 months ago

stockAPI2 file matches

@pete•Updated 8 months ago

arenaApiExample2 file matches

@deblina•Updated 8 months ago

smallweb_openapi_guide2 file matches

@all•Updated 8 months ago

smallweb_openapi1 file match

@pomdtr•Updated 8 months ago

addNumbersAPI

@rororowyourboat•Updated 8 months ago

pineconenew-file-6541.tsx32 matches

@mees•Updated 1 hour ago
1// MEES Assistant API Endpoint with v2 API
2// Remember to add your environment variables in Val settings:
3// - OPENAI_API_KEY
4// - PINECONE_API_KEY
5// - ASSISTANT_ID
6// - PARSER_ASSISTANT_ID (optional)
11// Use OpenAI client only for embeddings
12const openai = new OpenAI({
13 apiKey: Deno.env.get("OPENAI_API_KEY"),
14});
15
16// Initialize Pinecone
17const pinecone = new Pinecone({
18 apiKey: Deno.env.get("PINECONE_API_KEY"),
19});
20
42async function parseQueryIntent(query: string) {
43 try {
44 const OPENAI_API_KEY = Deno.env.get("OPENAI_API_KEY");
45
46 // Create a quick thread for parsing
47 const threadResponse = await fetch("https://api.openai.com/v1/threads", {
48 method: "POST",
49 headers: {
50 "Authorization": `Bearer ${OPENAI_API_KEY}`,
51 "Content-Type": "application/json",
52 "OpenAI-Beta": "assistants=v2",
58
59 // Add the query
60 await fetch(`https://api.openai.com/v1/threads/${thread.id}/messages`, {
61 method: "POST",
62 headers: {
63 "Authorization": `Bearer ${OPENAI_API_KEY}`,
64 "Content-Type": "application/json",
65 "OpenAI-Beta": "assistants=v2",
72
73 // Run the parser assistant
74 const runResponse = await fetch(`https://api.openai.com/v1/threads/${thread.id}/runs`, {
75 method: "POST",
76 headers: {
77 "Authorization": `Bearer ${OPENAI_API_KEY}`,
78 "Content-Type": "application/json",
79 "OpenAI-Beta": "assistants=v2",
100
101 const statusResponse = await fetch(
102 `https://api.openai.com/v1/threads/${thread.id}/runs/${run.id}`,
103 {
104 headers: {
105 "Authorization": `Bearer ${OPENAI_API_KEY}`,
106 "OpenAI-Beta": "assistants=v2",
107 },
114 // Get the response
115 const messagesResponse = await fetch(
116 `https://api.openai.com/v1/threads/${thread.id}/messages?order=desc&limit=1`,
117 {
118 headers: {
119 "Authorization": `Bearer ${OPENAI_API_KEY}`,
120 "OpenAI-Beta": "assistants=v2",
121 },
414 }
415
416 const OPENAI_API_KEY = Deno.env.get("OPENAI_API_KEY");
417 if (!OPENAI_API_KEY) {
418 throw new Error("OPENAI_API_KEY not found in environment variables");
419 }
420
423 }
424
425 // IMPORTANT: All OpenAI API calls use these headers with assistants=v2
426 const baseHeaders = {
427 "Authorization": `Bearer ${OPENAI_API_KEY}`,
428 "Content-Type": "application/json",
429 "OpenAI-Beta": "assistants=v2",
466 let thread;
467 if (threadId) {
468 const threadResponse = await fetch(`https://api.openai.com/v1/threads/${threadId}`, {
469 headers: baseHeaders,
470 });
474 thread = await threadResponse.json();
475 } else {
476 const threadResponse = await fetch("https://api.openai.com/v1/threads", {
477 method: "POST",
478 headers: baseHeaders,
499
500 // Add message to thread with v2 headers
501 const messageResponse = await fetch(`https://api.openai.com/v1/threads/${thread.id}/messages`, {
502 method: "POST",
503 headers: baseHeaders,
513
514 // Run the assistant with v2 headers
515 const runResponse = await fetch(`https://api.openai.com/v1/threads/${thread.id}/runs`, {
516 method: "POST",
517 headers: baseHeaders,
652 });
653
654 result.all_maps.forEach(mapId => {
655 if (mapId && !autoDisplayMedia.find(m => m.id === mapId)) {
656 autoDisplayMedia.push({
657 id: mapId,
658 type: "map",
659 title: MEDIA_TITLES[mapId] || `Map ${mapId}`,
660 article_id: result.article_id,
661 relevance: `From: ${result.title.substring(0, 50)}... (${result.date})`,
748
749 const statusResponse = await fetch(
750 `https://api.openai.com/v1/threads/${thread.id}/runs/${run.id}`,
751 { headers: baseHeaders },
752 );
777 // Submit tool outputs with v2 headers
778 const toolOutputResponse = await fetch(
779 `https://api.openai.com/v1/threads/${thread.id}/runs/${run.id}/submit_tool_outputs`,
780 {
781 method: "POST",
801 // Get the assistant's response with v2 headers
802 const messagesResponse = await fetch(
803 `https://api.openai.com/v1/threads/${thread.id}/messages?order=desc&limit=20`,
804 { headers: baseHeaders },
805 );

EnuguRentHome.tsx3 matches

@godinoarts•Updated 1 hour ago
33 }
34
35 // Fetch data from API
36 const [featuredResponse, recentResponse] = await Promise.all([
37 fetch('/api/listings/featured?limit=6'),
38 fetch('/api/listings?limit=8')
39 ]);
40
rapilot330
Kapil01