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=961&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"(947ms)

tanaSavemain.tsx3 matches

@nbbaierUpdated 1 year ago
1import { saveToTana } from "https://esm.town/v/nbbaier/saveToTana";
2import { APIPlainNode } from "https://esm.town/v/nbbaier/tanaTypes";
3import { Hono } from "npm:hono";
4
5const token = Deno.env.get("tanaInputAPI");
6
7export const tanaSave = async (req: Request) => {
10 let { text, url } = c.req.query();
11
12 const payload: APIPlainNode = {
13 name: text,
14 children: [

saveToTanamain.tsx8 matches

@nbbaierUpdated 1 year ago
1import { TanaAPIHelper } from "https://esm.town/v/nbbaier/TanaAPIHelper";
2import { tanaConstants } from "https://esm.town/v/nbbaier/tanaConstants";
3import { APIPlainNode } from "https://esm.town/v/nbbaier/tanaTypes";
4
5/** saveToTana - creates a node in Tana via the Tana Input API
6 * @param {string} token - Token for accessing the API.
7 * @param {APIPlainNode} node - Data node to be created in Tana.
8 * @param {string} targetNodeId - ID of the target node where the new node will be attached (defaults to the inbox)
9 * @returns {Promise<APIPlainNode>} - A promise that resolves to the created node.
10 */
11export const saveToTana = async (
12 token: string,
13 node: APIPlainNode,
14 targetNodeId: string = tanaConstants.inboxNodeId,
15) => {
16 const client = new TanaAPIHelper(token);
17 const createdNode = await client.createNode(node, targetNodeId);
18 return createdNode;

tanaTypesmain.tsx12 matches

@nbbaierUpdated 1 year ago
1export type APIDataType = "boolean" | "plain" | "date" | "url" | "reference";
2
3export type NodeType = "node" | undefined;
4
5export type CommonNodeProps = {
6 dataType?: APIDataType;
7 type?: NodeType;
8};
9
10export type APICheckboxNode = {
11 value: boolean;
12} & CommonNodeProps;
13
14export type APIDateNode = {
15 name: string;
16} & CommonNodeProps;
17
18export type APIReferenceNode = {
19 id: string;
20} & CommonNodeProps;
21
22export type APIFileNode = {
23 file: string;
24 contentType: string;
26} & CommonNodeProps;
27
28export type APINode = APIPlainNode | APIDateNode | APIReferenceNode | APIFileNode;
29export type APIFieldValue = APINode | APICheckboxNode;
30
31export type APIPlainNode = {
32 name: string;
33 description?: string;
34 supertags?: { id: string }[];
35 children?: (APIField | APINode)[];
36} & CommonNodeProps;
37
38export type APIField = {
39 type: "field";
40 attributeId: string;
41 children?: (APIPlainNode | APINode | APICheckboxNode)[];
42};
43

saveToTanaREADME.md6 matches

@nbbaierUpdated 1 year ago
1# Save To Tana
2
3This val provides a function `saveToTana` allows the creation of nodes in [Tana](https://tana.inc/) via their [Input API](https://github.com/tanainc/tana-input-api-samples). The parameters are as follows:
4- **Token:** to access the Tana Input API, you must pass an API token to the function. Obtain an API token from the Tana app and save it as a secret in Val Town.
5- **Node:** the node that is created within Tana is passed as the second argument and must conform to the shape of an Input API node (see the [documentation](https://github.com/tanainc/tana-input-api-samples) on github for details.
6- **Target node:** optionally, you can specify a specific target node by passing a node ID to the function as it's third argument.
7
12```ts
13import { saveToTana } from "https://esm.town/v/nbbaier/saveToTana";
14import { APIPlainNode } from "https://esm.town/v/nbbaier/tanaTypes";
15import { Hono } from "npm:hono";
16
17const token = Deno.env.get("tanaInputAPI");
18
19export const honoTanaEndpoint = async (req: Request) => {
22 let { text, url } = c.req.query();
23
24 const payload: APIPlainNode = {
25 name: text,
26 children: [

rateArticleRelevancemain.tsx1 match

@iakovosUpdated 1 year ago
3export const rateArticleRelevance = async (interests: string, article: any) => {
4 const { default: OpenAI } = await import("npm:openai");
5 const openai = new OpenAI({ apiKey: process.env.OPENAI_KEY });
6
7 try {

isSupportedmain.tsx1 match

@spurushottam13Updated 1 year ago
1export async function isSupported(jsInterface) {
2 const caniuse = await import("npm:caniuse-api");
3 return caniuse.getSupport("border-radius");
4}

unsplashFmain.tsx1 match

@byrnemlUpdated 1 year ago
4export let unsplashF = (token) =>
5 fetchJSON(
6 `https://api.unsplash.com/photos`,
7 {
8 headers: {

modelInvokemain.tsx1 match

@stevekrouseUpdated 1 year ago
4const model = new ChatOpenAI({
5 temperature: 0.9,
6 openAIApiKey: process.env.openai,
7});
8

animemain.tsx2 matches

@yieldrayUpdated 1 year ago
38 if (!name) throw new Error("Cannot get cat");
39 const result: any[] = [];
40 for (const re of html.matchAll(/data-apireq="(.[^"]+)"/g)) {
41 const encoded = re[1];
42 const decoded: {
63 const ep = cat.find((c) => c.episode.startsWith(String(episode)));
64 if (!ep) throw new Error("Episode not exists");
65 const res = await fetch("https://v.anime1.me/api", {
66 method: "POST",
67 headers: {

crux_addREADME.md1 match

@yieldrayUpdated 1 year ago
1Migrated from folder: api/crux_add

new-val-api-21 file match

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

gptApiTemplate2 file matches

@charmaineUpdated 2 days 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