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=847&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 11437 results for "api"(1490ms)

readwiseReaderDocumentListmain.tsx2 matches

@zerovox•Updated 10 months ago
43 queryParams.append("location", location);
44 }
45 console.log("Making export api request with params " + queryParams.toString());
46 const response = await fetch("https://readwise.io/api/v3/list/?" + queryParams.toString(), {
47 method: "GET",
48 headers: {

readwiseReaderReadItemsRssmain.tsx2 matches

@zerovox•Updated 10 months ago
4export async function readwiseReaderReadItemsRss() {
5 // Get all of a user's archived documents
6 const archivedData = await readwiseReaderDocumentList(Deno.env.get("readwiseReaderApiToken"), undefined, "archive");
7
8 // Later, if you want to get new documents updated after some date, do this:
9 // const docsAfterDate = new Date(Date.now() - 24 * 60 * 60 * 1000); // use your own stored date
10 // const newData = await fetchDocumentListApi(docsAfterDate.toISOString());
11
12 return new Response(dataToRSS(

readwiseReaderDocumentListREADME.md1 match

@zerovox•Updated 10 months ago
1Reader docs here: https://readwise.io/reader_api
2
3Adapted from the example code. Fetches items from Readwise Reader given a token, and optional updatedAfter and location parameters.

readwiseReaderReadItemsRssREADME.md2 matches

@zerovox•Updated 10 months ago
1Creates an RSS feed of my read items from Readwise Reader.
2
3Reader docs here: https://readwise.io/reader_api
4
5In order to get read items from Readwise Reader -> Workflowy, this turns the read items (aka "archive") into an RSS feed, which Zapier picks up, and creates bullets in Workflowy.
6
7Ideally would store the generated RSS or the last fetch date, and only get new items, but for now `readwiseReaderDocumentList` re-fetches the full history each time.

valTownChatGPTmain.tsx1 match

@simonw•Updated 10 months ago
3import { renderToString } from "npm:react-dom/server";
4
5// This uses by personal API key, you'll need to provide your own if
6// you fork this. We'll be adding support to the std/openai lib soon!
7const openai = new OpenAI();

fetchTodaysNytCxPuzzlemain.tsx2 matches

@plr•Updated 10 months ago
37 mini?: boolean;
38}): Promise<PuzzlesData> => {
39 // https://api.foracross.com/api/puzzle_list?page=0&pageSize=50&filter%5BnameOrTitleFilter%5D=ny%20times%20june%2019%202024&filter%5BsizeFilter%5D%5BMini%5D=true&filter%5BsizeFilter%5D%5BStandard%5D=true
40 const url = new URL("https://api.foracross.com/api/puzzle_list");
41 const search = new URLSearchParams();
42 search.set("page", `${page}`);

pipelinemain.tsx17 matches

@iamseeley•Updated 10 months ago
1const HUGGING_FACE_API_URL = "https://api-inference.huggingface.co/models";
2const HUGGING_FACE_API_KEY = Deno.env.get("HUGGING_FACE_API_KEY");
3
4const defaultModels = {
60
61 async featureExtraction(input, options) {
62 return this.callHuggingFaceAPI(input, options);
63 }
64
65 async textClassification(input, options) {
66 return this.callHuggingFaceAPI(input, options);
67 }
68
69 async tokenClassification(input, options) {
70 return this.callHuggingFaceAPI(input, options);
71 }
72
73 async questionAnswering(input, options) {
74 return this.callHuggingFaceAPI(input, options);
75 }
76
77 async summarization(input, options) {
78 return this.callHuggingFaceAPI(input, options);
79 }
80
81 async translation(input, options) {
82 return this.callHuggingFaceAPI(input, options);
83 }
84
85 async textGeneration(input, options) {
86 return this.callHuggingFaceAPI(input, options);
87 }
88
89 async sentenceSimilarity(input, options) {
90 return this.callHuggingFaceAPI(input, options);
91 }
92
93 async callHuggingFaceAPI(payload, options) {
94 try {
95 const response = await fetch(`${HUGGING_FACE_API_URL}/${this.model}`, {
96 method: "POST",
97 headers: {
98 "Authorization": `Bearer ${HUGGING_FACE_API_KEY}`,
99 "Content-Type": "application/json"
100 },
104 if (!response.ok) {
105 const error = await response.json();
106 console.error("Hugging Face API Error:", error);
107 return { error: `API request failed: ${error.error}` };
108 }
109
111 return data;
112 } catch (error) {
113 console.error("Error calling Hugging Face API:", error);
114 return { error: "Error calling Hugging Face API" };
115 }
116 }

verifyTokenmain.tsx1 match

@pomdtr•Updated 10 months ago
1async function fetchUser(token: string): Promise<{ id: string }> {
2 const resp = await fetch("https://api.val.town/v1/me", {
3 headers: {
4 Authorization: `Bearer ${token}`,

vtApiTypesmain.tsx12 matches

@neverstew•Updated 10 months ago
1/**
2 * This file was auto-generated by openapi-typescript.
3 * Do not make direct changes to the file.
4 */
427 * Authenticated use will have read access to the authenticated user's private vals and secrets, write access to the authenticated user's vals, and the ability to send the authenticated user emails via `console.email`.
428 *
429 * Vals generated via this API will *not* appear in the authenticated user's workspace.
430 */
431 get: {
463 * Authenticated use will have read access to the authenticated user's private vals and secrets, write access to the authenticated user's vals, and the ability to send the authenticated user emails via `console.email`.
464 *
465 * Vals generated via this API will *not* appear in the authenticated user's workspace.
466 */
467 post: {
494 "/v1/run/{username}.{val_name}": {
495 /**
496 * Run a val as an API
497 * @deprecated
498 * @description This endpoint runs the specified user's val and returns the output.
526 };
527 /**
528 * Run a val as an API
529 * @deprecated
530 */
563 "/": {
564 /**
565 * Run a val as an API (as an Express handler)
566 * @description Runs `@{username}.{val_name}` as an Express handler.
567 *
568 * `@{username}.{val_name}` must be a function. It is passed the Express [`req`](https://expressjs.com/en/4x/api.html#req) and [`res`](https://expressjs.com/en/4x/api.html#res) objects as its arguments. You can use `req` to pull out request data, and `res` to respond with any valid Express response. Learn more at the [Express docs](https://expressjs.com/en/4x/api.html).
569 *
570 * Unlike the other two APIs, the Express API is specified via subdomain and runs at `https://{username}-{val_name}.express.val.run`.
571 *
572 * ### Unauthenticated
573 * Unauthenticated use will only be able to call public vals as Express handlers.
574 *
575 * The val will be executed with `{username}`'s permissions ("API Mode"), so it will be able to read and write to `{username}`'s public and private vals, secrets, and use `console.email`.
576 *
577 * ### Authenticated
601 };
602 /**
603 * Run a val as an API (as an Express handler)
604 * @description Runs `@{username}.{val_name}` as an Express handler.
605 *
606 * `@{username}.{val_name}` must be a function. It is passed the Express [`req`](https://expressjs.com/en/4x/api.html#req) and [`res`](https://expressjs.com/en/4x/api.html#res) objects as its arguments. You can use `req` to pull out request data, and `res` to respond with any valid Express response. Learn more at the [Express docs](https://expressjs.com/en/4x/api.html).
607 *
608 * ### Unauthenticated
609 * Unauthenticated use will only be able to call public vals as Express handlers.
610 *
611 * The val will be executed with `{username}`'s permissions ("API Mode"), so it will be able to read and write to `{username}`'s public and private vals, secrets, and use `console.email`.
612 *
613 * ### Authenticated

add_to_habitify_from_todoist_w_aimain.tsx19 matches

@nerdymomocat•Updated 10 months ago
1import { blob } from "https://esm.town/v/std/blob";
2import process from "node:process";
3import { TodoistApi } from "npm:@doist/todoist-api-typescript";
4import Instructor from "npm:@instructor-ai/instructor";
5import Jimp from "npm:jimp";
15// the task is skipped
16
17const TODOIST_API_KEY = process.env.TODOIST_API_KEY;
18const HABITIFY_API_KEY = process.env.HABITIFY_API_KEY;
19const OPENAI_API_KEY = process.env.OPENAI_API_KEY;
20const DEF_TIMEZONE = "America/Los_Angeles"; // Get your timezone from here: https://stackoverflow.com/a/54500197
21
47};
48
49const todoistapi = new TodoistApi(TODOIST_API_KEY);
50
51const oai = new OpenAI({
52 apiKey: OPENAI_API_KEY ?? undefined,
53});
54
107async function getCommentsForTask(taskId) {
108 try {
109 const comments = await todoistapi.getComments({ taskId });
110 return comments;
111 } catch (error) {
137 const response = await fetch(url, {
138 headers: {
139 Authorization: `Bearer ${TODOIST_API_KEY}`,
140 },
141 });
310
311async function addLog(habit_id, unit_type, value, target_date) {
312 const url = `https://api.habitify.me/logs/${habit_id}`;
313 const headers = {
314 Authorization: HABITIFY_API_KEY,
315 "Content-Type": "application/json",
316 };
338}
339async function addTextNote(habit_id, created, content) {
340 const url = `https://api.habitify.me/notes/${habit_id}`;
341 const headers = {
342 Authorization: HABITIFY_API_KEY,
343 "Content-Type": "application/json",
344 };
366
367async function addImageNote(habit_id, created_at, imageBuffer) {
368 const url = `https://api.habitify.me/notes/addImageNote/${habit_id}?created_at=${encodeURIComponent(created_at)}`;
369 const headers = {
370 Authorization: HABITIFY_API_KEY,
371 "Content-Type": "image/jpeg",
372 };
395 if (!habits_list || force_update_database)
396 {
397 const HABITIFY_API_KEY = process.env.HABITIFY_API_KEY;
398 const url = "https://api.habitify.me/habits";
399 const headers = {
400 Authorization: HABITIFY_API_KEY,
401 "Content-Type": "application/json",
402 };
456export default async function(interval: Interval) {
457 const habits_list = await get_habitify_database();
458 var tasks = await todoistapi.getTasks({
459 projectId: add_to_habitify_todoist_project_id,
460 });
520 }
521 }
522 await todoistapi.deleteTask(task.id);
523 }
524}

mod-interview-api1 file match

@twschiller•Updated 16 hours ago

daily-advice-app1 file match

@dcm31•Updated 3 days ago
Random advice app using Advice Slip API
apiv1
papimark21