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/$1?q=api&page=50&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 18312 results for "api"(1629ms)

markdown-embeddemoCache.ts1 match

@stevekrouseUpdated 3 days ago
5// Initialize Notion client
6const notion = new Client({
7 auth: Deno.env.get("NOTION_API_KEY"),
8});
9

markdown-embed.cursorrules10 matches

@stevekrouseUpdated 3 days ago
13- Generate code in TypeScript or TSX
14- Add appropriate TypeScript types and interfaces for all data structures
15- Prefer official SDKs or libraries than writing API calls directly
16- Ask the user to supply API or library documentation if you are at all unsure about it
17- **Never bake in secrets into the code** - always use environment variables
18- Include comments explaining complex logic (avoid commenting obvious operations)
23### 1. HTTP Trigger
24
25- Create web APIs and endpoints
26- Handle HTTP requests and responses
27- Example structure:
173However, it's *extremely importing* to note that `parseProject` and other Standard Library utilities ONLY RUN ON THE SERVER.
174If you need access to this data on the client, run it in the server and pass it to the client by splicing it into the HTML page
175or by making an API request for it.
176
177## Val Town Platform Specifics
181- **AI Image:** To inline generate an AI image use: `<img src="https://maxm-imggenurl.web.val.run/the-description-of-your-image" />`
182- **Storage:** DO NOT use the Deno KV module for storage
183- **Browser APIs:** DO NOT use the `alert()`, `prompt()`, or `confirm()` methods
184- **Weather Data:** Use open-meteo for weather data (doesn't require API keys) unless otherwise specified
185- **View Source:** Add a view source link by importing & using `import.meta.url.replace("ems.sh", "val.town)"` (or passing this data to the client) and include `target="_top"` attribute
186- **Error Debugging:** Add `<script src="https://esm.town/v/std/catch"></script>` to HTML to capture client-side errors
187- **Error Handling:** Only use try...catch when there's a clear local resolution; Avoid catches that merely log or return 500s. Let errors bubble up with full context
188- **Environment Variables:** Use `Deno.env.get('keyname')` when you need to, but generally prefer APIs that don't require keys
189- **Imports:** Use `https://esm.sh` for npm and Deno dependencies to ensure compatibility on server and browser
190- **Storage Strategy:** Only use backend storage if explicitly required; prefer simple static client-side sites
224### Backend (Hono) Best Practices
225
226- Hono is the recommended API framework
227- Main entry point should be `backend/index.ts`
228- **Static asset serving:** Use the utility functions to read and serve project files:
248 });
249 ```
250- Create RESTful API routes for CRUD operations
251- Always include this snippet at the top-level Hono app to re-throwing errors to see full stack traces:
252 ```ts
285 - For files in the project, use `readFile` helpers
286
2875. **API Design:**
288 - `fetch` handler is the entry point for HTTP vals
289 - Run the Hono app with `export default app.fetch // This is the entry point for HTTP vals`

markdown-embedchess.tsx3 matches

@stevekrouseUpdated 3 days ago
10 // src="https://glance--90537b2ecab54268bf831875fe1d0158.web.val.run"
11 // src="https://lightweight--ef4179e03fc011f0bc0c76b3cceeab13.web.val.run"
12 // src="/api/iframe"
13 // src={`/api/${content}`}
14 // src={`/api/${content}?user=${userId}`}
15 src={contentURL}
16 title={`Glance content: ${content}`}

markdown-embedauth.ts4 matches

@stevekrouseUpdated 3 days ago
1export default async (c, next) => {
2 const method = c.req.method;
3 const secret = c.req.header("x-api-key"); // sent by Notion webhooks via POST
4 const fetchSite = c.req.header("sec-fetch-site");
5
6 // POSTs from Notion are automation webhooks that carry the x-api-key custom header
7 // that header needs to match the X_API_KEY environment variable in this project
8 // or this auth check won't pass
9 // for now we can just let GETs through without any auth shim
10 if (
11 (secret && secret !== Deno.env.get("X_API_KEY") || fetchSite && fetchSite !== "same-origin") && method !== "GET"
12 ) {
13 console.log(fetchSite);

markdown-embedApp.tsx5 matches

@stevekrouseUpdated 3 days ago
1/** @jsxImportSource https://esm.sh/react@18.2.0 */
2import { useEffect, useState } from "https://esm.sh/react@18.2.0";
3import { DemoData, isApiError, isNotionPage } from "../index.tsx";
4import { CheckoutContent } from "./content/checkout/checkout.tsx";
5import { FormContent } from "./content/form/form.tsx";
60 if (!demoData) return <div>No demo data available</div>;
61
62 // Handle error responses from the API
63 if (isApiError(demoData)) {
64 return (
65 <div>
66 <h3>API Response:</h3>
67 <p>
68 <strong>Status:</strong> {demoData.status}
168 href={`#${page.properties.Name.title[0].plain_text}`}
169 className={
170 `${currentHash === page.properties.Name.title[0].plain_text ? 'active' : ''} capitalize`
171 }
172 onClick={() => {

markdown-embedapi.ts0 matches

@stevekrouseUpdated 3 days ago
1import { Hono } from "npm:hono";
2
3// Import route modules
4import cobrowse from "./cobrowse.ts";
5import database from "./database.ts";

osverify10 matches

@dinavinterUpdated 3 days ago
2
3const GIGYA_DOMAIN = process.env.GIGYA_DOMAIN || "accounts.eu1.gigya.com";
4const GIGYA_API_KEY = process.env.GIGYA_API_KEY;
5const GIGYA_APP_KEY = process.env.GIGYA_APP_KEY;
6const GIGYA_APP_SECRET = process.env.GIGYA_APP_SECRET;
7
8if (!GIGYA_API_KEY || !GIGYA_APP_KEY || !GIGYA_APP_SECRET) {
9 console.error("Missing Gigya environment variables!");
10 console.log("Required variables: GIGYA_API_KEY, GIGYA_APP_KEY, GIGYA_APP_SECRET");
11 process.exit(1);
12}
16
17 const body = new URLSearchParams({
18 apiKey: GIGYA_API_KEY,
19 userKey: GIGYA_APP_KEY,
20 secret: GIGYA_APP_SECRET,
123 }
124
125 // 5. Test connection to accounts API
126 console.log("\n5. Testing accounts API connection...");
127 try {
128 const testResponse = await makeGigyaRequest("accounts.getAccountInfo", {
130 });
131
132 // We expect this to fail with "user not found" which means the API is working
133 if (testResponse.errorCode === 403005) {
134 console.log("✅ Accounts API connection working (user not found as expected)");
135 } else {
136 console.log(`⚠️ Unexpected accounts API response: ${testResponse.errorMessage}`);
137 }
138 } catch (error) {
139 console.log("❌ Accounts API connection failed:", error.message);
140 }
141

osds-schema.ts4 matches

@dinavinterUpdated 3 days ago
2
3const GIGYA_DOMAIN = process.env.GIGYA_DOMAIN || "accounts.eu1.gigya.com";
4const GIGYA_API_KEY = process.env.GIGYA_API_KEY;
5const GIGYA_APP_KEY = process.env.GIGYA_APP_KEY;
6const GIGYA_APP_SECRET = process.env.GIGYA_APP_SECRET;
7
8if (!GIGYA_API_KEY || !GIGYA_APP_KEY || !GIGYA_APP_SECRET) {
9 console.error("Missing Gigya environment variables!");
10 console.log("Required variables: GIGYA_API_KEY, GIGYA_APP_KEY, GIGYA_APP_SECRET");
11 process.exit(1);
12}
16
17 const body = new URLSearchParams({
18 apiKey: GIGYA_API_KEY,
19 userKey: GIGYA_APP_KEY,
20 secret: GIGYA_APP_SECRET,

FarcasterSpacesSpace.tsx2 matches

@moeUpdated 3 days ago
139
140 const queryFn = () =>
141 fetch(`/api/channels`)
142 .then((r) => r.json())
143 .then((r) => r?.data?.channels?.find((c) => c.channel_name == channel))
146
147 const join = async () => {
148 const response = await fetch(`/api/token?channel=${channel}&uid=${uid}`).then((r) => r.json())
149 console.log('response', response)
150 setToken(response.token)

utilsREADME.md1 match

@stdUpdated 3 days ago
1# Val Town Project Utilities
2
3These utils are very rapidly developing, so expect breaking changes.
4
5* file - reading files and directories in Projects

Galacta3 file matches

@defunktUpdated 33 mins ago
Marvel Rivals GPT via tracker.gg API

github-api1 file match

@cricks_unmixed4uUpdated 1 day ago
apiry
snartapi