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/image-url.jpg%20%22Image%20title%22?q=api&page=1019&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 14362 results for "api"(1058ms)

vitalCoralWormmain.tsx1 match

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

niceCyanHummingbirdmain.tsx1 match

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

forwardermain.tsx1 match

@debbie•Updated 6 months ago
189 <head>
190 <title>Val Email Generator</title>
191 <link href="https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700&display=swap" rel="stylesheet">
192 <meta name="viewport" content="width=device-width, initial-scale=1">
193 <style>${css}</style>

transcendentTanToucanmain.tsx1 match

@temptemp•Updated 6 months ago
59async function relay() {
60 const reqDev = await fetch(
61 `https://devtools.devprod.cloudflare.dev/js_app?wss=%2Fplayground.devprod.cloudflare.dev%2Fapi%2Finspector%3Fuser%3Db540c24b3817eaad0241a2baffdd493229c279357c134cd0a1ade2388c398b7d%26h%3D87502d4ecedde10987fee740e6c9ae116ea74e13a6cb62c6efc24237ec337d2b&theme=systemPreferred&domain=workers+playground`,
62 {},
63 );

celestialBeigeDovemain.tsx1 match

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

prosperousMaroonSpidermain.tsx1 match

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

sapientLavenderHerringmain.tsx2 matches

@maxm•Updated 6 months ago
12 <script>hljs.highlightAll();</script>
13 <style>
14 @import url('https://fonts.googleapis.com/css2?family=Kumbh+Sans:wght@900&family=Roboto+Mono:wght@400;700&display=swap');
15
16 * {
119import { Wide } from 'http://esm.town/v/maxm/wide';
120
121// Use your Val Town API Token to create a session
122const wide = new Wide(await ValSession.new(Deno.env.get("valtown")))
123

sapientLavenderHerringREADME.md1 match

@maxm•Updated 6 months ago
8import { Wide } from 'http://esm.town/v/maxm/wide';
9
10// Use your Val Town API Token to create a session
11const wide = new Wide(await ValSession.new(Deno.env.get("valtown")))
12

imggenpromain.tsx24 matches

@andiebuk•Updated 6 months ago
117
118 if (Math.abs(originalAspectRatio - adjustedAspectRatio) > ASPECT_RATIO_TOLERANCE) {
119 warnings.push(`Original aspect ratio (${originalAspectRatio.toFixed(2)}) adjusted to match API constraints.`);
120 }
121
122 // Add specific warnings
123 if (safeWidth !== adjustedWidth) {
124 warnings.push(`Width adjusted from ${safeWidth} to ${adjustedWidth} to meet API requirements.`);
125 }
126 if (safeHeight !== adjustedHeight) {
127 warnings.push(`Height adjusted from ${safeHeight} to ${adjustedHeight} to meet API requirements.`);
128 }
129
151
152 if (url.pathname === "/generate" && request.method === "POST") {
153 const apiKey = Deno.env.get("TOGETHER_API_KEY");
154 if (!apiKey) {
155 console.error("API key not found in environment variables");
156 return new Response(JSON.stringify({ error: "API key not found" }), {
157 status: 500,
158 headers: { "Content-Type": "application/json" },
164 console.log("Received prompt:", prompt);
165
166 const togetherApiUrl = "https://api.together.xyz/v1/images/generations";
167 console.log("Sending request to Together AI API:", togetherApiUrl);
168
169 const response = await fetch(togetherApiUrl, {
170 method: "POST",
171 headers: {
172 "Content-Type": "application/json",
173 "Authorization": `Bearer ${apiKey}`,
174 },
175 body: JSON.stringify({
183 });
184
185 console.log("Together AI API response status:", response.status);
186
187 if (!response.ok) {
188 const errorText = await response.text();
189 console.error("Together AI API error:", errorText);
190 throw new Error(`API request failed with status ${response.status}: ${errorText}`);
191 }
192
193 const result = await response.json();
194 console.log("Together AI API full response:", JSON.stringify(result, null, 2));
195
196 // Robust extraction of base64 image data
204 } else {
205 console.error("Unexpected response structure:", result);
206 throw new Error("No image found in API response");
207 }
208
231 // Handle direct image generation from URL query
232 if (imagePrompt) {
233 const apiKey = Deno.env.get("TOGETHER_API_KEY");
234 if (!apiKey) {
235 return new Response("API key not found", { status: 500 });
236 }
237
238 try {
239 const togetherApiUrl = "https://api.together.xyz/v1/images/generations";
240 const response = await fetch(togetherApiUrl, {
241 method: "POST",
242 headers: {
243 "Content-Type": "application/json",
244 "Authorization": `Bearer ${apiKey}`,
245 },
246 body: JSON.stringify({
256 if (!response.ok) {
257 const errorText = await response.text();
258 throw new Error(`API request failed with status ${response.status}: ${errorText}`);
259 }
260
268 imageBase64 = result.data.b64_json;
269 } else {
270 throw new Error("No image found in API response");
271 }
272

imggenproREADME.md2 matches

@andiebuk•Updated 6 months ago
5 https://your-val.val.run?image=a%20beautiful%20sunset&width=4096&height=4096 (will cap at 2048x2048)
6
7This uses together.ai api and generates the image using the black-forest-labs/FLUX.1-schnell model which is very fast.
8
9You will need to set the environment var TOGETHER_API_KEY to your key.
10
11I built this entirely with Townie AI and most of it was done with the Claude 3.5 Haiku which I find for most projects get things right faster than sonnet.

createemailapiv22 file matches

@souravvmishra•Updated 7 hours ago

waec_api6 file matches

@seyistry•Updated 14 hours ago
snartapi
mux
Your friendly, neighborhood video API.