Back to APIs list
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.
pipedream
@stevekrouse
Script
Pipedream helpers Pipedream offers an Accounts API to handle OAuth for you, automatically, and for free. How to do it is covered in this guide . The helper functions below can make it easier to work with various Google API. For example, I used them like so to get all my free/busy times for this week from all my google calendars: import { pipeDreamGoogle } from "https://esm.town/v/stevekrouse/pipedream";
const accountId = "REPLACE_WITH_YOUR_GCAL_ACCOUNT_ID_FROM_PIPEDREAM";
const calendar = await pipeDreamGoogle("calendar", accountId);
// Function to get free/busy information
async function getFreeBusyTimes(calendarId: string) {
const now = new Date();
const startOfWeek = new Date(now);
startOfWeek.setDate(now.getDate() - now.getDay());
const endOfWeek = new Date(startOfWeek);
endOfWeek.setDate(startOfWeek.getDate() + 6);
const requestBody = {
timeMin: startOfWeek.toISOString(),
timeMax: endOfWeek.toISOString(),
items: [{ id: calendarId }],
};
const freeBusyResponse = await calendar.freebusy.query({
requestBody,
});
return freeBusyResponse.data.calendars[calendarId].busy;
}
const calendars = (await calendar.calendarList.list()).data.items;
const freeBusy = await Promise.all(calendars.map(calendar => getFreeBusyTimes(calendar.id)));
console.log(freeBusy); In order for this to work you need to follow the instructions in this guide to save your pipedream API key into your Val Town Environment Variables under pipedream , then connect the google account you care about to Pipedream, and copy it's Pipedream "account id" into your val code. Let me know if you need any help by commenting on this val!
indirection
@jxnblk
HTTP (preview)
A game of riddles to play with your friends How to play To start a game, choose a 3-20 letter word. The game generates a riddle based on your word. Copy the link to share with your friends to see if they can guess the word. If they guess the word correctly, they get to pick a new word and can send you a new clue back. If they guess wrong, the next riddle is based on the word they guessed You can play with 2 or as many people as you want.
You can follow a long chain, like the game Telephone or games can branch with multiple players. TODO [ ] Reload after updating the URL to support native share sheets [ ] Incorrect state / helpers [x] Trim and lowercase guesses
sqliteExplorerApp
@nbbaier
HTTP
SQLite Explorer View and interact with your Val Town SQLite data. It's based off Steve's excellent SQLite Admin val, adding the ability to run SQLite queries directly in the interface. This new version has a revised UI and that's heavily inspired by LibSQL Studio by invisal . This is now more an SPA, with tables, queries and results showing up on the same page. Install Install the latest stable version (v86) by forking this val: Authentication Login to your SQLite Explorer with password authentication with your Val Town API Token as the password. Todos / Plans [ ] improve error handling [ ] improve table formatting [ ] sticky table headers [x] add codemirror [ ] add loading indication to the run button (initial version shipped) [ ] add ability to favorite queries [ ] add saving of last query run for a table (started) [ ] add visible output for non-query statements [ ] add schema viewing [ ] add refresh to table list sidebar after CREATE/DROP/ALTER statements [ ] add automatic execution of initial select query on double click [x] add views to the sidebar [ ] add triggers to sidebar [ ] add upload from SQL, CSV and JSON [ ] add ability to connect to a non-val town Turso database [x] fix wonky sidebar separator height problem (thanks to @stevekrouse) [x] make result tables scrollable [x] add export to CSV, and JSON (CSV and JSON helper functions written in this val . Thanks to @pomdtr for merging the initial version!) [x] add listener for cmd+enter to submit query