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=4&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 18929 results for "api"(2351ms)

Stripe741 words

https://docs.val.town/integrations/stripe/
from "https://esm.town/v/stevekrouse/discordWebhook"; import Stripe from "npm:stripe"; const stripe = new Stripe( Deno.env.get("stripe_sk_customer_readonly") as string, { apiVersion: "2020-08-27", } ); function getStripeCustomer(customerId: string) { return stripe.customers.retrieve(customerId); } export let newStripeEvent =

Sections

Stripe Checkout

Val Town: https://val.town/v/std/stripeCheckoutQuickstart. // @ts-ignore. import { Stripe } from "npm:stripe"; const stripe = new Stripe(Deno.env.get("STRIPE_TEST_API_KEY")); export default async function (req: Request): Promise<Response> { const url = new URL(req.url); if

Example Val Town Stripe Webhook

from "https://esm.town/v/stevekrouse/discordWebhook"; import Stripe from "npm:stripe"; const stripe = new Stripe( Deno.env.get("stripe_sk_customer_readonly") as string, { apiVersion: "2020-08-27", } ); function getStripeCustomer(customerId: string) { return stripe.customers.retrieve(customerId); } export let newStripeEvent =

Upgrade Guide: Safer Val Scopes378 words

https://docs.val.town/troubleshooting/std-set-permission-error/
in ChatGPT Ask questions about this page. On Nov 1, 2024, we announced safer default API scopes for vals, which don’t include the val:write scope. Some users were not included

Sections

Upgrade Guide: Safer Val Scopes

in ChatGPT Ask questions about this page. On Nov 1, 2024, we announced safer default API scopes for vals, which don’t include the val:write scope. Some users were not included

CORS387 words

https://docs.val.town/troubleshooting/cors/
from any domain (*). Support common HTTP methods without additional configuration. Work with standard web APIs and frameworks. Handle preflight requests automatically. This default configuration is beneficial for development, allowing

Sections

Default CORS Configuration

from any domain (*). Support common HTTP methods without additional configuration. Work with standard web APIs and frameworks. Handle preflight requests automatically. This default configuration is beneficial for development, allowing

Email453 words

https://docs.val.town/std/email/
"Hi", headers: { "X-Custom-Header": "xxx", }, }), ). This is also documented in our REST API, and supported in the SDK. Custom email addresses. Section titled “Custom email addresses” Email

Sections

Headers

"Hi", headers: { "X-Custom-Header": "xxx", }, }), ). This is also documented in our REST API, and supported in the SDK.

Version Control479 words

https://docs.val.town/reference/version-control/
file: import { min } from "npm:lodash-es@4"; We highly recommend pinning imported modules because their APIs can change between versions and unexpectedly break your code. Lockfiles. Section titled “Lockfiles” When

Sections

Versions of external imports

file: import { min } from "npm:lodash-es@4"; We highly recommend pinning imported modules because their APIs can change between versions and unexpectedly break your code.

Permissions935 words

https://docs.val.town/reference/permissions/
doesn’t protect any data. It merely makes it impossible for anyone to trigger this public API endpoint without the password. The worst that could happen if this password leaks is

Sections

Custom Authentication

doesn’t protect any data. It merely makes it impossible for anyone to trigger this public API endpoint without the password. The worst that could happen if this password leaks is

Github user's stars (pagination)436 words

https://docs.val.town/integrations/github/github-users-stars-pagination/
"https://esm.town/v/stevekrouse/fetchJSON?v=41"; export const getGithubStars = async (username: string) => { const user = await fetchJSON( `https://api.github.com/users/${username}`, ); let totalStars = 0; // Paginate the max number of pages per request.

Sections

Github user's stars (pagination)

"https://esm.town/v/stevekrouse/fetchJSON?v=41"; export const getGithubStars = async (username: string) => { const user = await fetchJSON( `https://api.github.com/users/${username}`, ); let totalStars = 0; // Paginate the max number of pages per request.

Email yourself when you get a comment reaction!

emailGithubReactions = async () => { const username = "stevekrouse"; const events = await fetchJSON( `https://api.github.com/users/${username}/events?per_page=100`, { headers: { Authorization: `Bearer ${githubPatToken}`, }, }, ); const comments = events.filter((event) =>

Send messages to Slack284 words

https://docs.val.town/integrations/slack/send-messages-to-slack/
with a message payload. Create a Slack app. Section titled “Create a Slack app” Visit https://api.slack.com/apps?new_app=1, create a new app From Scratch, and choose your App Name and your workspace.

Sections

Create a Slack app

Create a Slack app. Section titled “Create a Slack app” Visit https://api.slack.com/apps?new_app=1, create a new app From Scratch, and choose your App Name and your workspace.

Telegram bot584 words

https://docs.val.town/integrations/telegram/
url from req.url. // This is a no-op if nothing's changed. if (!isEndpointSet) { await bot.api.setWebhook(req.url, { secret_token: SECRET_TOKEN, }); isEndpointSet = true; } if (req.method === "POST") { return

Sections

2. Create a webhook handler to receive messages

url from req.url. // This is a no-op if nothing's changed. if (!isEndpointSet) { await bot.api.setWebhook(req.url, { secret_token: SECRET_TOKEN, }); isEndpointSet = true; } if (req.method === "POST") { return
Plantfo

Plantfoindex.ts3 matches

@Llad•Updated 7 hours ago
37});
38
39// API info endpoint moved to /api
40app.get("/api", async (c) => {
41 const stats = await getCacheStats();
42 return c.json({
43 message: "Plant Information API",
44 usage: "GET /plant/:name - Get information about a specific plant",
45 example: "/plant/rose",

untitled-8413index.ts26 matches

@chadparker•Updated 7 hours ago
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { readFile, serveFile } from "https://esm.town/v/std/utils@85-main/index.ts";
3import type { ValTownVal, ValListResponse, ApiResponse } from "../shared/types.ts";
4
5const app = new Hono();
20});
21
22// API endpoint to fetch user's vals
23app.get("/api/vals", async c => {
24 try {
25 const apiToken = Deno.env.get('VALTOWN_API_TOKEN');
26
27 if (!apiToken) {
28 return c.json<ApiResponse<null>>({
29 success: false,
30 error: "Val Town API token not configured. Please set VALTOWN_API_TOKEN environment variable."
31 }, 400);
32 }
33
34 // Fetch vals from Val Town API
35 const response = await fetch('https://api.val.town/v2/me/vals', {
36 headers: {
37 'Authorization': `Bearer ${apiToken}`,
38 'Content-Type': 'application/json'
39 }
41
42 if (!response.ok) {
43 throw new Error(`Val Town API error: ${response.status} ${response.statusText}`);
44 }
45
48 // Process vals and add basic information
49 const processedVals = valsData.data.map(val => {
50 // For now, we'll set a default type since the v2 API doesn't include it
51 // We can try to infer it from the val name or other clues
52 val.type = 'script'; // Default type
53
54 // Simple heuristic: if the val name suggests it's an HTTP endpoint
55 if (val.name.toLowerCase().includes('api') ||
56 val.name.toLowerCase().includes('server') ||
57 val.name.toLowerCase().includes('web') ||
64 });
65
66 return c.json<ApiResponse<ValTownVal[]>>({
67 success: true,
68 data: processedVals
71 } catch (error) {
72 console.error('Error fetching vals:', error);
73 return c.json<ApiResponse<null>>({
74 success: false,
75 error: error instanceof Error ? error.message : 'Unknown error occurred'
78});
79
80// API endpoint to get a specific val's details
81app.get("/api/vals/:id", async c => {
82 try {
83 const apiToken = Deno.env.get('VALTOWN_API_TOKEN');
84 const valId = c.req.param('id');
85
86 if (!apiToken) {
87 return c.json<ApiResponse<null>>({
88 success: false,
89 error: "Val Town API token not configured"
90 }, 400);
91 }
92
93 const response = await fetch(`https://api.val.town/v1/vals/${valId}`, {
94 headers: {
95 'Authorization': `Bearer ${apiToken}`,
96 'Content-Type': 'application/json'
97 }
99
100 if (!response.ok) {
101 throw new Error(`Val Town API error: ${response.status} ${response.statusText}`);
102 }
103
109 }
110
111 return c.json<ApiResponse<ValTownVal>>({
112 success: true,
113 data: val
116 } catch (error) {
117 console.error('Error fetching val:', error);
118 return c.json<ApiResponse<null>>({
119 success: false,
120 error: error instanceof Error ? error.message : 'Unknown error occurred'

beeminder-api4 file matches

@cricks_unmixed4u•Updated 6 hours ago

shippingAPI1 file match

@dynamic_silver•Updated 21 hours ago
apiry
snartapi