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=10&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 18916 results for "api"(4094ms)

Glanceractions.controller.ts1 match

@lightweight•Updated 17 hours ago
3// Initialize Notion client
4const notion = new Client({
5 auth: Deno.env.get("NOTION_API_KEY"),
6});
7

Glanceragent.controller.ts1 match

@lightweight•Updated 17 hours ago
3// Initialize Notion client
4const notion = new Client({
5 auth: Deno.env.get("NOTION_API_KEY"),
6});
7

untitled-222shell.ts1 match

@stainless_em•Updated 18 hours ago
21import * as Main from "chrome-devtools-frontend/entrypoints/main/main.js";
22
23// Fix crash on Firefox (non standard / unsupported api used)
24ShadowRoot.prototype.getSelection = ShadowRoot.prototype.getComponentSelection;
25Element.prototype.scrollIntoViewIfNeeded = Element.prototype.scrollIntoView;

test-apns-voip-notimain.tsx1 match

@rafaelortizzableh•Updated 18 hours ago
49 const teamId = "5LJ2HBVN6V";
50 const bundleId = isStaging ? "com.oneroofapp.snag.dev.voip" : "com.oneroofapp.snag.voip";
51 const endpoint = isSandbox ? "https://api.sandbox.push.apple.com/3/device" : "https://api.push.apple.com/3/device";
52
53 // 2. Create the JWT for authentication.
52 const apnsResponse = await fetch(
53 // The APNs endpoint includes the target device token.
54 `https://api.push.apple.com/3/device/${deviceToken}`,
55 {
56 method: "POST",

chatExampleindex.html2 matches

@laurynas•Updated 19 hours ago
6 <title>React Hono Val Town Starter</title>
7 <script src="https://cdn.tailwindcss.com"></script>
8 <link rel="preconnect" href="https://fonts.googleapis.com">
9 <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
10 <link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&display=swap" rel="stylesheet">
11 <link rel="icon" href="/public/favicon.svg" sizes="any" type="image/svg+xml">
12 <style>

chatExampleREADME.md3 matches

@laurynas•Updated 19 hours ago
38```
39
40## API Endpoints
41
42- `GET /` - Serves the React application with initial data
43- `GET /api/messages` - Fetch all messages (JSON)
44- `POST /api/messages` - Create a new message
45- `GET /public/**` - Static assets (CSS, JS, etc.)
46- `/*` - All other routes handled by TanStack Router

chatExampleREADME.md5 matches

@laurynas•Updated 19 hours ago
8## Hono
9
10This app uses [Hono](https://hono.dev/) as the API framework. You can think of Hono as a replacement for [ExpressJS](https://expressjs.com/) that works in serverless environments like Val Town or Cloudflare Workers. If you come from Python or Ruby, Hono is also a lot like [Flask](https://github.com/pallets/flask) or [Sinatra](https://github.com/sinatra/sinatra), respectively.
11
12## Serving assets to the frontend
20### `index.html`
21
22The most complicated part of this backend API is serving index.html. In this app (like most apps) we serve it at the root, ie `GET /`.
23
24We *bootstrap* `index.html` with some initial data from the server, so that it gets dynamically injected JSON data without having to make another round-trip request to the server to get that data on the frontend. This is a common pattern for client-side rendered apps.
25
26## CRUD API Routes
27
28This app has two CRUD API routes: for reading and inserting into the messages table. They both speak JSON, which is standard. They import their functions from `/backend/database/queries.ts`. These routes are called from the React app to refresh and update data.
29
30## Errors
31
32Hono and other API frameworks have a habit of swallowing up Errors. We turn off this default behavior by re-throwing errors, because we think most of the time you'll want to see the full stack trace instead of merely "Internal Server Error". You can customize how you want errors to appear.

chatExamplequeries.ts2 matches

@laurynas•Updated 19 hours ago
7 queryKey: ["messages"],
8 queryFn: async () => {
9 const response = await fetch("/api/messages");
10 if (!response.ok) {
11 throw new Error("Failed to fetch messages");
25 return useMutation({
26 mutationFn: async (content: string) => {
27 const response = await fetch("/api/messages", {
28 method: "POST",
29 headers: { "Content-Type": "application/json" },

chatExampleindex.ts3 matches

@laurynas•Updated 19 hours ago
34app.get("/shared/**/*", c => serveFile(c.req.path, import.meta.url));
35
36// API endpoints
37app.get("/api/messages", async (c) => {
38 const messages = await getMessages();
39 return c.json(messages);
40});
41
42app.post("/api/messages", async (c) => {
43 const { content } = await c.req.json();
44

beeminder-api4 file matches

@cricks_unmixed4u•Updated 1 hour ago

shippingAPI1 file match

@dynamic_silver•Updated 17 hours ago
apiry
snartapi