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=20&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 18993 results for "api"(4103ms)

firecrawlmain.tsx1 match

@charmaine•Updated 2 days ago
4} from "npm:@mendable/firecrawl-js";
5
6const app = new FirecrawlApp({ apiKey: Deno.env.get("FIRECRAWL_API_KEY") });
7
8// Scrape a website

Towniesend-message.ts12 matches

@valdottown•Updated 2 days ago
48 project,
49 branchId,
50 anthropicApiKey,
51 selectedFiles,
52 images,
54
55 // do we want to allow user-provided tokens still
56 const apiKey = anthropicApiKey || Deno.env.get("ANTHROPIC_API_KEY");
57 const our_api_token = apiKey === Deno.env.get("ANTHROPIC_API_KEY");
58
59 if (our_api_token) {
60 if (await hasInsufficientCredits({ bearerToken })) {
61 return Response.json({
73
74 const rowid = await startTrackingUsage({
75 our_api_token,
76 bearerToken, // will look up the userId from this
77 branch_id: branchId,
82
83 // Initialize PostHog client
84 const projectApiKey = Deno.env.get("POSTHOG_PROJECT_API_KEY");
85
86 let tracedModel;
87
88 if (projectApiKey) {
89 const phClient = new PostHog(projectApiKey, {
90 host: "https://us.i.posthog.com",
91 });
98 const traceId = `townie_${rowid}_${Date.now()}`;
99
100 const anthropic = createAnthropic({ apiKey });
101
102 // Wrap the Anthropic model with PostHog tracing
108 townie_branch_id: branchId,
109 townie_usage_id: rowid,
110 townie_our_api_token: our_api_token,
111 townie_num_images: images?.length || 0,
112 townie_selected_files_count: selectedFiles?.length || 0,
121 } else {
122 // Fallback to regular Anthropic call if PostHog is not configured
123 const anthropic = createAnthropic({ apiKey });
124 tracedModel = anthropic(model);
125 }
271 });
272
273 if (our_api_token) {
274 const stillHasCredits =
275 !(await hasInsufficientCredits({ bearerToken })); // Check for at least 1 cent

Townie2PurchaseCreditsRoute.tsx2 matches

@charmaine•Updated 2 days ago
15 const fetchBalance = async () => {
16 try {
17 const response = await fetch("/api/credit-balance");
18 if (response.ok) {
19 const data = await response.json();
35
36 try {
37 const response = await fetch("/api/purchase-credits", {
38 method: "POST",
39 headers: { "Content-Type": "application/json" },

Townie2index.ts4 matches

@charmaine•Updated 2 days ago
41);
42
43// token middleware for API requests
44app.all("/api/*", async (c, next) => {
45 if (c.req.path === "/api/stripe-webhook") {
46 return next();
47 }
55});
56
57app.route("/api", backend);
58
59app.get("/frontend/*", (c) => {

Townie2val-summary.ts3 matches

@charmaine•Updated 2 days 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]);

Townie2val-detail.ts1 match

@charmaine•Updated 2 days ago
18 finish_reason?: string;
19 num_images?: number;
20 our_api_token: boolean;
21}
22

Townie2useUser.tsx1 match

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

Townie2user-summary.ts2 matches

@charmaine•Updated 2 days 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

Townie2user-detail.ts2 matches

@charmaine•Updated 2 days 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

Townie2useProject.tsx2 matches

@charmaine•Updated 2 days 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) {

readback-api

@tr3ntg•Updated 8 hours ago
API for readback.
Plantfo

Plantfo8 file matches

@Llad•Updated 13 hours ago
API for AI plant info
apiry
snartapi