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=625&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 11992 results for "api"(1434ms)

resyBotREADME.md1 match

@nofreesamples•Updated 3 months ago
9```ts
10const resyBotCron = async () => {
11 const bookingInfo = await api(@vtdocs.resyBot, {
12 slug: 'amaro-bar',
13 city: 'ldn',

API_URLmain.tsx4 matches

@awhitter•Updated 3 months ago
119 try {
120 // Load secrets from Val Town
121 const airtableApiKey = await val.secrets.AIRTABLE_API_KEY;
122 const airtableBaseId = await val.secrets.AIRTABLE_BASE_ID;
123 const airtableTableId = await val.secrets.AIRTABLE_TABLE_ID;
128
129 do {
130 const url = new URL(`https://api.airtable.com/v0/${airtableBaseId}/${airtableTableId}`);
131 if (offset) {
132 url.searchParams.set('offset', offset);
135 const airtableResp = await fetch(url.toString(), {
136 headers: {
137 Authorization: `Bearer ${airtableApiKey}`,
138 'Content-Type': 'application/json',
139 },
141
142 if (!airtableResp.ok) {
143 throw new Error(`Airtable API error: ${airtableResp.statusText}`);
144 }
145

contentTemplateAppmain.tsx14 matches

@awhitter•Updated 3 months ago
58 const fetchContent = async () => {
59 try {
60 const response = await fetch("/api/content");
61 const data = await response.json();
62 if (data.records) {
99 const analyzeContent = async (item: AirtableRecord) => {
100 try {
101 const response = await fetch("/api/analyze", {
102 method: "POST",
103 headers: {
240 const url = new URL(req.url);
241
242 if (url.pathname === "/api/content") {
243 const apiToken = "patXZjAXzGvcAyCcv.f35f12a672442df9c98a9a30f081dc21aa56b072addc93f4c53bc389fb22defd";
244 const baseId = "appe6CB5XnPgGVQHw";
245 const tableId = "tblldKWyq3kppzUoP";
246
247 const airtableUrl = `https://api.airtable.com/v0/${baseId}/${tableId}`;
248
249 const headers = new Headers({
250 'Authorization': `Bearer ${apiToken}`,
251 'Content-Type': 'application/json',
252 'Access-Control-Allow-Origin': '*',
262 const response = await fetch(airtableUrl, {
263 headers: {
264 'Authorization': `Bearer ${apiToken}`,
265 'Content-Type': 'application/json',
266 },
280 });
281 }
282 } else if (url.pathname === "/api/analyze") {
283 if (req.method === 'POST') {
284 const { OpenAI } = await import("https://esm.town/v/std/openai");
366*/
367
368// Example 2: Making an API call to /api/content endpoint
369/*
370async function fetchContent() {
371 try {
372 const response = await fetch('https://awhitter-contenttemplateapp.web.val.run/api/content');
373 const data = await response.json();
374 console.log('Content:', data);
4202. Add an HTTP module as the first step
4213. Configure the HTTP module as follows:
422 - URL: https://awhitter-contenttemplateapp.web.val.run/api/content
423 - Method: GET
424 - Headers: None required
4254. In the next module, you can process the JSON response from the API
426 The response will contain an array of records with the content from Airtable
427*/
433import { Data, animate, Override, Animatable } from "framer"
434
435// This function fetches the content from the API
436async function fetchContent() {
437 try {
438 const response = await fetch('https://awhitter-contenttemplateapp.web.val.run/api/content')
439 const data = await response.json()
440 return data.records

aimain.tsx12 matches

@goode_bye•Updated 3 months ago
29
30const anthropic = createAnthropic({
31 // apiKey = Deno.env.get("ANTHROPIC_API_KEY");
32 apiKey: Deno.env.get("ANTHROPIC_API_KEY_COVERSHEET"),
33});
34
35const openai = createOpenAI({
36 // apiKey = Deno.env.get("OPENAI_API_KEY");
37 apiKey: Deno.env.get("OPENAI_API_KEY_COVERSHEET"),
38});
39
40const groq = createOpenAI({
41 baseURL: "https://api.groq.com/openai/v1",
42 apiKey: Deno.env.get("GROQ_API_KEY"),
43});
44
45const perplexity = createOpenAI({
46 apiKey: Deno.env.get("PERPLEXITY_API_KEY") ?? "",
47 baseURL: "https://api.perplexity.ai/",
48});
49
50const googleProvider = createGoogleGenerativeAI({
51 apiKey: Deno.env.get("GOOGLE_GENERATIVE_AI_API_KEY"),
52});
53
300 if (toolResults && toolResults.length > 0) {
301 // we have to do this bc the AI SDK doesn't seem to let you carry over function calling results,
302 // so we pretend to be the user instead of using the official role: tool API, which breaks everything
303 for (const toolResult of toolResults) {
304 options.messages.push({
619 return c.json(response);
620 } catch (error) {
621 console.error("API error:", error);
622 return c.text("Error occurred.", 500);
623 }
665 return c.json(response);
666 } catch (error) {
667 console.error("API error:", error);
668 return c.text("Error occurred.", 500);
669 }

API_URLREADME.md4 matches

@awhitter•Updated 3 months ago
1# Val Town API URL
2
3When Val Town code is run on Val Town servers we use a local URL so we can save time by skipping a roundtrip to the public internet. However, if you want to run your vals that use our API, ie std library vals, locally, you'll want to use our public API's URL, `https://api.val.town`. We recommend importing and using `std/API_URL` whenever you use our API so that you are always using the most efficient route.
4
5## Example Usage
6
7```ts
8import { API_URL } from "https://esm.town/v/std/API_URL";
9
10const response = await fetch(`${API_URL}/v1/me`, {
11 headers: {
12 Authorization: `Bearer ${Deno.env.get("valtown")}`,

sqlitemain.tsx3 matches

@awhitter•Updated 3 months ago
1import { API_URL } from "https://esm.town/v/std/API_URL";
2import { LibsqlError, type TransactionMode } from "npm:@libsql/client";
3import { z } from "npm:zod";
35
36async function execute(statement: InStatement): Promise<ResultSet> {
37 const res = await fetch(`${API_URL}/v1/sqlite/execute`, {
38 method: "POST",
39 headers: {
49
50async function batch(statements: InStatement[], mode?: TransactionMode): Promise<ResultSet[]> {
51 const res = await fetch(`${API_URL}/v1/sqlite/batch`, {
52 method: "POST",
53 headers: {

cerebras_coderREADME.md2 matches

@awhitter•Updated 3 months ago
6
71. Sign up for [Cerebras](https://cloud.cerebras.ai/)
82. Get a Cerebras API Key
93. Save it in a [Val Town environment variable](https://www.val.town/settings/environment-variables) called `CEREBRAS_API_KEY`

cerebras_codermain.tsx5 matches

@awhitter•Updated 3 months ago
212 } catch (error) {
213 Toastify({
214 text: "We may have hit our Cerebras Usage limits. Try again later or fork this and use your own API key.",
215 position: "center",
216 duration: 3000,
1024 };
1025 } else {
1026 const client = new Cerebras({ apiKey: Deno.env.get("CEREBRAS_API_KEY") });
1027 const completion = await client.chat.completions.create({
1028 messages: [
1149 <meta name="viewport" content="width=device-width, initial-scale=1.0">
1150 <title>CerebrasCoder</title>
1151 <link rel="preconnect" href="https://fonts.googleapis.com" />
1152 <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
1153 <link
1154 href="https://fonts.googleapis.com/css2?family=DM+Mono:ital,wght@0,300;0,400;0,500;1,300;1,400;1,500&family=DM+Sans:ital,opsz,wght@0,9..40,100..1000;1,9..40,100..1000&display=swap"
1155 rel="stylesheet"
1156 />
1165 <meta property="og:description" content="Turn your ideas into fully functional apps in less than a second – powered by Llama3.3-70b on Cerebras's super-fast wafer chips. Code is 100% open-source, hosted on Val Town."">
1166 <meta property="og:type" content="website">
1167 <meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">
1168
1169

alluringCoralParrotREADME.md2 matches

@bhawna14•Updated 3 months ago
6
71. Sign up for [Cerebras](https://cloud.cerebras.ai/)
82. Get a Cerebras API Key
93. Save it in a [Val Town environment variable](https://www.val.town/settings/environment-variables) called `CEREBRAS_API_KEY`
10
11# Todos

alluringCoralParrotmain.tsx4 matches

@bhawna14•Updated 3 months ago
212 } catch (error) {
213 Toastify({
214 text: "We may have hit our Cerebras Usage limits. Try again later or fork this and use your own API key.",
215 position: "center",
216 duration: 3000,
1024 };
1025 } else {
1026 const client = new Cerebras({ apiKey: Deno.env.get("CEREBRAS_API_KEY") });
1027 const completion = await client.chat.completions.create({
1028 messages: [
1148 <meta name="viewport" content="width=device-width, initial-scale=1.0">
1149 <title>CerebrasCoder</title>
1150 <link rel="preconnect" href="https://fonts.googleapis.com" />
1151 <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
1152 <link
1153 href="https://fonts.googleapis.com/css2?family=DM+Mono:ital,wght@0,300;0,400;0,500;1,300;1,400;1,500&family=DM+Sans:ital,opsz,wght@0,9..40,100..1000;1,9..40,100..1000&display=swap"
1154 rel="stylesheet"
1155 />

social_data_api_project3 file matches

@tsuchi_ya•Updated 16 hours ago

simple-scrabble-api1 file match

@bry•Updated 3 days ago
apiv1
papimark21