renderPoemWidgetJsonmain.tsx2 matches
13timeZone,
14};
15const timeForApi = date.toLocaleTimeString("en-GB", {
16...baseTimeParams,
17hourCycle: "h23",
18});
19const poem = await getPoemForTime(timeForApi);
20const newState = { ...poemWidgetJson };
21newState.layouts.hello_small.layers[0].rows[0].cells[0].text.string = poem;
1This Val accepts a stock symbol and will return current price and intraday price change.
23example: `https://pete-stockapi.web.val.run/symbol=MSFT`
45It's currently using alphavantage free tier API so it's limited to only 25 requests/day. Fork and create your own premium API key for more request.
1// This val creates a publicly accessible kitten image generator using the Val Town image generation API.
2// It supports generating square images with a single dimension parameter or rectangular images with two dimension parameters.
3
FanFicScrapermain.tsx19 matches
11e.preventDefault();
12setLoading(true);
13console.log(`Submitting URL for scraping: ${url}`);
14try {
15const response = await fetch("/scrape", {
22setResult(data);
23} catch (error) {
24console.log(`Error occurred while scraping URL: ${url}. Error details: ${error.message}`);
25setResult({ error: error.message });
26}
40/>
41<button type="submit" disabled={loading}>
42{loading ? "Scraping..." : "Scrape"}
43</button>
44</form>
79async function scrapePage(url) {
80console.log(`Starting to scrape page: ${url}`);
81const apiKey = Deno.env.get("ScrapingBeeAPIkey");
82if (!apiKey) {
83console.log("ScrapingBee API key not found in environment variables");
84throw new Error("ScrapingBee API key not found in environment variables");
85}
86104};
105106console.log(`Sending request to ScrapingBee for URL: ${url} at ${new Date().toISOString()}`);
107const startTime = Date.now();
108try {
109const response = await fetch(
110`https://app.scrapingbee.com/api/v1/?api_key=${apiKey}&url=${
111encodeURIComponent(url)
112}&render_js=false&extract_rules=${encodeURIComponent(JSON.stringify(extractRules))}`,
114115const duration = Date.now() - startTime;
116console.log(`Received response from ScrapingBee at ${new Date().toISOString()}. Duration: ${duration}ms`);
117console.log(`Received response from ScrapingBee for URL: ${url}. Status: ${response.status}`);
118119if (!response.ok) {
120console.log(`Error response from ScrapingBee. Status: ${response.status}`);
121throw new Error(`HTTP error! status: ${response.status}`);
122}
156return result;
157} catch (error) {
158console.log(`Error occurred while scraping URL: ${url}`);
159console.log(`Error details: ${error.message}`);
160console.log(`Error stack: ${error.stack}`);
163}
164165async function getApiKey() {
166const apiKey = Deno.env.get("ScrapingBeeAPIkey");
167if (!apiKey) {
168console.log("ScrapingBee API key not found in environment variables");
169throw new Error("ScrapingBee API key not found in environment variables");
170}
171return apiKey;
172}
173
getBlobAndRenderAsImageREADME.md4 matches
89To easily upload an image to your blob storage, [fork this val](
10getBlobAndRenderAsImage), run it, and enter your API key in the password input.
1112## How it works
2122- The server function calls `blob.get("test.png")`.
23- This `blob.get()` method makes an HTTP request to the Val Town API.
24- The API returns a Response object containing the image data.
25266465- [Blob storage overview in Val Town docs](https://docs.val.town/std/blob/)
66- [Val Town REST API references for blobs](https://docs.val.town/openapi#tag/blobs)
67- [Val Town blob std lib source code](https://www.val.town/v/std/blob)
blob_adminREADME.md1 match
9[](https://www.val.town/v/stevekrouse/blob_admin_app/fork)
1011It uses [basic authentication](https://www.val.town/v/pomdtr/basicAuth) with your [Val Town API Token](https://www.val.town/settings/api) as the password (leave the username field blank).
1213# TODO
891. Click `Fork`
102. Change `location` (Line 4) to describe your location. It accepts fairly flexible English descriptions which it turns into locations via [nominatim's geocoder API](https://www.val.town/v/stevekrouse/nominatimSearch).
113. Click `Run`
12
redditSearchmain.tsx5 matches
11interface RedditSearchOptions {
12query: string;
13apiKey?: string;
14}
1517export async function redditSearch({
18query,
19apiKey = Deno.env.get("BROWSERBASE_API_KEY"),
20}: RedditSearchOptions): Promise<ThreadResult[]> {
21if (!apiKey) {
22throw new Error("BrowserBase API key is required");
23}
2425const puppeteer = new PuppeteerDeno({ productName: "chrome" });
26const browser = await puppeteer.connect({
27browserWSEndpoint: `wss://connect.browserbase.com?apiKey=${apiKey}&enableProxy=true`,
28ignoreHTTPSErrors: true,
29});
ablePinkDogREADME.md1 match
19```
2021If you want to use an [api token](https://www.val.town/settings/api) to authenticate:
2223```ts
harshAquamarineRoostermain.tsx4 matches
1import { API_URL } from "https://esm.town/v/std/API_URL";
2import { LibsqlError, type ResultSet, type Row, type TransactionMode } from "npm:@libsql/client";
3import { z } from "npm:zod";
3536async function execute(statement: InStatement, args?: InArgs): Promise<ResultSet> {
37const res = await fetch(`${API_URL}/v1/sqlite/execute`, {
38method: "POST",
39headers: {
5051async function batch(statements: InStatement[], mode?: TransactionMode): Promise<ResultSet[]> {
52const res = await fetch(`${API_URL}/v1/sqlite/batch`, {
53method: "POST",
54headers: {
7879/* Val Town's Turso Proxy returns rows as an array of values
80* Yet the LibSQL API has a Row type which behave as an array or object,
81* ie you can access it via numerical index or string
82*/