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/$1?q=api&page=45&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 18286 results for "api"(2459ms)

markdown-embedsetDemoURL.ts1 match

@stevekrouseโ€ขUpdated 3 days ago
3// Initialize Notion client
4const notion = new Client({
5 auth: Deno.env.get("NOTION_API_KEY"),
6});
7

markdown-embedsetCobrowse.ts1 match

@stevekrouseโ€ขUpdated 3 days ago
13 console.log(page.id);
14 // get the cobrowse value from the payload
15 // warning: properties in Notion are capitalized as a convention (see Cobrowse)
16 const cobrowse = (page.properties.Cobrowse.checkbox) ? false : true;
17 // save new cobrowse boolean to Notion page

markdown-embedsetCobrowse.ts1 match

@stevekrouseโ€ขUpdated 3 days ago
3// Initialize Notion client
4const notion = new Client({
5 auth: Deno.env.get("NOTION_API_KEY"),
6});
7

markdown-embedsetAction.ts1 match

@stevekrouseโ€ขUpdated 3 days ago
3// Initialize Notion client
4const notion = new Client({
5 auth: Deno.env.get("NOTION_API_KEY"),
6});
7

markdown-embedroot.ts2 matches

@stevekrouseโ€ขUpdated 3 days ago
6// Initialize Notion client
7const notion = new Client({
8 auth: Deno.env.get("NOTION_API_KEY"),
9});
10
20 {
21 status: "error",
22 message: "Failed to connect to Notion API",
23 error: error.message,
24 },

markdown-embedrecordClick.ts1 match

@stevekrouseโ€ขUpdated 3 days ago
7 console.log("click: ", JSON.stringify(clickData));
8
9 fetch("/api/action", {
10 method: "POST",
11 headers: {

markdown-embedREADME.md11 matches

@stevekrouseโ€ขUpdated 3 days ago
17 let html = await readFile("/frontend/index.html", import.meta.url);
18
19 const response = await fetch(`/api/demo/${id}`);
20 const initialData = await response.json();
21
87// Client-side event recording
88window.recordClick = function (action) {
89 fetch(`/api/setAction`, {
90 method: "POST",
91 headers: { "Content-Type": "application/json" },
103
104```
105โ”œโ”€โ”€ backend/ # Server-side logic and API routes
106โ”‚ โ”œโ”€โ”€ controllers/ # Business logic for Notion integration
107โ”‚ โ”œโ”€โ”€ crons/ # Scheduled tasks for cache management
108โ”‚ โ”œโ”€โ”€ routes/ # HTTP route handlers
109โ”‚ โ”‚ โ”œโ”€โ”€ api/ # JSON API endpoints
110โ”‚ โ”‚ โ”œโ”€โ”€ tasks/ # Notion webhook handlers
111โ”‚ โ”‚ โ””โ”€โ”€ views/ # HTML page serving
121### Backend (`/backend`)
122
123Handles all server-side operations including API routes, Notion integration, and static file serving. Built with Hono for routing and includes authentication middleware.
124
125### Frontend (`/frontend`)
134
135- **Val Town & Deno**: Serverless runtime environment with TypeScript support
136- **Notion Client**: Official npm library for Notion API integration
137- **Hono**: Lightweight web framework for routing and middleware
138- **Blob Storage**: Val Town's built-in caching solution for performance optimization
170
171// Route modules
172app.route("/api", api); // JSON API endpoints
173app.route("/tasks", tasks); // Notion webhook handlers
174app.route("/demo", demo); // Demo page serving
175```
176
177#### API Routes (`/api`)
178
179Serve JSON data and handle CRUD operations for demo management, cobrowsing status, and user interactions.
241```typescript
242const notion = new Client({
243 auth: Deno.env.get("NOTION_API_KEY"),
244});
245
249Required environment variables:
250
251- `NOTION_API_KEY`: Notion integration token
252- `GLANCE_DEMOS_DB_ID`: Notion database ID for demo pages
253- `GLANCE_INTERACTIONS_DB_ID`: Notion database ID for interaction tracking
289Different route areas serve specific purposes:
290
291- `/api/*`: JSON data endpoints for frontend consumption
292- `/demo/*`: Personalized demo page serving with data injection
293- `/tasks/*`: Notion webhook processing and database updates

markdown-embedREADME.md1 match

@stevekrouseโ€ขUpdated 3 days ago
7### Task endpoints use /controllers to get and save data
8
9In order to keep the API easy to look and work with, the routes in /tasks handle routing but do not get data from or save data to Notion. The functions that connect to Notion live in the /controllers directory, and are _called_ from the endpoints in /tasks.
10
11### Naming convention for routes and controllers

markdown-embedREADME.md2 matches

@stevekrouseโ€ขUpdated 3 days ago
1## /api
2
3This directory holds the endpoints that serve JSON for the /demo, and a few other endpoints that handle POSTS and GETs from the /frontend.
5## Conventions
6
7As with other directories in `/routes`, the convention in this directory is that the file in the directory that has same name as the directory handles routing in this directory; i.e., `/api/api.ts` handles routing that directs a request from `/api/cobrowse` to the file that does the work: `/api/cobrowse.ts`.
8
9(If you're wondering why the file that handles routing in this directory isn't an `index.ts` file... Glad you asked! The reason is that when you have a bunch of files open in your IDE called `index.ts`, it's impossible to know without clicking in to each file which one is which. Similar issue with debugging server logs.)

markdown-embedREADME.md2 matches

@stevekrouseโ€ขUpdated 3 days ago
8// Initialize Notion client
9const notion = new Client({
10 auth: Deno.env.get("NOTION_API_KEY"),
11});
12```
13
14Keeping controllers in this directory and importing them into our routes keeps our API endpoints thin and easier to work with. (See the /tasks directory as an example.)
15
16## Re: /controllers and /utils

github-api1 file match

@cricks_unmixed4uโ€ขUpdated 15 hours ago

beeminder-api4 file matches

@cricks_unmixed4uโ€ขUpdated 15 hours ago
Kapil01
apiv1