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/$%7BsvgDataUrl%7D?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 18990 results for "api"(2765ms)

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

PlantfoREADME.md32 matches

@Llad•Updated 4 hours ago
1# Plant Information API
2
3A REST API that provides detailed plant information using OpenAI's GPT model with intelligent caching for improved performance and reduced API costs.
4
5## Project Structure
10│ └── database/
11│ └── cache.ts # Database cache functions
12├── test.html # Plant API testing interface
13├── admin.html # Cache admin interface
14└── README.md
25- Automatic plant name normalization for consistent caching
26
27## API Endpoints
28
29### GET /
30Simple testing interface for the Plant API with comprehensive features:
31- **Interactive plant lookup**: Enter plant names and see real-time API responses
32- **API documentation**: Built-in instructions showing all available endpoints and usage examples
33- **Request URL display**: Shows the exact URL used for each request with copy-to-clipboard functionality
34- **Response formatting**: Pretty-printed JSON responses with syntax highlighting
35- **Error handling**: Clear display of API errors and network issues
36- **Admin panel access**: Direct link to cache management interface
37- **Caching indicators**: Visual feedback showing whether responses came from cache or fresh API calls
38
39### GET /api
40Returns API information, usage instructions, and cache statistics.
41
42### GET /admin
102
103### GET /health
104Health check endpoint that returns API status.
105
106### GET /cache/stats
180## Authentication
181
182The API includes a secure authentication system to protect admin features and cache management endpoints.
183
184### Environment Variables
196The following endpoints require admin authentication:
197- `/admin` - Admin interface
198- `/admin/cache/full` - Full cache data API
199- `/cache/stats` - Cache statistics
200- `/cache/list` - List cached plants
210## Error Handling
211
212The API returns appropriate HTTP status codes:
213- `200`: Success
214- `400`: Bad request (missing plant name)
215- `401`: Unauthorized (authentication required)
216- `500`: Server error (OpenAI API issues, parsing errors)
217
218Error responses include descriptive error messages and may include additional debugging information.
222```bash
223# Access the testing interface (web browser)
224# Visit: https://your-api-url/
225
226# Get API information and statistics
227curl https://your-api-url/api
228
229# Get information about a rose (will cache the response)
230curl https://your-api-url/plant/rose
231
232# Get information about the same rose again (will return cached response)
233curl https://your-api-url/plant/rose
234
235# Get information about a tomato plant
236curl https://your-api-url/plant/tomato
237
238# Get information about a Japanese maple (spaces are handled automatically)
239curl https://your-api-url/plant/japanese%20maple
240
241# Check cache statistics (requires authentication)
242curl -b cookies.txt https://your-api-url/cache/stats
243
244# List all cached plants (requires authentication)
245curl -b cookies.txt https://your-api-url/cache/list
246
247# Clear the cache (requires authentication)
248curl -X POST -b cookies.txt https://your-api-url/cache/clear
249
250# Access the admin interface (web browser, requires login)
251# Visit: https://your-api-url/admin
252
253# Login page (web browser)
254# Visit: https://your-api-url/login
255```
256
258
259- **Plant name normalization**: Plant names are normalized (lowercased, special characters removed, spaces converted to underscores) for consistent caching
260- **Cache hits**: Subsequent requests for the same plant (even with different capitalization or spacing) will return cached responses instantly
261- **Cache misses**: New plants trigger OpenAI API calls and the responses are automatically cached
262- **Performance**: Cached responses are served in milliseconds vs. seconds for OpenAI API calls
263- **Cost efficiency**: Reduces OpenAI API usage and associated costs
264
265## Technical Details
Plantfo

Plantfotest.html10 matches

@Llad•Updated 4 hours ago
4 <meta charset="UTF-8">
5 <meta name="viewport" content="width=device-width, initial-scale=1.0">
6 <title>Plantfo - API</title>
7 <script src="https://cdn.twind.style" crossorigin></script>
8 </head>
13 <div>
14 <h1 class="text-3xl font-bold text-green-700 mb-2">
15 🌱 Plantfo: The API for Plant Care Info
16 </h1>
17 <p class="text-gray-600">
18 Enter a plant name to get detailed information from the API
19 </p>
20 </div>
27 </div>
28
29 <!-- API Usage Instructions -->
30 <div class="bg-blue-50 border border-blue-200 rounded-lg p-4 mb-6">
31 <h3 class="text-lg font-semibold text-blue-800 mb-2">
32 đź“– How to Use the API
33 </h3>
34 <div class="text-sm text-blue-700 space-y-2">
56 <ul class="list-disc list-inside ml-4 space-y-1">
57 <li>
58 <code class="bg-blue-100 px-2 py-1 rounded">GET /api</code> -
59 API information and statistics
60 </li>
61 </ul>
102
103 <div class="bg-white rounded-lg shadow-md p-6">
104 <h2 class="text-xl font-semibold text-gray-800 mb-4">API Response</h2>
105 <div id="requestUrl" class="mb-4 p-3 bg-gray-100 rounded-lg border">
106 <div class="text-sm text-gray-600 mb-1">Request URL:</div>
122 class="bg-gray-50 p-4 rounded-lg overflow-x-auto text-sm border min-h-[100px] flex items-center justify-center text-gray-500"
123 >
124 Enter a plant name above to see the API response
125 </div>
126 </div>
161 responseContent.className = 'bg-gray-50 p-4 rounded-lg overflow-x-auto text-sm border min-h-[100px]';
162 } else {
163 // API error - show error details
164 responseContent.innerHTML = `<div class="text-red-700"><strong>Error ${response.status}:</strong><pre class="mt-2">${JSON.stringify(data, null, 2)}</pre></div>`;
165 responseContent.className = 'bg-red-50 p-4 rounded-lg overflow-x-auto text-sm border min-h-[100px] border-red-200';
Plantfo

Plantfo8 file matches

@Llad•Updated 4 hours ago
API for AI plant info

beeminder-api4 file matches

@cricks_unmixed4u•Updated 1 day ago
apiry
snartapi