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/$%7Bsuccess?q=api&page=1039&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 11752 results for "api"(4293ms)

getCoolPostsmain.tsx1 match

@VictorForissierUpdated 1 year ago
2
3export function getCoolPosts() {
4 return fetch("https://hn.algolia.com/api/v1/search_by_date?tags=author_pg")
5 .then((res) => res.json())
6 .then((res) => res.hits[0].comment_text);

variablePowermain.tsx1 match

@jedahanUpdated 1 year ago
25`;
26
27 fetchJSON("https://api.magicthegathering.io/v1/cards?power=*")
28 .then(({ cards }) => {
29 const names = new Set();

gpt4main.tsx3 matches

@rlimitUpdated 1 year ago
3
4/**
5 * OpenAI text completion. https://platform.openai.com/docs/api-reference/completions
6 *
7 * val.town and rlimit.com has generously provided a free daily quota. Until the quota is met, no need to provide an API key.
8 *
9 */
10export const gpt4 = async (prompt: string, maxTokens?: number = 1000) => {
11 const parent = parentReference();
12 return await runVal("rlimit.gpt4Api", {
13 prompt,
14 valUser: parent.userHandle,

githubEventsmain.tsx1 match

@bwaidelichUpdated 1 year ago
3// GitHub events
4export let githubEvents = fetchJSON(
5 "https://api.github.com/users/stevekrouse/events"
6);

getOpenapiEmbeddingmain.tsx5 matches

@wiltUpdated 1 year ago
2
3/**
4 * Call OpenAPI Embeddings api to vectorize a query string
5 * Returns an array of 1536 numbers
6 */
7export const getOpenapiEmbedding = async ({ openapiToken, query }: {
8 openapiToken: string;
9 query: string;
10}): Promise<number[]> =>
11 fetchJSON("https://api.openai.com/v1/embeddings", {
12 method: "POST",
13 headers: {
14 Authorization: `Bearer ${openapiToken}`,
15 "Content-Type": "application/json",
16 },

apiTestmain.tsx1 match

@wiltUpdated 1 year ago
1export const apiTest = async (arg: Request) => {
2 return Response.json({
3 ok: true,

nearbyJonBomain.tsx1 match

@jonboUpdated 1 year ago
46 console.log("hi");
47
48 fetch("https://api.val.town/v1/run/jonbo.fetchBcycleCounts")
49 .then((response) => {
50 if (!response.ok) {

basicAPIExmain.tsx4 matches

@stevekrouseUpdated 1 year ago
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2
3// accessible via API at https://api.val.town/eval/@stevekrouse.basicAPIEx
4export const basicAPIEx = fetchJSON(
5 "https://date.nager.at/api/v2/publicholidays/2023/US"
6);
7// Bonus: the whole runtime is available in the URL Bar 🤯
8// ie https://api.val.town/eval/"The first holiday is "+ @stevekrouse.basicAPIEx[0].name

valBeeExamplemain.tsx1 match

@stevekrouseUpdated 1 year ago
4export const valBeeExample = async () => {
5 return (valbeeTest = fetchText(
6 "http://numbersapi.com/random/math"
7 ));
8};

twitterUsermain.tsx2 matches

@stevekrouseUpdated 1 year ago
12 twitterJSON({
13 url: handle
14 ? `https://api.twitter.com/2/users/by/username/${handle}`
15 : `https://api.twitter.com/2/users/${id}`,
16 bearerToken,
17 });

gpt-image-test

@CaptainJackUpdated 15 hours ago
测试 gpt image 的不同 api 能否满足图片生成要求

new-val-api-21 file match

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