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/$%7Bsuccess?q=api&page=51&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 15513 results for "api"(1512ms)

myApi1 file match

@sander•Updated 1 year ago

myApi1 file match

@pmenze•Updated 1 year ago

myApi1 file match

@sarincasm•Updated 1 year ago

myApi1 file match

@pjlamb12•Updated 1 year ago

myApi1 file match

@andycoupe•Updated 1 year ago

myApi1 file match

@SlugeR•Updated 1 year ago

myApi1 file match

@lionad•Updated 1 year ago

myApi1 file match

@smetzdev•Updated 1 year ago

myApi1 file match

@hovavo•Updated 1 year ago

generateValCodeAPI2 file matches

@andreterron•Updated 1 year ago

HTTP_examplesREADME.md3 matches

@halloleo•Updated 51 mins ago
1# Val Town Docs - HTTP Examples
2
3HTTP triggers let you expose an API or website from your file.
4
5They are built on the web-standard
6[Request](https://developer.mozilla.org/en-US/docs/Web/API/Request) and
7[Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) objects,
8so are compatible with a number of web frameworks like
9[Hono](https://hono.dev/) and [Peko](https://github.com/sejori/peko).

endpointsget_vals_endpoints.tsx11 matches

@chadparker•Updated 51 mins ago
1export default async function(req: Request) {
2 try {
3 const apiKey = Deno.env.get("VALTOWN_API_TOKEN");
4
5 if (!apiKey) {
6 return new Response(
7 JSON.stringify({ error: "VALTOWN_API_TOKEN not found" }, null, 2),
8 { status: 400, headers: { "Content-Type": "application/json" } },
9 );
11
12 // Get my vals using the authenticated /me/vals endpoint
13 const valsResponse = await fetch("https://api.val.town/v2/me/vals", {
14 headers: {
15 "Authorization": `Bearer ${apiKey}`,
16 "Content-Type": "application/json",
17 },
20 if (!valsResponse.ok) {
21 const errorText = await valsResponse.text();
22 console.log("API Error response:", errorText);
23 throw new Error(
24 `Failed to fetch vals: ${valsResponse.status} ${valsResponse.statusText}. Response: ${errorText}`,
42 for (const val of vals) {
43 try {
44 // Use the files API to get the actual file structure
45 const filesResponse = await fetch(
46 `https://api.val.town/v2/vals/${val.id}/files?path=&recursive=true&limit=100`,
47 {
48 headers: {
49 "Authorization": `Bearer ${apiKey}`,
50 "Content-Type": "application/json",
51 },
80 // Fetch the file content using the file path
81 const fileContentResponse = await fetch(
82 `https://api.val.town/v2/vals/${val.id}/files?path=${encodeURIComponent(endpointsFile.path)}`,
83 {
84 headers: {
85 "Authorization": `Bearer ${apiKey}`,
86 "Content-Type": "application/json",
87 },
Kapil01
apiv1