Google Sheets API examples & templates
Use these vals as a playground to view and fork Google Sheets API examples and templates on Val Town. Run any example below or find templates that can be used as a pre-built solution.
gsheet_call
@mattx
Script
gsheet_call Wrapper around Google Sheets API v4. Parameters service_account: JSON string containing Google Service Account key sheet_id: Google Sheet ID method: HTTP method to use action: Full URL with https://sheets.googleapis.com/v4/spreadsheets/{spreadsheetId}/ removed data: HTTP request body Requirements a Google Cloud service account the Google Sheets API v4 enabled in your Google Cloud project the spreadsheet ID (provide it in the sheet_id parameter) Instructions Share the spreadsheet with the service account Make a JSON key for the service account, then set it as a secret. Use the secret for the service_account parameter. Figure out the action you want to perform. You will need to provide everything that comes after {spreadsheetId}/ as the action parameter. For example: values/A1:C1:append?valueInputOption=RAW Figure out the request body. For example: {values: [["foo", "bar", "baz"]]}
SidebarToArchive
@yawnxyz
HTTP (deprecated)
Sidebar.io Archiver Sidebar's been one of my biggest design resources for the last decade. Since sidebar.io's break announcement this morning (https://sidebar.io/break/) I've set out to mess around with using Val.town to archive sidebar.
The Google Sheet can be found here: https://docs.google.com/spreadsheets/d/1RghvMfPTR5xvHMAk1pKYuH2pFYYKOJ6bH0LLkHNZiuc/edit?usp=sharing Initially I was just piping data to Google Sheets but that's slow, wasteful and kind of dumb... instead I just wrapped Hono around the code to provide a download the CSV to browser.
stockPrice
@stevekrouse
HTTP (deprecated)
Current Stock Price This val was designed to be used in Google Sheets, particularly because Google Finance stopped supporting Spotify inexplicably. Usage Copy and paste this into Google Sheets: =IMPORTDATA(CONCATENATE("https://stevekrouse-stockprice.web.val.run/?simple=1&symbol=","SPOT")) Replace "SPOT" with the symbol you want API This val currently uses Alpha Vantage's free plan (5 requests per minute & 500 per day). You can sign up for your own API Key here: https://www.alphavantage.co/support/#api-key
ai
@yawnxyz
HTTP (deprecated)
An http and class wrapper for Vercel's AI SDK Usage: Groq: https://yawnxyz-ai.web.val.run/generate?prompt="tell me a beer joke"&provider=groq&model=llama3-8b-8192 Perplexity: https://yawnxyz-ai.web.val.run/generate?prompt="what's the latest phage directory capsid & tail article about?"&provider=perplexity Mistral: https://yawnxyz-ai.web.val.run/generate?prompt="tell me a joke?"&provider=mistral&model="mistral-small-latest" async function calculateEmbeddings(text) {
const url = `https://yawnxyz-ai.web.val.run/generate?embed=true&value=${encodeURIComponent(text)}`;
try {
const response = await fetch(url);
const data = await response.json();
return data;
} catch (error) {
console.error('Error calculating embeddings:', error);
return null;
}
}
ideas
@stevekrouse
HTTP (deprecated)
Request for vals Here's my personal list of things I want to see on Val Town. I may build them myself at some point, but to the glory goes the person who builds it first. If you want to collaborate or get clarification on any of these ideas, please drop me a comment or reach out on discord. Status Page Possibly the singular most popular thing to do on Val Town is to build a downtime detector for your website. This one from @healeycodes is super popular as well as this fork by @andreterron . Sites like cronitor do this and also seamlessly provide a status page as well, for example like this one: https://status.val.town/. It would be awesome if we built a fork of these downtime detectors that also stored historical uptime/downtime (and possibly latency) information in sqlite, and then provided an http interface to view the data as well. Free Stock API Proxy I have been working on a stock price api tool, initially for use within Google Sheets: https://www.val.town/v/stevekrouse/stockPrice It would be awesome to expand this to also be useful to other folks, ie folks within Val Town. For example, it could be used to build stock price trackers. Our BTC price tracker is pretty popular. I think one for stocks would be similarly popular, but it'd need someone to provide a good free stock API. Maybe one exists or maybe we need to proxy it.