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=842&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 10974 results for "api"(1713ms)

Jokemain.tsx1 match

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

honoBasicAuthmain.tsx1 match

@mmcc•Updated 1 year ago
19
20async function fetchUser(token: string): Promise<User> {
21 const resp = await fetch("https://api.val.town/v1/me", {
22 headers: {
23 Authorization: `Bearer ${token}`,

honoBasicAuthREADME.md1 match

@mmcc•Updated 1 year ago
15```
16
17To authenticate, [paste an api token](https://www.val.town/settings/api) in the password prompt.

reloadOnSaveREADME.md1 match

@stevekrouse•Updated 1 year ago
1# Reload in new tabs when your vals change
2
3When you're working on an HTML HTTP val in a new tab, it's annoying to have to manually reload the tab on every save. In the Val Town editor, you can hit cmd+enter, but there's nothing like that for a val in a new tab because Val Town doesn't control that new tab (like we control the iframe in the browser preview). However, you control that HTML via the fetch handler you're writing, so you can add a script that polls the Val Town API for the current version number of your val, and reload itself if it detects a new version. This val has a collection of helpers to help you do just that.
4
5## Usage

JokeGeneratormain.tsx1 match

@samarthpasala•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();

octopusAgilePricingmain.tsx1 match

@MattieTK•Updated 1 year ago
33 const locationCode = locationMap[location];
34 const octopusDataUrl =
35 `https://api.octopus.energy/v1/products/AGILE-BB-23-12-06/electricity-tariffs/E-1R-AGILE-BB-23-12-06-${locationCode}/standard-unit-rates/`;
36 const data = await fetch(octopusDataUrl);
37 let { results: results, next: next } = await data.json();

plumGazellemain.tsx2 matches

@lufafajoshua•Updated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export async function postHogAPICapture({ key, event, properties, distinct_id }: {
4 key: string;
5 event: string;
8}) {
9 const body = {
10 "api_key": key,
11 "event": event,
12 "properties": properties,

dot_commain.tsx1 match

@horatiothomas•Updated 1 year ago
102 <li className="pb-2 sm:pb-1">
103 <span className={dateClass}>2013 Jun -</span>Software Engineer @{" "}
104 <Link href="http://firstround.com/">First Round Capital</Link>
105 </li>
106 <li className="pb-2 sm:pb-1">

transmitterREADME.md1 match

@curtcox•Updated 1 year ago
1# Echo incoming request as JSON
2See https://developer.mozilla.org/en-US/docs/Web/API/Request
3
4

trpcmain.tsx1 match

@pomdtr•Updated 1 year ago
1const baseURL = `https://www.val.town/api/trpc`;
2
3export const trpc = {

daily-advice-app1 file match

@dcm31•Updated 2 days ago
Random advice app using Advice Slip API

gptApiTemplate1 file match

@charmaine•Updated 3 days ago
apiv1
papimark21