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=931&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 11702 results for "api"(1955ms)

longest_valmain.tsx5 matches

@andreterron•Updated 1 year ago
1import { paginateAPI } from "https://esm.town/v/andreterron/paginateAPI";
2import { API_URL } from "https://esm.town/v/std/API_URL?v=5";
3import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
4
11};
12const me = await fetchJSON(
13 `${API_URL}/v1/me`,
14 opts,
15);
16// TODO: Paginate
17const vals = await paginateAPI(
18 `${API_URL}/v1/users/${me.id}/vals?limit=100`,
19 opts,
20);

API_URLmain.tsx2 matches

@std•Updated 1 year ago
2 // try/catch prevents crashes if the script doesn't have env access
3 try {
4 return Deno.env.get("VALTOWN_API_URL");
5 } catch {}
6}
7
8export const API_URL = envOrUndefined("VALTOWN_API_URL") ?? "https://api.val.town";

chat_openaimain.tsx2 matches

@cosmo•Updated 1 year ago
1const { default: OpenAI } = await import("npm:openai");
2
3export async function chat(apiKey, messages) {
4 const openai = new OpenAI({ apiKey });
5
6 return openai.chat.completions.create({

draftReadmemain.tsx2 matches

@nbbaier•Updated 1 year ago
25async function getVal(username: string, valName: string) {
26 try {
27 const res = await fetch(`https://api.val.town/v1/alias/${username}/${valName}`, {
28 method: "GET",
29 headers: {
67async function updateReadme(id: string, readme: string) {
68 try {
69 const res = await fetch(`https://api.val.town/v1/vals/${id}`, {
70 method: "PUT",
71 headers: {

readmeGPTmain.tsx3 matches

@nbbaier•Updated 1 year ago
6 model: string;
7 openai: OpenAI;
8 apiKey: string;
9 valtownKey: string;
10
32 private async getVal(username: string, valName: string) {
33 try {
34 const res = await fetch(`https://api.val.town/v1/alias/${username}/${valName}`, {
35 method: "GET",
36 headers: {
72 private async updateReadme(id: string, readme: string) {
73 try {
74 const res = await fetch(`https://api.val.town/v1/vals/${id}`, {
75 method: "PUT",
76 headers: {

sqliteWritermain.tsx2 matches

@nbbaier•Updated 1 year ago
10 table: string;
11 model: string;
12 apiKey: string;
13 openai: OpenAI;
14
17 this.table = table;
18 this.model = model;
19 // this.apiKey = openaiOptions.apiKey ? openaiOptions.apiKey : Deno.env.get("OPENAI_API_KEY");
20 this.openai = new OpenAI(openaiOptions);
21 }

readmeGPTREADME.md2 matches

@nbbaier•Updated 1 year ago
30```
31
32## API Reference
33
34### Class: ReadmeWriter
43
44- `model` (optional): The model to be used for generating the readme. Defaults to "gpt-3.5-turbo".
45- `apiKey` (optional): An OpenAI API key. Defaults to `Deno.env.get("OPENAI_API_KEY")`.
46
47#### Methods

sqliteWriterREADME.md2 matches

@nbbaier•Updated 1 year ago
365. Handle the generated query or query result according to your application's needs.
37
38## API
39
40### `new QueryWriter(args: { table: string; model?: string }): QueryWriter`
44- `table`: The name of the database table to operate on.
45- `model` (optional): The model to use for generating SQL queries. Defaults to "gpt-3.5-turbo".
46- `apiKey` (optional): An OpenAI API key. Defaults to `Deno.env.get("OPENAI_API_KEY")`.
47
48

valTownQuotaUseagemain.tsx2 matches

@zarutian•Updated 1 year ago
1// @ts-check js
2import { API_URL } from "https://esm.town/v/std/API_URL";
3const VALTOWN_API_URL = API_URL.concat("/v1");
4import { getMyValTownUserUUID } from "https://esm.town/v/zarutian/getMyValTownUserUUID";
5import { getAllValsOfUser } from "https://esm.town/v/zarutian/getAllValsOfUser";

getMyValTownUserUUIDmain.tsx4 matches

@zarutian•Updated 1 year ago
1// @ts-check
2import { API_URL } from "https://esm.town/v/std/API_URL";
3const VALTOWN_API_URL = API_URL.concat("/v1");
4
5// const VALTOWN_API_URL = "https://api.val.town/v1";
6/**
7 * @returns {Promise<string>} the uuid of the user as an string
8 **/
9export const getMyValTownUserUUID = async () => {
10 return (await (await fetch(`${VALTOWN_API_URL}/me`, {
11 headers: {
12 Authorization: `Bearer ${Deno.env.get("valtown")}`,

new-val-api-21 file match

@shouser•Updated 1 day ago
This is an example of using the API to create a val.

gptApiTemplate2 file matches

@charmaine•Updated 2 days ago
artivilla
founder @outapint.io vibe coding on val.town. dm me to build custom vals: https://artivilla.com
mux
Your friendly, neighborhood video API.