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=fetch&page=61&format=json

For typeahead suggestions, use the /typeahead endpoint:

https://codesearch.val.run/typeahead?q=fetch

Returns an array of strings in format "username" or "username/projectName"

Found 3119 results for "fetch"(358ms)

Plantadexmain.tsx12 matches

@dcm31•Updated 1 week ago
41
42 useEffect(() => {
43 async function fetchSpeciesData() {
44 try {
45 const response = await fetch(`https://api.inaturalist.org/v1/taxa/${taxonId}`);
46 if (!response.ok) {
47 throw new Error(`HTTP error! status: ${response.status}`);
50 setSpeciesData(data.results[0]);
51 } catch (err) {
52 console.error("Error fetching species data:", err);
53 setError(err);
54 } finally {
57 }
58
59 fetchSpeciesData();
60 }, [taxonId]);
61
91 const [selectedObservation, setSelectedObservation] = useState(null);
92
93 const fetchData = useCallback(async (user) => {
94 if (!user) return;
95 setLoading(true);
96 try {
97 console.log(`Fetching observations for user '${user}'...`);
98 const response = await fetch(`https://api.inaturalist.org/v1/observations?user_id=${user}&iconic_taxa=Plantae&order=desc&order_by=created_at`);
99 if (!response.ok) {
100 throw new Error(`HTTP error! status: ${response.status}`);
101 }
102 const data = await response.json();
103 console.log("Fetched data:", data);
104 setObservations(data.results || []);
105 } catch (err) {
106 console.error("Error fetching data:", err);
107 setError(err);
108 } finally {
112
113 useEffect(() => {
114 fetchData(username);
115 }, [fetchData, username]);
116
117 const handleSubmit = (e) => {
118 e.preventDefault();
119 fetchData(username);
120 };
121

clickbaitbotsummarizeContent9 matches

@minimasoft•Updated 1 week ago
10});
11
12// Helper function to fetch content from the getContent API
13async function fetchContentFromUrl(url) {
14 // This URL should be updated with the actual getContent API URL
15 const getContentApiUrl = "https://nulo--2b8a5f201aaf11f094a0569c3dd06744.web.val.run";
16 const encodedUrl = encodeURIComponent(url);
17 const response = await fetch(`${getContentApiUrl}/content/${encodedUrl}`);
18
19 if (!response.ok) {
20 throw new Error(`Failed to fetch content: ${response.status}`);
21 }
22
31 }
32
33 const response = await fetch("https://openrouter.ai/api/v1/chat/completions", {
34 method: "POST",
35 headers: {
86 console.log(`Cache miss for summary of ${url}, generating new summary`);
87
88 // Fetch content from the URL
89 const content = await fetchContentFromUrl(url);
90
91 // Summarize the content
202 <body>
203 <h1>URL Content Summarizer</h1>
204 <p>This tool fetches content from a URL and generates a concise summary using AI.</p>
205
206 <div class="nav-links">
270
271// This is the entry point for HTTP vals
272export default app.fetch;

clickbaitbotREADME.md3 matches

@minimasoft•Updated 1 week ago
1# URL to Markdown API
2
3This Val Town API fetches content from a URL, converts it to markdown, and caches the results for improved performance.
4
5## Features
14### GET /content/:url
15
16Fetches content from the specified URL and returns it as markdown.
17
18**Parameters:**
19- `:url` - URL-encoded URL of the page to fetch
20
21**Example:**

clickbaitbotgetContent5 matches

@minimasoft•Updated 1 week ago
77 } catch {}
78
79 console.log(`Cache miss for ${url}, fetching from Firecrawl`);
80
81 // Get Firecrawl API token from environment variable
86
87 // Call Firecrawl API
88 const response = await fetch("https://api.firecrawl.dev/v1/scrape", {
89 method: "POST",
90 headers: {
110 const errorText = await response.text();
111 console.error(`Firecrawl API error: ${response.status} ${errorText}`);
112 return c.text(`Failed to fetch content: ${response.status}`, 500);
113 }
114
208 <body>
209 <h1>URL to Markdown API</h1>
210 <p>This API fetches content from a URL and returns it as markdown.</p>
211
212 <div class="tools-nav">
242
243// This is the entry point for HTTP vals
244export default app.fetch;

gptToolsreadmeGPT3 matches

@nbbaier•Updated 1 week ago
1import { type WriterOptions } from "./WriterOptions";
2import { fetch } from "https://esm.town/v/std/fetch?v=4";
3import OpenAI, { type ClientOptions } from "npm:openai";
4
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: {

gptToolsdraftReadme3 matches

@nbbaier•Updated 1 week ago
1import { fetch } from "https://esm.town/v/std/fetch?v=4";
2import OpenAI, { type ClientOptions } from "npm:openai";
3
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: {

openaiPricingfetchAndStoreOpenAiUsage5 matches

@nbbaier•Updated 1 week ago
1import { createDayTotal } from "./createDayTotal";
2import { fetchOpenAiUsageData } from "./fetchOpenAiUsageData";
3import { updateBlobUsageDB } from "./updateBlobUsageDB";
4import { fetch } from "https://esm.town/v/std/fetch";
5import { set } from "https://esm.town/v/std/set?v=11";
6import { DateTime } from "npm:luxon";
7
8const fetchAndStoreOpenAiUsage = async () => {
9 const timeZone = "America/Chicago";
10 const date = DateTime.now();
14
15 try {
16 const { data, whisper_api_data, dalle_api_data } = await fetchOpenAiUsageData("2024-04-01");
17 console.log(data.length);
18 console.log(whisper_api_data.length);
28};
29
30await fetchAndStoreOpenAiUsage();

openaiPricingfetchOpenAiUsageData5 matches

@nbbaier•Updated 1 week ago
1import { fetch } from "https://esm.town/v/std/fetch?v=4";
2
3const fetchOpenAiUsageData = async (today: string) => {
4 const response = await fetch(
5 `https://api.openai.com/v1/usage?date=${today}`,
6 {
13
14 if (!response.ok) {
15 throw new Error("Failed to fetch openAI usage data.");
16 }
17
19};
20
21export { fetchOpenAiUsageData };

openaiPricingfetchAndStoreOpenAiUsage25 matches

@nbbaier•Updated 1 week ago
1import { createDayTotal } from "./createDayTotal";
2import { cronEvalLogger as logger } from "https://esm.town/v/nbbaier/cronLogger";
3import { fetchOpenAiUsageData } from "./fetchOpenAiUsageData";
4import { updateBlobUsageDB } from "./updateBlobUsageDB";
5import { blob } from "https://esm.town/v/std/blob?v=11";
6import { fetch } from "https://esm.town/v/std/fetch";
7import { DateTime } from "npm:luxon";
8
9const fetchAndStoreOpenAiUsage = async (interval: Interval) => {
10 const timeZone = "America/Chicago";
11 const date = DateTime.now();
15
16 try {
17 const { data, whisper_api_data, dalle_api_data } = await fetchOpenAiUsageData(today);
18
19 const day_total = await createDayTotal(data, whisper_api_data, dalle_api_data);
27};
28
29export default logger(fetchAndStoreOpenAiUsage);

openaiPricingdeftAmberSwallow2 matches

@nbbaier•Updated 1 week ago
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=45";
2
3type Model = {
36};
37
38const modelResults = await fetchJSON(
39 "https://raw.githubusercontent.com/BerriAI/litellm/refs/heads/main/model_prices_and_context_window.json",
40) as { [key: string]: Model };

fetchPaginatedData2 file matches

@nbbaier•Updated 1 week ago

tweetFetcher2 file matches

@nbbaier•Updated 1 week ago