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=774&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 10974 results for "api"(1016ms)

valleBlogV0main.tsx1 match

@janpaul123•Updated 8 months ago
38 model: openai("gpt-4o", {
39 baseURL: "https://std-openaiproxy.web.val.run/v1",
40 apiKey: Deno.env.get("valtown"),
41 } as any),
42 messages: [

linearStandupmain.tsx9 matches

@schpet•Updated 8 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: {

lastloginREADME.md1 match

@stevekrouse•Updated 8 months ago
4
5[LastLogin](https://lastlogin.io/) is a decentralized hosted auth provider
6that enables login to any app through email, Google, Github, etc without API keys.
7
8This val exports middleware that can be added to any HTTP val.

currencymain.tsx2 matches

@maraoz•Updated 8 months ago
2
3export let currency = async (desired, base = "usd", amount = 1) => {
4 let { rates } = await fetchJSON(`https://open.er-api.com/v6/latest/${base}`);
5 if (rates && rates[desired.toUpperCase()]) return amount * (rates[desired.toUpperCase()]);
6 else {
7 let { rates } = await fetchJSON(
8 `https://api.coingecko.com/api/v3/exchange_rates?&x_cg_demo_api_key=${Deno.env.get("COINGECKO_API_KEY")}`,
9 );
10 return amount * rates[desired.toLowerCase()]?.value / rates[base.toLowerCase()]?.value;

VALLErunmain.tsx11 matches

@janpaul123•Updated 9 months ago
211 Make an HTTP val (other vals are currently not supported to run, even though we have examples for them).
212 Start your response with a comment explaining how your approach will work, what libraries or
213 API calls you will use, and any tradeoffs you're making. Then write the code in a consise way,
214 the simplest way to achieve the goal, though you can add some inline comments to explain your
215 reasoning (not for every line, but for major groups of lines). Don't use any environment variables
216 unless strictly necessary, for example use APIs that don't require a key, prefer internal function
217 imports (using esm.town), and prefer putting API keys as inline variables. Use built-in Deno
218 functions where possible. Unless specified, don't add error handling,
219 make sure that errors bubble up to the caller.
220 Avoid external images or base64 images, use emojis, unicode symtols, or icon fonts/libraries instead, unless that's
221 not practical for the user's request (e.g. if they ask for a particular animated gif).
222 If the user asks for something that requires persistence, use the Val Town Blob storage API, unless
223 explicitly specified otherwise. Use the current val name for the storage key, which you can get
224 using the "pomdtr/extractValInfo" val, which you can call like this:
273Make an HTTP val (other vals are currently not supported to run, even though we have examples for them).
274Add comments at the top of the file explaining how your approach works, what libraries or
275API calls you will use, and any tradeoffs you're making. Then write the code in a consise way,
276the simplest way to achieve the goal, though you can add some inline comments to explain your
277reasoning (not for every line, but for major groups of lines). Don't use any environment variables
278unless strictly necessary, for example use APIs that don't require a key, prefer internal function
279imports (using esm.town), and prefer putting API keys as inline variables. Use built-in Deno
280functions where possible. Unless specified, don't add error handling,
281make sure that errors bubble up to the caller.
282Avoid external images or base64 images, use emojis, unicode symtols, or icon fonts/libraries instead, unless that's
283not practical for the user's request (e.g. if they ask for a particular animated gif).
284If the user asks for something that requires persistence, use the Val Town Blob storage API, unless
285explicitly specified otherwise. Use the current val name for the storage key, which you can get
286using the "pomdtr/extractValInfo" val, which you can call like this:
389 \`\`\`
390
391 ### Lower-level API
392
393 We do provide access to the lower-level getter and setters, which are useful if you are storing non-JSON or binary data, need to stream in your response or request data, or do anything else lower-level.
394
395 - \`async get(key: string)\`: Retrieves a blob for a given key.
396 - \`async set(key: string, value: string | BodyInit)\`: Sets the blob value for a given key. See [BodyInit](https://deno.land/api@v1.38.1?s=BodyInit).
397
398 ### Limitations
1204
1205 const tempValName = `valle_tmp_${Math.random() * 10}`.replaceAll(".", "");
1206 // Errors in running the val bubble up through this API, so ignore them.
1207 await vt.vals.create({ name: tempValName, code: newCode, type: "http" as any, privacy: "unlisted" }).catch(
1208 (error) => {

resyAuthmain.tsx3 matches

@stevekrouse•Updated 9 months ago
1import { fetch } from "https://esm.town/v/std/fetch";
2import { resyPublicAPIKey } from "https://esm.town/v/vtdocs/resyPublicAPIKey";
3
4export const resyAuth = async (email: string, password: string): Promise<{
9 }[];
10}> => {
11 const authRes = await fetch("https://api.resy.com/3/auth/password", {
12 "headers": {
13 "authorization":
14 `ResyAPI api_key="${resyPublicAPIKey}"`,
15 "content-type": "application/x-www-form-urlencoded",
16 },

twitterSearchmain.tsx1 match

@danielgmason•Updated 9 months ago
14}): Promise<TweetResult[]> {
15 const res = await twitterJSON({
16 url: `https://api.twitter.com/2/tweets/search/recent?query=${await searchParams(
17 {
18 query,

distinctGoldLarkmain.tsx3 matches

@tempguy•Updated 9 months ago
10formData.append("file", blob, "data.json");
11
12// URL of your API
13const apiUrl = "https://filehaus.top/api/upload/data.json"; // Replace with your API URL
14
15// Send the file using fetch
16try {
17 const response = await fetch(apiUrl, {
18 method: "POST",
19 body: formData,

valleGetValsContextWindowmain.tsx7 matches

@janpaul123•Updated 9 months ago
13 const readmeVals: any = await (await fetch("https://janpaul123-readmevals.web.val.run/")).json();
14
15 const API_URL = "https://api.val.town";
16
17 const sections = [
129 {
130 prompt: "Write a val that accesses environment variables",
131 code: `const res = await fetch("${API_URL}/v1/me", {
132 headers: {
133 Authorization: \`Bearer \${Deno.env.get("valtown")}\`,
141 code: `import process from "node:process";
142
143 const res = await fetch("${API_URL}/v1/me", {
144 headers: {
145 Authorization: \`Bearer \${process.env.valtown}\`,
310 You can attach files to your emails by using the \`attachments\` field.
311 Attachments need to be [Base64](https://en.wikipedia.org/wiki/Base64) encoded,
312 which is that the [btoa](https://developer.mozilla.org/en-US/docs/Web/API/btoa)
313 method is doing in this example:
314
412 \`\`\`
413
414 ### Lower-level API
415
416 We do provide access to the lower-level getter and setters, which are useful if you are storing non-JSON or binary data, need to stream in your response or request data, or do anything else lower-level.
417
418 - \`async get(key: string)\`: Retrieves a blob for a given key.
419 - \`async set(key: string, value: string | BodyInit)\`: Sets the blob value for a given key. See [BodyInit](https://deno.land/api@v1.38.1?s=BodyInit).
420
421 ### Limitations
458 role: "assistant",
459 content:
460 "```ts\nexport default async function(req: Request): Promise<Response> {\n const apiKey = Deno.env.get(\"METEO_KEY\");\n const apiUrl = `https://api.open-meteo.com/v1/forecast?latitude=40.6782&longitude=-73.9442&hourly=temperature_2m&current_weather=true&apikey=${apiKey}`;\n\n const response = await fetch(apiUrl);\n const weatherData = await response.json();\n\n return new Response(JSON.stringify(weatherData), { headers: { \"Content-Type\": \"application/json\" } });\n}\n```",
461 },
462 {

valleBlogV0README.md1 match

@janpaul123•Updated 9 months ago
1* Fork this val to your own profile.
2* Create a [Val Town API token](https://www.val.town/settings/api), open the browser preview of this val, and use the API token as the password to log in.
3

daily-advice-app1 file match

@dcm31•Updated 2 days ago
Random advice app using Advice Slip API

gptApiTemplate1 file match

@charmaine•Updated 3 days ago
apiv1
papimark21