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=406&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 4131 results for "api"(631ms)

bluesky_bot_templatemain.tsx1 match

@alexwein•Updated 3 months ago
1import process from "node:process";
2import { AppBskyFeedPost, AtpAgent } from "npm:@atproto/api";
3
4const agent = new AtpAgent({

templateRedditAlertmain.tsx9 matches

@valdottown•Updated 3 months ago
1import { searchWithSerpApi } from "https://esm.town/v/charmaine/searchWithSerpApi";
2import { discordWebhook } from "https://esm.town/v/stevekrouse/discordWebhook";
3
4// Customize your search parameters
5const KEYWORDS = "\"node\" OR \"node.js\"";
6const DISCORD_API_KEY = Deno.env.get("mentionsDiscord");
7const SERP_API_KEY = Deno.env.get("SERP_API_KEY");
8
9// Set isProd = false for testing and = true for production
13
14export async function redditAlert({ lastRunAt }: Interval) {
15 if (!SERP_API_KEY || !DISCORD_API_KEY) {
16 console.error("Missing SERP_API_KEY or Discord webhook URL. Exiting.");
17 return;
18 }
19
20 // Determine the time frame for the search
21 // Details on as_qdr: https://serpapi.com/advanced-google-query-parameters#api-parameters-advanced-search-query-parameters-as-qdr
22 const timeFrame = isProd
23 ? lastRunAt
27
28 try {
29 const response = await searchWithSerpApi({
30 query: KEYWORDS,
31 site: "reddit.com",
32 apiKey: SERP_API_KEY,
33 as_qdr: timeFrame,
34 });
62 if (isProd) {
63 await discordWebhook({
64 url: DISCORD_API_KEY,
65 content,
66 });

searchWithSerpApimain.tsx7 matches

@charmaine•Updated 3 months ago
1export async function searchWithSerpApi({
2 query,
3 site,
4 daysBack,
5 apiKey,
6}: {
7 query: string;
8 site?: string;
9 daysBack?: number;
10 apiKey: string;
11}): Promise<SearchResult[]> {
12 if (!apiKey) {
13 console.warn("SERP API key not provided. Skipping search.");
14 return [];
15 }
21
22 const encodedQuery = encodeURIComponent(`${query} ${site ? `site:${site}` : ""} after:${formattedDate}`);
23 const url = `https://serpapi.com/search.json?engine=google&q=${encodedQuery}&api_key=${apiKey}&sort_by=date`;
24
25 try {
36 }));
37 } catch (error) {
38 console.error("Error occurred during SERP API search:", error);
39 return [];
40 }

valiantSalmonWarblermain.tsx1 match

@shouser•Updated 3 months ago
17 <p>
18 We've recently made improvements to Val Town's security by
19 <a href="https://blog.val.town/blog/api-token-scopes" target="_blank" rel="noopener noreferrer">
20 providing granular control over val permissions</a>.
21 As part of the rollout, we updated all vals to a safer set of default permissions.

stripeWebsocketDemostripeTrigger1 match

@wolf•Updated 3 months ago
6const stripe = new Stripe(
7 Deno.env.get("TEST_STRIPE_SECRET") as string,
8 { apiVersion: "2023-10-16" },
9);
10
8
9const stripe = new Stripe(Deno.env.get("stripe_sk_customer_readonly") as string, {
10 apiVersion: "2020-08-27",
11});
12

simpletextmain.tsx2 matches

@nbbaier•Updated 6 months ago
16 <meta name="viewport" content="width=device-width, initial-scale=1.0">
17 <title>${blogTitle}</title>
18 <link rel="preconnect" href="https://fonts.googleapis.com">
19 <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
20 <link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;1,100;1,200;1,300;1,400;1,500;1,600;1,700&display=swap" rel="stylesheet">
21 <style>
22 @view-transition { navigation: auto; }

emailREADME.md1 match

@shouser•Updated 8 months ago
54You can attach files to your emails by using the `attachments` field.
55Attachments need to be [Base64](https://en.wikipedia.org/wiki/Base64) encoded,
56which is that the [btoa](https://developer.mozilla.org/en-US/docs/Web/API/btoa)
57method is doing in this example:
58

emailmain.tsx2 matches

@shouser•Updated 8 months ago
1import { API_URL } from "https://esm.town/v/std/API_URL";
2import { parseSendGridEmail } from "https://esm.town/v/stevekrouse/parseSendGridEmail?v=8";
3import { parseSendGridEmails } from "https://esm.town/v/stevekrouse/parseSendGridEmails?v=10";
69}) => {
70 let result = await fetch(
71 `${API_URL}/v1/email`,
72 {
73 method: "POST",

cronLoggermain.tsx2 matches

@nbbaier•Updated 9 months ago
1import { inTheBackground } from "https://esm.town/v/neverstew/inTheBackground";
2import { API_URL } from "https://esm.town/v/std/API_URL?v=5";
3import { sqlite } from "https://esm.town/v/std/sqlite?v=6";
4import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=45";
26 headers["Authorization"] = `Bearer ${token}`;
27 }
28 const { id } = await fetchJSON(`${API_URL}/v1/alias/${userHandle}/${valName}`, { headers });
29
30 const table_name = "cron_evals";

openapi2 file matches

@stevekrouse•Updated 1 day ago

dbToAPI_backup4 file matches

@nbbaier•Updated 3 days ago
artivilla
founder @outapint.io vibe coding on val.town. dm me to build custom vals: https://artivilla.com
fiberplane
Purveyors of Hono tooling, API Playground enthusiasts, and creators of 🪿 HONC 🪿 (https://honc.dev)