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//%22$%7BvalTownUrl%7D/%22?q=api&page=1&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 25502 results for "api"(1046ms)

manifoldHttpmain.ts19 matches

@dcm31•Updated 37 mins ago
6 const [url, setUrl] = useState("");
7 const [result, setResult] = useState<any>(null);
8 const [apiKey, setApiKey] = useState("");
9 const [betAmount, setBetAmount] = useState(0);
10 const [status, setStatus] = useState<string | null>(null);
11
12 useEffect(() => {
13 const storedKey = localStorage.getItem("manifoldApiKey");
14 if (storedKey) setApiKey(storedKey);
15 }, []);
16
17 function saveKey() {
18 localStorage.setItem("manifoldApiKey", apiKey);
19 alert("API key saved locally");
20 }
21
33
34 async function handleBetAll() {
35 if (!result || !apiKey || betAmount <= 0) return;
36 setStatus("Placing bets...");
37
41 body: JSON.stringify({
42 url,
43 apiKey,
44 amount: betAmount
45 })
55
56 <div className="mb-4">
57 <h2 className="font-semibold mb-2">API Key</h2>
58 <input
59 type="password"
60 value={apiKey}
61 onChange={(e) => setApiKey(e.target.value)}
62 placeholder="Enter Manifold API key"
63 className="border p-2 rounded w-full mb-2"
64 />
132 const slug = parts.pop() || parts.pop();
133
134 const apiUrl = `https://manifold.markets/api/v0/slug/${slug}`;
135 const res = await fetch(apiUrl);
136 if (!res.ok) return new Response(`Failed to fetch market: ${res.statusText}`, { status: 500 });
137
150
151 if (pathname === "/betAll" && req.method === "POST") {
152 const { url, apiKey, amount } = await req.json();
153 if (!url || !apiKey || !amount) return new Response("Missing parameters", { status: 400 });
154
155 const parts = url.split("/");
156 const slug = parts.pop() || parts.pop();
157
158 const apiUrl = `https://manifold.markets/api/v0/slug/${slug}`;
159 const res = await fetch(apiUrl);
160 if (!res.ok) return new Response(`Failed to fetch market: ${res.statusText}`, { status: 500 });
161
167 const results: any[] = [];
168 for (const ans of data.answers) {
169 const betRes = await fetch("https://manifold.markets/api/v0/bet", {
170 method: "POST",
171 headers: {
172 "content-type": "application/json",
173 "Authorization": `Key ${apiKey}`,
174 },
175 body: JSON.stringify({

manifoldSummain.ts2 matches

@dcm31•Updated 45 mins ago
4 const slug = parts.pop() || parts.pop(); // handle trailing slash
5
6 const apiUrl = `https://manifold.markets/api/v0/slug/${slug}`;
7 const res = await fetch(apiUrl);
8 if (!res.ok) throw new Error(`Failed to fetch market: ${res.statusText}`);
9 const data = await res.json();

gatemain.ts2 matches

@know•Updated 1 hour ago
185 <meta name="viewport" content="width=device-width, initial-scale=1.0">
186 <title>Principia</title>
187 <link rel="preconnect" href="https://fonts.googleapis.com">
188 <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
189 <link href="https://fonts.googleapis.com/css2?family=Merriweather:wght@300;400;700&family=Roboto+Mono:wght@300;400&display=swap" rel="stylesheet">
190 <style>
191 :root {

h6-val-summary.ts3 matches

@werewolf006•Updated 1 hour ago
18 SUM(num_images) as total_images
19 FROM ${USAGE_TABLE}
20 WHERE val_id = ? AND our_api_token = 1
21 GROUP BY val_id
22 `, [valId]);
34 FROM ${INFERENCE_CALLS_TABLE} i
35 JOIN ${USAGE_TABLE} u ON i.usage_id = u.id
36 WHERE u.val_id = ? AND u.our_api_token = 1
37 GROUP BY u.val_id
38 `, [valId]);
41 const requestsResult = await sqlite.execute(`
42 SELECT * FROM ${USAGE_TABLE}
43 WHERE val_id = ? AND our_api_token = 1
44 ORDER BY timestamp DESC
45 `, [valId]);

h6-val-detail.ts1 match

@werewolf006•Updated 1 hour ago
18 finish_reason?: string;
19 num_images?: number;
20 our_api_token: boolean;
21}
22

h6-useUser.tsx1 match

@werewolf006•Updated 1 hour ago
1import { useState, useEffect } from "react";
2
3const USER_ENDPOINT = "/api/user";
4
5export function useUser() {

h6-user-summary.ts2 matches

@werewolf006•Updated 1 hour ago
20 SUM(num_images) as total_images
21 FROM ${USAGE_TABLE}
22 WHERE our_api_token = 1
23 `;
24
41 FROM ${INFERENCE_CALLS_TABLE} i
42 JOIN ${USAGE_TABLE} u ON i.usage_id = u.id
43 WHERE u.our_api_token = 1
44 `;
45

h6-user-detail.ts2 matches

@werewolf006•Updated 1 hour ago
1import { renderLayout } from "./layout.ts";
2import { formatNumber, formatPrice, formatDate, formatBoolean } from "../utils/formatters.ts";
3import { CreditAddition } from "../api/credit-additions.ts";
4
5interface UserSummaryRow {
33 finish_reason?: string;
34 num_images?: number;
35 our_api_token: boolean;
36}
37

h6-useProject.tsx2 matches

@werewolf006•Updated 1 hour ago
1import { useState, useEffect } from "react";
2
3const PROJECT_ENDPOINT = "/api/project";
4const FILES_ENDPOINT = "/api/project-files";
5
6export function useProject(projectId: string, branchId?: string) {

h6-useProjects.tsx1 match

@werewolf006•Updated 1 hour ago
1import { useState, useEffect } from "react";
2
3const ENDPOINT = "/api/projects-loader";
4
5export function useProjects() {

PixelPixelApiMonitor1 file match

@selfire1•Updated 12 hours ago
Regularly polls the API and messages on an error.

weatherApp1 file match

@dcm31•Updated 19 hours ago
A simple weather app with dropdown cities using Open-Meteo API
fapian
<("<) <(")> (>")>
Kapil01