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/image-url.jpg%20%22Optional%20title%22?q=api&page=1159&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"(3599ms)

CS1200main.tsx1 match

@rimjhim•Updated 2 months ago
4async function fetchRandomJoke() {
5 const response = await fetch(
6 "https://official-joke-api.appspot.com/random_joke",
7 );
8 return response.json();

Kaliwebhook6 matches

@augustohp•Updated 2 months ago
1import { appendMessage } from "https://esm.town/v/augustohp/Kali/dify/api";
2import { userCreateFromWebhook } from "https://esm.town/v/augustohp/Kali/orm";
3import { react, sendText } from "https://esm.town/v/augustohp/Kali/zapi/api";
4import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
5import { telegramSendMessage } from "https://esm.town/v/vtdocs/telegramSendMessage";
64 const biggestPhoto: Photo = photo.sort((a, b) => b.file_size - a.file_size)[0];
65 const getFileUrlResponse = await fetchJSON(
66 `https://api.telegram.org/bot${telegramToken}/getFile?file_id=${biggestPhoto.file_id}`,
67 );
68 const fileUrl = `https://api.telegram.org/file/bot${telegramToken}/${getFileUrlResponse.result.file_path}`;
69 console.log(fileUrl);
70 const downloadResponse = await fetch(fileUrl);
87): Promise<boolean> {
88 const reactionType: Reaction[] = [{ type: "emoji", emoji: reaction }];
89 let url = new URL(`https://api.telegram.org/bot${telegramToken}/setMessageReaction`);
90 url.searchParams.append("chat_id", chatId.toString());
91 url.searchParams.append("message_id", messageId.toString());
129 console.log(r);
130 // Validate request from Telegram
131 const secretToken = req.headers.get("x-telegram-bot-api-secret-token");
132 const expectedSecretToken = Deno.env.get("TELEGRAM_SECRET_TOKEN") || "invalid-value";
133 if (secretToken !== expectedSecretToken) {

dedicatedJadeMeerkatmain.tsx1 match

@neelchandwani•Updated 2 months ago
4async function fetchRandomJoke() {
5 const response = fetch(
6 "https://official-joke-api.appspot.com/random_joke",
7 );
8 return response.json();

successfulTomatoJaguarmain.tsx1 match

@rm3hta•Updated 2 months ago
4async function fetchRandomJoke() {
5 const response = await fetch(
6 "https://official-joke-api.appspot.com/random_joke",
7 );
8 return response.json();

execmain.tsx9 matches

@Lucianoc•Updated 2 months ago
57
58export async function exec(interval: Interval) {
59 const apiKey = Deno.env.get("LINEAR_API_KEY");
60 if (!apiKey) {
61 console.error("LINEAR_API_KEY not found in environment variables");
62 Deno.exit(1);
63 }
65 const { startDate, endDate } = getYesterdayDateRange();
66
67 const response = await fetch("https://api.linear.app/graphql", {
68 method: "POST",
69 headers: {
70 "Content-Type": "application/json",
71 Authorization: apiKey,
72 },
73 body: JSON.stringify({
80
81 if (data.errors) {
82 console.error("Error fetching data from Linear API:", data.errors);
83 Deno.exit(1);
84 }
94 }
95
96 const historyResponse = await fetch("https://api.linear.app/graphql", {
97 method: "POST",
98 headers: {
99 "Content-Type": "application/json",
100 Authorization: apiKey,
101 },
102 body: JSON.stringify({
190 }
191
192 const slackResponse = await fetch("https://slack.com/api/chat.postMessage", {
193 method: "POST",
194 headers: {

OpenAIREADME.md3 matches

@Lucianoc•Updated 2 months ago
1# OpenAI - [Docs ↗](https://docs.val.town/std/openai)
2
3Use OpenAI's chat completion API with [`std/openai`](https://www.val.town/v/std/openai). This integration enables access to OpenAI's language models without needing to acquire API keys.
4
5For free Val Town users, [all calls are sent to `gpt-4o-mini`](https://www.val.town/v/std/openaiproxy?v=12#L85).
65If these limits are too low, let us know! You can also get around the limitation by using your own keys:
66
671. Create your own API key on [OpenAI's website](https://platform.openai.com/api-keys)
682. Create an [environment variable](https://www.val.town/settings/environment-variables?adding=true) named `OPENAI_API_KEY`
693. Use the `OpenAI` client from `npm:openai`:
70

OpenAImain.tsx7 matches

@Lucianoc•Updated 2 months ago
2
3/**
4 * API Client for interfacing with the OpenAI API. Uses Val Town credentials.
5 */
6export class OpenAI {
8
9 /**
10 * API Client for interfacing with the OpenAI API. Uses Val Town credentials.
11 *
12 * @param {number} [opts.timeout=10 minutes] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
14 * @param {Core.Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
15 * @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
16 * @param {Core.Headers} opts.defaultHeaders - Default headers to include with every request to the API.
17 * @param {Core.DefaultQuery} opts.defaultQuery - Default query parameters to include with every request to the API.
18 * @param {boolean} [opts.dangerouslyAllowBrowser=false] - By default, client-side use of this library is not allowed, as it risks exposing your secret API credentials to attackers.
19 */
20 constructor(options: Omit<ClientOptions, "baseURL" | "apiKey" | "organization"> = {}) {
21 this.rawOpenAIClient = new RawOpenAI({
22 ...options,
23 baseURL: "https://std-openaiproxy.web.val.run/v1",
24 apiKey: Deno.env.get("valtown"),
25 organization: null,
26 });

solidTealTiglonmain.tsx1 match

@HuskyTRUE•Updated 2 months ago
4async function fetchRandomJoke() {
5 const response = await fetch(
6 "https://official-joke-api.appspot.com/random_joke",
7 );
8 return response.json();

mapsclonerindex.ts2 matches

@matti•Updated 2 months ago
12app.get("/frontend/**/*", c => serveFile(c.req.path, import.meta.url));
13
14// Add your API routes here
15// app.get("/api/data", c => c.json({ hello: "world" }));
16
17// Unwrap and rethrow Hono errors as the original error

bloglive-reload.ts1 match

@cdignam•Updated 2 months ago
82 // if we wanted to create a /lastUpdatedAt route,
83 // which would let us pass a val town bearer token, we could do that here
84 // gives us 10k API requests per minute instead of 1k
85 // and would work with private projects
86

readback-api

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

Plantfo8 file matches

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