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=827&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 11605 results for "api"(2046ms)

lastloginREADME.md1 match

@yawnxyzUpdated 8 months ago
75```
76
77See the [URLPattern API](https://developer.mozilla.org/en-US/docs/Web/API/URL_Pattern_API) for reference.
78
79## Logout

lastloginmain.tsx1 match

@yawnxyzUpdated 8 months ago
1import { api } from "https://esm.town/v/pomdtr/api";
2import { zip } from "https://esm.town/v/pomdtr/sql";
3import { sqlite } from "https://esm.town/v/std/sqlite";

marineMoccasinLizardmain.tsx9 matches

@kazUpdated 8 months ago
49 const fetchAnswersAndRankings = async () => {
50 if (user) {
51 const response = await fetch("/api/answers");
52 const data = await response.json();
53 setAnswers(data.answers);
59 const saveAnswer = useCallback(async (newAnswer: Answer, losingAnswer: string) => {
60 if (user) {
61 await fetch("/api/answer", {
62 method: "POST",
63 headers: { "Content-Type": "application/json" },
70 const clearAnswers = useCallback(async () => {
71 if (user) {
72 await fetch("/api/clear-answers", { method: "POST" });
73 setAnswers([]);
74 setRankings([]);
242 const handleLogin = useCallback(async (e: React.FormEvent) => {
243 e.preventDefault();
244 const response = await fetch("/api/login", {
245 method: "POST",
246 headers: { "Content-Type": "application/json" },
314
315 const url = new URL(request.url);
316 if (url.pathname === "/api/login") {
317 const { username } = await request.json();
318 await sqlite.execute(`INSERT OR IGNORE INTO ${KEY}_users (username) VALUES (?)`, [username]);
321 }
322
323 if (url.pathname === "/api/answer") {
324 const { questionId, answer, losingAnswer } = await request.json();
325 const userId = 1; // In a real app, you'd get this from the session
333 }
334
335 if (url.pathname === "/api/answers") {
336 const userId = 1; // In a real app, you'd get this from the session
337 const answers = (await sqlite.execute(`SELECT * FROM ${KEY}_answers WHERE user_id = ?`, [userId])).rows;
340 }
341
342 if (url.pathname === "/api/clear-answers") {
343 const userId = 1; // In a real app, you'd get this from the session
344 await sqlite.execute(`DELETE FROM ${KEY}_answers WHERE user_id = ?`, [userId]);
411
412const css = `
413 @import url('https://fonts.googleapis.com/css2?family=Pacifico&family=Roboto:wght@300;400;500&display=swap');
414
415 :root {

npmExplorermain.tsx8 matches

@allUpdated 8 months ago
1/**
2 * This val creates an enhanced NPM package explorer using the npm registry API.
3 * It displays a grid of npm packages with basic information, categories, and navigation.
4 * The approach uses React for the frontend and fetch for API calls.
5 * It includes a details view for each package, a link to the npm page, and category navigation.
6 * Icons are added for each category, and additional pill boxes are included for specific topics.
40 performance: "⚡",
41 devops: "🚀",
42 api: "🔌",
43 authentication: "🔑",
44 deployment: "📦",
276 const category = url.searchParams.get("category") || "";
277
278 let apiUrl = `https://registry.npmjs.org/-/v1/search?text=${
279 encodeURIComponent(searchTerm)
280 }&size=${size}&from=${from}`;
281
282 if (category === "popular") {
283 apiUrl += "&popularity=1.0";
284 } else if (category === "new") {
285 apiUrl += "&maintenance=0&quality=0&popularity=0";
286 } else if (category !== "all" && category) {
287 apiUrl += `&keywords=${encodeURIComponent(category)}`;
288 }
289
290 try {
291 const response = await fetch(apiUrl);
292 const data = await response.json();
293 return new Response(JSON.stringify(data), {

lastloginmain.tsx1 match

@tionisUpdated 8 months ago
69) {
70 return async (req: Request) => {
71 const { api } = await import("https://esm.town/v/pomdtr/api");
72 const { deleteCookie, getCookies, setCookie } = await import("jsr:@std/http/cookie");
73

sqliteExplorerAppREADME.md1 match

@rizoadevUpdated 8 months ago
13## Authentication
14
15Login to your SQLite Explorer with [password authentication](https://www.val.town/v/pomdtr/password_auth) with your [Val Town API Token](https://www.val.town/settings/api) as the password.
16
17## Todos / Plans

sqliteExplorerAppmain.tsx2 matches

@rizoadevUpdated 8 months ago
27 <head>
28 <title>SQLite Explorer</title>
29 <link rel="preconnect" href="https://fonts.googleapis.com" />
30
31 <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
32 <link
33 href="https://fonts.googleapis.com/css2?family=Fira+Code:wght@300..700&family=Source+Sans+3:ital,wght@0,200..900;1,200..900&display=swap"
34 rel="stylesheet"
35 />

aqiREADME.md1 match

@nandhinianandjUpdated 8 months ago
8
91. Click `Fork`
102. Change `location` (Line 4) to describe your location. It accepts fairly flexible English descriptions which it turns into locations via [nominatim's geocoder API](https://www.val.town/v/stevekrouse/nominatimSearch).
113. Click `Run`
12

VALLEREADME.md3 matches

@lhoUpdated 8 months ago
6* Fork this val to your own profile.
7* Make a folder for the temporary vals that get generated, take the ID from the URL, and put it in `tempValsParentFolderId`.
8* If you want to use OpenAI models you need to set the `OPENAI_API_KEY` [env var](https://www.val.town/settings/environment-variables).
9* If you want to use Anthropic models you need to set the `ANTHROPIC_API_KEY` [env var](https://www.val.town/settings/environment-variables).
10* Create a [Val Town API token](https://www.val.town/settings/api), open the browser preview of this val, and use the API token as the password to log in.
11
12<img width=500 src="https://imagedelivery.net/iHX6Ovru0O7AjmyT5yZRoA/7077d1b5-1fa7-4a9b-4b93-f8d01d3e4f00/public"/>

valleBlogV0README.md1 match

@lhoUpdated 8 months ago
1* Fork this val to your own profile.
2* Create a [Val Town API token](https://www.val.town/settings/api), open the browser preview of this val, and use the API token as the password to log in.
3

new-val-api-21 file match

@shouserUpdated 14 hours ago
This is an example of using the API to create a val.

gptApiTemplate2 file matches

@charmaineUpdated 1 day ago
papimark21
socialdata
Affordable & reliable alternative to Twitter API: ➡️ Access user profiles, tweets, followers & timeline data in real-time ➡️ Monitor profiles with nearly instant alerts for new tweets, follows & profile updates ➡️ Simple integration