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=949&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 21176 results for "api"(7646ms)

16 }
17
18 const url = `https://discord.com/api/v10${endpoint}`;
19 const headers = {
20 "Authorization": `Bot ${token}`,
34
35 if (!response.ok) {
36 console.error(`❌ Discord API error: ${response.status}`);
37 throw new Error(`Discord API error: ${response.status}`);
38 }
39

iClickWolfHomePage.tsx4 matches

@wolfUpdated 2 months ago
11}
12
13// Default item to use if API fails
14const DEFAULT_ITEM: Item = {
15 id: 1,
29 async function fetchItem() {
30 try {
31 const response = await fetch("/api/items");
32 if (response.ok) {
33 const data = await response.json();
34 setItem(data);
35 } else {
36 // If API fails, use default item
37 console.warn("Using default item data because API returned an error");
38 setItem(DEFAULT_ITEM);
39

iClickWolfREADME.md10 matches

@wolfUpdated 2 months ago
7
8- **Backend**: `/backend/index.ts` - The main HTTP server that serves the
9 frontend and API endpoints
10 - `/backend/database/` - Contains SQLite database setup and queries
11 - `/backend/routes/` - API routes for checkout, webhook, and items
12
13- **Frontend**: `/frontend/index.html` - The main HTML entry point
26The following environment variables are required:
27
28- `STRIPE_SECRET` - Stripe API secret key
29- `STRIPE_PUBLIC` - Stripe publishable key (for frontend)
30- `STRIPE_WEBHOOK_SECRET` - Secret for verifying Stripe webhook events
31- `VAL_EMAIL_KEY` - API key for the email sending service
32
33## Error Handling
35The application includes robust error handling:
36
37- If Stripe is not configured (missing API keys), appropriate error messages are
38 shown
39- If the database fails to load items, default values are used as a fallback
40- All API errors are properly logged and user-friendly messages are displayed
41- Form validation prevents submission of invalid data
42
48- `iclickwolf_preorders_v1` - Stores customer preorder information
49
50## API Endpoints
51
52- `POST /api/checkout` - Creates a Stripe checkout session and preorder
53- `POST /api/webhook` - Handles Stripe webhook events
54- `GET /api/items` - Returns the first item (iClicker)
55

iClickWolfPurchasePage.tsx1 match

@wolfUpdated 2 months ago
34
35 try {
36 const response = await fetch("/api/checkout", {
37 method: "POST",
38 headers: {

iClickWolfindex.ts5 matches

@wolfUpdated 2 months ago
24}
25
26// API routes
27app.route("/api/checkout", checkoutRoutes);
28app.route("/api/webhook", webhookRoutes);
29app.route("/api/items", itemsRoutes);
30
31// Serve frontend files
32app.get("/frontend/*", (c) => serveFile(c.req.path, import.meta.url));
33
34// Handle SPA routes - serve index.html for all non-API, non-asset routes
35const serveIndex = async (c: any) => {
36 try {

iClickWolfcheckout.ts2 matches

@wolfUpdated 2 months ago
4const app = new Hono();
5
6// Initialize Stripe only if the API key is available
7let stripe: any = null;
8const stripeKey = Deno.env.get("STRIPE_SECRET");
12 const { Stripe } = await import("npm:stripe");
13 stripe = new Stripe(stripeKey, {
14 apiVersion: "2025-04-30.basil",
15 });
16 } catch (error) {

iClickWolfwebhook.ts5 matches

@wolfUpdated 2 months ago
8const app = new Hono();
9
10// Initialize Stripe only if the API key is available
11let stripe: any = null;
12const stripeKey = Deno.env.get("STRIPE_SECRET");
16 const { Stripe } = await import("npm:stripe");
17 stripe = new Stripe(stripeKey, {
18 apiVersion: "2025-04-30.basil",
19 });
20 } catch (error) {
31 html?: string;
32}) {
33 const emailSenderApiUrl = "https://wolf-emailsender.web.val.run/";
34 const emailKey = Deno.env.get("VAL_EMAIL_KEY");
35
36 if (!emailKey) {
37 console.error("Email API key not configured");
38 throw new Error("Email service is not configured");
39 }
40
41 const response = await fetch(emailSenderApiUrl, {
42 method: "POST",
43 headers: {
1// discord-rate-limit-service.ts - Advanced rate limiting for Discord API with
2// exponential backoff, circuit breaker, global rate limit handling, and blob persistence
3
14}
15
16// API call tracking for global rate limits
17interface ApiCallRecord {
18 timestamp: number;
19}
33 private static instance: DiscordRateLimitService;
34 private rateLimitBuckets: Map<string, RateLimitInfo> = new Map();
35 private apiCallTimes: ApiCallRecord[] = [];
36 private globalLock: boolean = false;
37
217 console.log(`⚡ Circuit breaker open, blocking requests for ${waitTime} more seconds`);
218 throw new Error(
219 `Circuit breaker open. API requests blocked for ${waitTime} more seconds due to too many failures.`,
220 );
221 }
263 }
264
265 // Main method to execute API calls with rate limiting
266 public async executeWithRateLimit<T>(
267 routeKey: string,
289 await this.ensureDynamicRateLimitCompliance(routeKey);
290
291 // Execute the actual API call
292 const result = await action();
293
401 // Check for Discord's global rate limit message
402 if (error.message && typeof error.message === "string") {
403 if (error.message.includes("You are being blocked from accessing our API temporarily")) {
404 // Set a longer global rate limit time (e.g., 10 minutes)
405 this.globalRateLimitUntil = Date.now() + 10 * 60 * 1000;
567
568 // Also track for global rate limiting
569 this.trackApiCall();
570 }
571
572 // Track an API call for global rate limiting
573 private trackApiCall(): void {
574 const now = Date.now();
575 this.apiCallTimes.push({ timestamp: now });
576
577 // Clean up old records
578 this.apiCallTimes = this.apiCallTimes.filter(call => now - call.timestamp <= this.RATE_LIMIT_WINDOW_MS);
579 }
580
651
652 // Clean up old records
653 this.apiCallTimes = this.apiCallTimes.filter(call => now - call.timestamp <= this.RATE_LIMIT_WINDOW_MS);
654
655 // If we have capacity, return immediately
656 if (this.apiCallTimes.length < this.RATE_LIMIT_PER_SECOND) {
657 return;
658 }
659
660 // Calculate how long to wait before making another request
661 if (this.apiCallTimes.length > 0) {
662 // Get the oldest API call in our window
663 const oldestCall = this.apiCallTimes[0];
664
665 // Calculate when that call will expire from our window
luciaMagicLinkStarter

luciaMagicLinkStarterindex.ts2 matches

@stevekrouseUpdated 2 months ago
15app.get("/frontend/**/*", c => serveFile(c.req.path, import.meta.url));
16
17// Add your API routes here
18// app.get("/api/data", c => c.json({ hello: "world" }));
19
20// Unwrap and rethrow Hono errors as the original error
19import type {
20 HellLetLooseMapData,
21 MapInfo,
22} from "https://esm.town/v/ktodaz/Discord_Bot_Services/map_vote/map-vote-getHellLetLooseMapData.tsx";
23
24import type { CurrentConfig } from "https://esm.town/v/ktodaz/Discord_Bot_Services/map_vote/map-vote-getCurrentConfig.tsx";
25
26// Discord API endpoints
27const API_BASE = "https://discord.com/api/v10";
28
29// Initialize the Discord rate limit service
44};
45
46// Enhanced Discord API request function with rate limiting
47async function discordRequest(endpoint: string, options: RequestInit = {}) {
48 const token = Deno.env.get("DISCORD_BOT_TOKEN");
51 }
52
53 const url = `${API_BASE}${endpoint}`;
54 const headers = {
55 "Authorization": `Bot ${token}`,
82 }
83
84 console.error(`❌ Discord API error: ${response.status}`, errorBody);
85 throw new Error(`Discord API error: ${response.status} ${JSON.stringify(errorBody)}`);
86 }
87
106
107 return rateLimitService.executeWithRateLimit(routeKey, async () => {
108 const url = `${API_BASE}/channels/${channelId}/messages/${messageId}/reactions/${emoji}/@me`;
109 const token = Deno.env.get("DISCORD_BOT_TOKEN");
110
237 title: initialEmbedData.InitialEmbedTitle || "Loading . . .",
238 description: initialEmbedData.InitialEmbedDescription
239 || "Due to Discord API rate limits this will take a few minutes.",
240 fields: [
241 {
272
273// Process variants for a map and add emoji reactions
274async function processMapVariants(messageId: string, channelId: string, map: MapInfo, variantOptions: any) {
275 const mapMetaVariants: string[] = [];
276 const mapEnabledVariants: string[] = [];

github-api8 file matches

@cricks_unmixed4uUpdated 9 hours ago
Very incomplete collection of useful GitHub API adapters

myAPiKey

@Kix111Updated 12 hours ago
codingpapi
replicate
Run AI with an API