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=864&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 10997 results for "api"(1317ms)

getThreadsActivitymain.tsx1 match

@stevekrouseUpdated 1 year ago
20
21async function getNewThreads() {
22 const resp = await fetch(`https://discord.com/api/guilds/${guild}/threads/active`, {
23 headers: {
24 "Authorization": `Bot ${token}`,

auth_middlewaremain.tsx2 matches

@stevekrouseUpdated 1 year ago
19 <article>
20 <form method="post">
21 <label for="token">API Token</label>
22 <input id="token" name="token" type="password" />
23 <button type="submit">Submit</button>
47
48async function fetchUser(token: string): Promise<User> {
49 const resp = await fetch("https://api.val.town/v1/me", {
50 headers: {
51 Authorization: `Bearer ${token}`,

auth_middlewareREADME.md2 matches

@stevekrouseUpdated 1 year ago
9## Usage
10
11Set an `AUTH_SECRET_KEY` env variable (used to sign/verify jwt tokens). Use an API token to authenticate.
12
13```typescript
23See @pomdtr/test_auth for an example
24
25⚠️ Make sure to only provides your api token to vals you trust (i.e. your own), as it gives access to your whole account.
26
27Migrated from folder: Archive/auth_middleware

sqlitemain.tsx1 match

@saolsenUpdated 1 year ago
1import { SpanStatusCode } from "https://cdn.skypack.dev/@opentelemetry/api";
2import { type ResultSet, type TransactionMode } from "npm:@libsql/client";
3

fetchPaginatedDataREADME.md2 matches

@nbbaierUpdated 1 year ago
1# Fetch Paginated Data
2
3This val exports a function that loops through paginated API responses and returns the combined data as an array. It expects pagination with `next` and there to be a `data` property in the API response. This conforms to the Val Town API, so this function is useful when fetching paginated Val Town API responses for creating custom folders in [pomdtr's vscode extension](https://github.com/pomdtr/valtown-vscode).
4
5Usage:
7```ts
8const id = <vt user id>
9await fetchPaginatedData(`https://api.val.town/v1/users/${id}/vals`, {
10 headers: { Authorization: `Bearer ${Deno.env.get("valtown")}` },
11});

auth_middlewareREADME.md2 matches

@pomdtrUpdated 1 year ago
11Set an `AUTH_SECRET_KEY` env variable (used to sign/verify jwt tokens) to a [random string](https://randomkeygen.com/).
12
13Then use an API token to authenticate.
14
15```typescript
25See @pomdtr/test_auth for an example
26
27⚠️ Make sure to only provides your api token to vals you trust (i.e. your own), as it gives access to your whole account.

qstashmain.tsx1 match

@saolsenUpdated 1 year ago
4 SpanStatusCode,
5 trace,
6} from "https://cdn.skypack.dev/@opentelemetry/api";
7import { Client, Receiver } from "npm:@upstash/qstash";
8

redismain.tsx1 match

@saolsenUpdated 1 year ago
1import { SpanStatusCode } from "https://cdn.skypack.dev/@opentelemetry/api";
2import { Redis } from "https://deno.land/x/upstash_redis@v1.14.0/mod.ts";
3

tracingmain.tsx6 matches

@saolsenUpdated 1 year ago
1import "https://deno.land/x/xhr@0.1.0/mod.ts";
2import "node:async_hooks";
3import { context, propagation, SpanStatusCode, trace } from "https://cdn.skypack.dev/@opentelemetry/api";
4import { OTLPTraceExporter } from "https://cdn.skypack.dev/@opentelemetry/exporter-trace-otlp-http";
5import { B3Propagator } from "https://cdn.skypack.dev/@opentelemetry/propagator-b3";
32 }
33
34 // Send traces to honeycomb if HONEYCOMB_API_KEY key is set.
35 const honeycomb_api_key = Deno.env.get("HONEYCOMB_API_KEY");
36 if (honeycomb_api_key) {
37 provider.addSpanProcessor(
38 new SimpleSpanProcessor(
39 new OTLPTraceExporter({
40 url: "https://api.honeycomb.io/v1/traces",
41 headers: {
42 "x-honeycomb-team": honeycomb_api_key,
43 },
44 }),

connect4_sitemain.tsx1 match

@saolsenUpdated 1 year ago
2import { track } from "https://esm.town/v/saolsen/plausible?v=3";
3import { init, traced_fetch, traced_handler, traced, get_tracer } from "https://esm.town/v/saolsen/tracing?v=135";
4import { trace } from "npm:@opentelemetry/api";
5init("connect4_site");
6const tracer = get_tracer("connect4_site");

daily-advice-app1 file match

@dcm31Updated 2 days ago
Random advice app using Advice Slip API

gptApiTemplate1 file match

@charmaineUpdated 3 days ago
apiv1
papimark21