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=723&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 10967 results for "api"(814ms)

convertEmailToBlogDraftmain.tsx2 matches

@georgemandis•Updated 7 months ago
13- Create a new Markdown file in a specified GitHub repository.
14
15 We'll use the email handler from Val Town, html-to-markdown for conversion, and the GitHub API via Octokit to create the file.
16 */
17
50 content: btoa(binString),
51 headers: {
52 "X-GitHub-Api-Version": "2022-11-28",
53 },
54 });

convertEmailToBlogDraftREADME.md1 match

@georgemandis•Updated 7 months ago
6- This script assumes you're using some kind of static site generator that can read from a GitHub repository. There are many to choose from in this space. I'm partial to [11ty](http://11ty.dev)
7- Gmail is doing some heavy-lifting for me here in terms of kindly converting my HTML email to Markdown behind the scenes. It's not a guarantee all email providers do this. If yours does not, you may have to investigate an HTML-to-Markdown conversion step.
8- We'll use the GitHub API via Octokit to create the file. You'll need to [create a token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#) and store it an an environmental variable in your Val Town settings.
9
10

arenaApiExamplemain.tsx2 matches

@deblina•Updated 7 months ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export let arenaApiExample = (async () => {
4 const resp = await fetch(
5 "http://api.are.na/v2/channels/project-logs",
6 );
7 const json = await resp.json();

arenaApiExampleREADME.md3 matches

@deblina•Updated 7 months ago
1# Are.na API
2
3Example of using the [are.na](https://dev.are.na/documentation/channels#Block43472) API to get the contents of an Are.na board - specifically my fun board that showcases websites with that "glossy black style."
4
5All you need is [fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) to make this happen!

bbrunmain.tsx1 match

@kenbarrett•Updated 7 months ago
131
132const boardToEndpoint = (board: string) => {
133 return board.replace(/\.json$/, ".api/run");
134};
135

BrowserbaseFetcherFromURLmain.tsx5 matches

@willthereader•Updated 7 months ago
1import { PuppeteerDeno } from "https://deno.land/x/puppeteer@16.2.0/src/deno/Puppeteer.ts";
2// 1st stable version is v13
3const BROWSERBASE_API_KEY = Deno.env.get("BROWSERBASE_API_KEY");
4const TIMEOUT = 30000; // 30 seconds timeout
5
16 let browser;
17 try {
18 if (!BROWSERBASE_API_KEY) {
19 throw new Error("BROWSERBASE_API_KEY is not set");
20 }
21
22 const puppeteer = new PuppeteerDeno({ productName: "chrome" });
23 const wsEndpoint = `wss://connect.browserbase.com?apiKey=${BROWSERBASE_API_KEY}&enableProxy=true`;
24
25 console.log("Attempting to connect to Browserbase...");
80 let errorMessage = error.message;
81 if (error.message.includes("400 Bad Request")) {
82 errorMessage = "Failed to connect to Browserbase. Please check your API key and account status.";
83 }
84 return new Response(JSON.stringify({ error: errorMessage }), {

entireGoldLarkmain.tsx1 match

@nlnhsr•Updated 7 months ago
86 if (!inputs.$key || inputs.$key != Deno.env.get("BB_SERVICE_KEY")) {
87 return {
88 $error: "Must provide an API key to access the service.",
89 };
90 }

openaiproxyREADME.md1 match

@roadlabs•Updated 7 months ago
1# OpenAI Proxy
2
3This OpenAI API proxy injects Val Town's API keys. For usage documentation, check out https://www.val.town/v/std/openai

openaiproxymain.tsx5 matches

@roadlabs•Updated 7 months ago
1import { parseBearerString } from "https://esm.town/v/andreterron/parseBearerString";
2import { API_URL } from "https://esm.town/v/std/API_URL?v=5";
3import { OpenAIUsage } from "https://esm.town/v/std/OpenAIUsage";
4import { RateLimit } from "npm:@rlimit/http";
28 const authHeader = req.headers.get("Proxy-Authorization") || req.headers.get("Authorization");
29 const token = authHeader ? parseBearerString(authHeader) : undefined;
30 const meRes = await fetch(`${API_URL}/v1/me`, { headers: { Authorization: `Bearer ${token}` } });
31 if (!meRes.ok) {
32 return new Response("Unauthorized", { status: 401 });
42
43 // Proxy the request
44 const url = new URL("." + pathname, "https://api.openai.com");
45 url.search = search;
46
47 const headers = new Headers(req.headers);
48 headers.set("Host", url.hostname);
49 headers.set("Authorization", `Bearer ${Deno.env.get("OPENAI_API_KEY")}`);
50 headers.set("OpenAI-Organization", Deno.env.get("OPENAI_API_ORG"));
51
52 const modifiedBody = await limitFreeModel(req, user);

bbaasfemain.tsx1 match

@odicho•Updated 7 months ago
58 * Indicates that the input or output port represents base structured
59 * datatype containing multi-part content of a message, generated by an LLM.
60 * See [Content](https://ai.google.dev/api/rest/v1beta/Content) for details
61 * on the datatype.
62 */

daily-advice-app1 file match

@dcm31•Updated 1 day ago
Random advice app using Advice Slip API

gptApiTemplate1 file match

@charmaine•Updated 3 days ago
apiv1
papimark21