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/$%7Bart_info.art.src%7D?q=api&page=1482&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 18012 results for "api"(1570ms)

surfboardDemoSchedule2main.tsx3 matches

@keenanzucker•Updated 10 months ago
9 tomorrow.setDate(tomorrow.getDate() + 1);
10 const data = await fetch(
11 `https://api.stage.teamsurfboard.com/api/v1/schedule?start=${today.toISOString()}&end=${tomorrow.toISOString()}`,
12 {
13 headers: {
14 // ADD YOUR API TOKEN INTO THE ENV VARIABLES
15 "Authorization": `Bearer ${Deno.env.get("TEAMSURFBOARD_API_TOKEN")}`,
16 },
17 },

telegramWebhookEchoMessagemain.tsx2 matches

@ghsaboias•Updated 10 months ago
3
4const BOT_TOKEN = Deno.env.get("TELEGRAM_TOKEN");
5const TELEGRAM_API_URL = `https://api.telegram.org/bot${BOT_TOKEN}`;
6
7useHTTP(async (req, res) => {
26async function sendMessage(chatId, text) {
27 try {
28 const url = `${TELEGRAM_API_URL}/sendMessage`;
29 const payload = {
30 chat_id: chatId,

illustratedPrimerREADME.md1 match

@nknj•Updated 10 months ago
1Generates a streaming illustrated primer on a subject. Enter a subject, click on titles to "delve".
2
3🪩 To fork, [sign up for Substrate](https://substrate.run/signin) to get your own API key and $50 free credits

illustratedPrimermain.tsx3 matches

@nknj•Updated 10 months ago
8
9 // Substrate graph
10 const substrate = new Substrate({ apiKey: Deno.env.get("SUBSTRATE_API_KEY_R") });
11 const Topic = z
12 .object({
79
80 // UI
81 const capitalize = s => s.replace(/^\w/, c => c.toUpperCase());
82 return new Response(
83 new ReadableStream({
96 <div style="margin:0 10px;">${pair.image}</div>
97 <div style="margin:0 10px;font-size:1.2rem;">
98 <a href="/?input=${pair.title}"><b>${capitalize(pair.title)}</b></a><br/>${pair.caption}</div>
99</div>`,
100 ));

salmonMolemain.tsx3 matches

@nknj•Updated 10 months ago
4import { zodToJsonSchema } from "npm:zod-to-json-schema";
5
6const substrate = new Substrate({ apiKey: Deno.env.get("SUBSTRATE_API_KEY") });
7
8// search for HN comments using https://hn.algolia.com/api
9const query = "langchain";
10const searchResults = await hnSearch({
31 new ComputeJSON({
32 prompt: `Summarize this comment and how it relates to the topic: ${query}
33 Use "negative" sentiment for posts about API, abstraction, documentation, tutorial, general quality, slowness, or performance issues.
34 COMMENT: ${JSON.stringify(hit)}`,
35 json_schema: zodToJsonSchema(commentInfo),

salmonMoleREADME.md2 matches

@nknj•Updated 10 months ago
1Find comments on HN (powered by [Algolia](https://hn.algolia.com/api)), extract content and return a streaming markdown summary (powered by [Substrate](https://substrate.run)).
2
3The RAG portion of this is 34 lines of Substrate code. Read the walkthrough: https://x.com/vprtwn/status/1812844236401762513
4
5🪩 To fork, [sign up for Substrate](https://substrate.run/signin) to get your own API key and $50 free credits.
6
7See also:

openaiproxyREADME.md1 match

@mmrech•Updated 10 months ago
1# OpenAI Proxy
2
3This OpenAI API proxy injects Val Town's API keys. For usage documentation, check out https://www.val.town/v/std/openai

openaiproxymain.tsx5 matches

@mmrech•Updated 10 months ago
1import { parseBearerString } from "https://esm.town/v/andreterron/parseBearerString";
2import { API_URL } from "https://esm.town/v/std/API_URL?v=5";
3import { OpenAIUsage } from "https://esm.town/v/std/OpenAIUsage";
4import { RateLimit } from "npm:@rlimit/http";
27 const authHeader = req.headers.get("Proxy-Authorization") || req.headers.get("Authorization");
28 const token = authHeader ? parseBearerString(authHeader) : undefined;
29 const meRes = await fetch(`${API_URL}/v1/me`, { headers: { Authorization: `Bearer ${token}` } });
30 if (!meRes.ok) {
31 return new Response("Unauthorized", { status: 401 });
41
42 // Proxy the request
43 const url = new URL("." + pathname, "https://api.openai.com");
44 url.search = search;
45
46 const headers = new Headers(req.headers);
47 headers.set("Host", url.hostname);
48 headers.set("Authorization", `Bearer ${Deno.env.get("OPENAI_API_KEY")}`);
49 headers.set("OpenAI-Organization", Deno.env.get("OPENAI_API_ORG"));
50
51 const modifiedBody = await limitFreeModel(req, user);

gitReleaseNotesmain.tsx1 match

@kylem•Updated 10 months ago
45
46async function getGithubReleases(repo: string): Promise<GithubRelease[]> {
47 const response = await fetch(`https://api.github.com/repos/${repo}/releases`);
48 if (!response.ok) {
49 throw new Error(`Failed to fetch releases from ${repo}`);

blobmain.tsx1 match

@janpaul123•Updated 10 months ago
1// This implementation uses SQLite to store blob data instead of the Val Town API.
2// It creates a 'blobs' table to store key-value pairs, where the key is the blob key
3// and the value is the blob data stored as TEXT. This approach allows for persistence

Apiify7 file matches

@wolf•Updated 19 mins ago

dailyQuoteAPI

@Souky•Updated 2 days ago
Kapil01
apiv1