You can access search results via JSON API by adding format=json
to your query:
https://codesearch.val.run/$%7Bsuccess?q=api&page=22&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 11580 results for "api"(1155ms)
1import { API_URL } from "https://esm.town/v/std/API_URL";
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
3import ValTown from "npm:@valtown/sdk";
28);
2930// Example of using the API to create a new val with a single file
31// First create the val
32const valResponse = await fetch(
33`${API_URL}/v2/vals`,
34{
35method: "POST",
36body: JSON.stringify({
37name: "new-val-api",
38privacy: "public",
39description: "This is an example of using the API to create a val.",
40}),
41headers: {
53const val = await valResponse.json();
54const fileResponse = await fetch(
55`${API_URL}/v2/vals/${val.id}/files?path=main.tsx`,
56{
57method: "POST",
58body: JSON.stringify({
59content: "This is an example of using the API to create a file at the root.",
60type: "file",
61}),
1This is an example of using the API to create a file at the root.