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=501&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 5580 results for "api"(1840ms)

dailyDadJokemain.tsx1 match

@stevekrouse•Updated 1 year ago
3
4export async function dailyDadJoke() {
5 let { setup, punchline } = await fetchJSON("https://official-joke-api.appspot.com/random_joke");
6 return email({
7 text: punchline,

getDadJokemain.tsx1 match

@stevekrouse•Updated 1 year ago
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2
3export let getDadJoke = () => fetchJSON("https://official-joke-api.appspot.com/random_joke");

untitled_amethystShrewmain.tsx1 match

@adheep04•Updated 1 year ago
4async function fetchRandomJoke() {
5 const response = await fetch(
6 "https://official-joke-api.appspot.com/random_joke",
7 );
8 return response.json();

honoZodSwaggerUimain.tsx16 matches

@stevekrouse•Updated 1 year ago
1/** @jsxImportSource https://esm.sh/hono@3.9.2/jsx **/
2import { swaggerUI } from "npm:@hono/swagger-ui";
3import { z } from "npm:@hono/zod-openapi";
4import { OpenAPIHono } from "npm:@hono/zod-openapi";
5import { createRoute } from "npm:@hono/zod-openapi";
6
7const ParamsSchema = z.object({
9 .string()
10 .min(3)
11 .openapi({
12 param: {
13 name: "id",
20const UserSchema = z
21 .object({
22 id: z.string().openapi({
23 example: "123",
24 }),
25 name: z.string().openapi({
26 example: "John Doe",
27 }),
28 age: z.number().openapi({
29 example: 42,
30 }),
31 })
32 .openapi("User");
33
34const route = createRoute({
50});
51
52const app = new OpenAPIHono();
53
54app.get("/", c =>
58 <ul>
59 <li>
60 <a href="/openapi.json">OpenAPI Spec</a>
61 </li>
62 <li>
64 </li>
65 <li>
66 Example API call:{" "}
67 <a href="/users/123">
68 <code>GET /users/123</code>
73 ));
74
75app.openapi(route, (c) => {
76 const { id } = c.req.valid("param");
77 return c.json({
82});
83
84app.doc("/openapi.json", {
85 openapi: "3.0.0",
86 info: {
87 version: "1.0.0",
88 title: "My API",
89 },
90});
91app.get("/swagger", swaggerUI({ url: "/openapi.json" }));
92
93export default app.fetch;

dbToAPIREADME.md3 matches

@nbbaier•Updated 1 year ago
1## Create an API from a [lowdb blob](https://www.val.town/v/pomdtr/lowdb)
2
3This val exports a function that takes a lowdb instance and returns a [Hono](https://hono.dev) router that can be used to interact with the data. This is the beginning of an implementation of something like [json-server](https://github.com/typicode/json-server) for Val Town.
4
5The resulting server also comes with a frontend at `/`. The code for the frontend can be found [here](https://www.val.town/v/nbbaier/dbToAPIFrontend).
6
7See [this val](https://www.val.town/v/nbbaier/dbToAPIexample) for an example.
8
9### Things I'd like to implement

weatherGPTREADME.md1 match

@ellenchisa•Updated 1 year ago
1If you fork this, you'll need to set `OPENAI_API_KEY` in your [Val Town Secrets](https://www.val.town/settings/secrets).
2
3

emailRandomJokemain.tsx1 match

@liu_david3•Updated 1 year ago
4async function fetchRandomJoke() {
5 const response = await fetch(
6 "https://official-joke-api.appspot.com/random_joke",
7 );
8 return response.json();

untitled_crimsonFinchmain.tsx1 match

@rob_ne•Updated 1 year ago
4async function fetchRandomJoke() {
5 const response = await fetch(
6 "https://official-joke-api.appspot.com/random_joke",
7 );
8 return response.json();

memoryApiExampleREADME.md1 match

@stevekrouse•Updated 1 year ago
1Migrated from folder: Archive/memoryApiExample

memoryApiExamplemain.tsx7 matches

@stevekrouse•Updated 1 year ago
1import { handleMemoryApiRequest } from "https://esm.town/v/xkonti/gptMemoryManager";
2
3const apiName = "Memory API";
4const contactEmail = "some@email.com";
5const lastPolicyUpdate = "2023-11-28";
6const blobKeyPrefix = "gpt:memories:";
7const apiKeyPrefix = "GPTMEMORYAPI_KEY_";
8
9export const memoryApiExample = async (req: Request) => {
10 return await handleMemoryApiRequest(
11 req,
12 apiName,
13 contactEmail,
14 lastPolicyUpdate,
15 blobKeyPrefix,
16 apiKeyPrefix,
17 );
18};

runValAPIEx2 file matches

@charmaine•Updated 1 day ago

PassphraseAPI2 file matches

@wolf•Updated 3 days ago
rapilot330
artivilla
founder @outapint.io vibe coding on val.town. dm me to build custom vals: https://artivilla.com