Back to APIs list

Airtable API examples & templates

Use these vals as a playground to view and fork Airtable API examples and templates on Val Town. Run any example below or find templates that can be used as a pre-built solution.
iamseeley avatar
iamseeley
valTownUser
Script
👤 valTownUser The valTownUser object provides a convenient interface to interact with Val Town's API and access user-specific information and functionalities. User Information getUserInfo() Fetches and caches the user's information. Use case: Retrieving all user details at once. import { valTownUser } from "https://esm.town/v/iamseeley/valTownUser"; export const getUserInfo = () => valTownUser.getUserInfo(); // Example usage: const userInfo = await getUserInfo(); console.log('User Information:', userInfo); // You can also destructure specific properties you need: const { username, id, email, tier } = await getUserInfo(); console.log(`Username: ${username}`); console.log(`User ID: ${id}`); console.log(`Email: ${email}`); console.log(`Account Tier: ${tier}`); getUsername() Retrieves the user's username. Use case: Displaying the current user's name in a val. import { valTownUser } from "https://esm.town/v/iamseeley/valTownUser"; export const getUsername = () => valTownUser.getUsername(); // Example usage: const username = await getUsername(); console.log(`Current user: ${username}`); getId() Retrieves the user's ID. Use case: Using the user ID for database queries or API calls. import { valTownUser } from "https://esm.town/v/iamseeley/valTownUser"; export const getId = () => valTownUser.getId(); // Example usage: const userId = await getId(); console.log(`User ID: ${userId}`); getBio() Retrieves the user's biography. Use case: Displaying the user's bio on a profile page. import { valTownUser } from "https://esm.town/v/iamseeley/valTownUser"; export const getBio = () => valTownUser.getBio(); // Example usage: const bio = await getBio(); console.log(`User bio: ${bio || 'Not set'}`); getProfileImageUrl() Retrieves the URL of the user's profile image. Use case: Showing the user's avatar in a val. import { valTownUser } from "https://esm.town/v/iamseeley/valTownUser"; export const getProfileImageUrl = () => valTownUser.getProfileImageUrl(); // Example usage: const profileImageUrl = await getProfileImageUrl(); console.log(`Profile image URL: ${profileImageUrl || 'Not set'}`); getEmail() Retrieves the user's email address. Use case: Sending notifications or verifications. import { valTownUser } from "https://esm.town/v/iamseeley/valTownUser"; export const getEmail = () => valTownUser.getEmail(); // Example usage: const email = await getEmail(); console.log(`User email: ${email}`); getTier() Retrieves the user's account tier. Use case: Implementing tier-specific features. import { valTownUser } from "https://esm.town/v/iamseeley/valTownUser"; export const getTier = () => valTownUser.getTier(); // Example usage: const tier = await getTier(); console.log(`User tier: ${tier}`); URL Generation getEndpointUrl(valName) Generates the endpoint URL for a specified val. Use case: Creating links to val endpoints in your application. import { valTownUser } from "https://esm.town/v/iamseeley/valTownUser"; export const getEndpointUrl = (valName: string) => valTownUser.getEndpointUrl(valName); // Example usage: const endpointUrl = await getEndpointUrl('mySitesServer'); console.log(`Endpoint URL: ${endpointUrl}`); getValUrl(valName) Generates the Val Town URL for a specified val. Use case: Creating links to val pages in Val Town. import { valTownUser } from "https://esm.town/v/iamseeley/valTownUser"; export const getValUrl = (valName: string) => valTownUser.getValUrl(valName); // Example usage: const valUrl = await getValUrl('myVal'); console.log(`Val URL: ${valUrl}`); User Activity getLikedVals(options) Retrieves the vals liked by the user. Use case: Displaying a list of the user's favorite vals. import { valTownUser } from "https://esm.town/v/iamseeley/valTownUser"; export const getLikedVals = (options = {}) => valTownUser.getLikedVals(options); // Example usage: const likedVals = await getLikedVals({ limit: 5 }); console.log('Liked vals:', likedVals.data); getComments(options) Retrieves comments related to the user. Use case: Showing a user's comment history. import { valTownUser } from "https://esm.town/v/iamseeley/valTownUser"; export const getComments = (options = {}) => valTownUser.getComments(options); // Example usage: const comments = await getComments({ limit: 10, relationship: 'given' }); console.log('User comments:', comments.data); getReferences(options) Retrieves references to the user's vals. Use case: Tracking how often a user's vals are used by others. import { valTownUser } from "https://esm.town/v/iamseeley/valTownUser"; export const getReferences = (options = {}) => valTownUser.getReferences(options); // Example usage: const references = await getReferences({ limit: 5 }); console.log('Val references:', references.data); Blob Management listBlobs(prefix) Lists the user's blobs. Use case: Displaying a file manager for the user's stored data. import { valTownUser } from "https://esm.town/v/iamseeley/valTownUser"; export const listBlobs = (prefix?: string) => valTownUser.listBlobs(prefix); // Example usage: const blobs = await listBlobs(); console.log('User blobs:', blobs); storeBlob(key, data) Stores a new blob or updates an existing one. Use case: Uploading user files or storing large datasets. import { valTownUser } from "https://esm.town/v/iamseeley/valTownUser"; export const storeBlob = (key: string, data: any) => valTownUser.storeBlob(key, data); // Example usage: await storeBlob('myFile.txt', 'Hello, World!'); console.log('Blob stored successfully'); getBlob(key) Retrieves a specific blob. Use case: Downloading a user's stored file. import { valTownUser } from "https://esm.town/v/iamseeley/valTownUser"; export const getBlob = async (key: string) => { const blobData = await valTownUser.getBlob(key); return new TextDecoder().decode(new Uint8Array(blobData)); }; // Example usage: const blobContent = await getBlob('myFile.txt'); console.log('Blob content:', blobContent); deleteBlob(key) Deletes a specific blob. Use case: Removing old or unnecessary files. import { valTownUser } from "https://esm.town/v/iamseeley/valTownUser"; export const deleteBlob = (key: string) => valTownUser.deleteBlob(key); // Example usage: await deleteBlob('myFile.txt'); console.log('Blob deleted successfully'); Val Management listVals(options) Lists the user's vals. Use case: Displaying a dashboard of the user's created vals. import { valTownUser } from "https://esm.town/v/iamseeley/valTownUser"; export const listVals = (options = {}) => valTownUser.listVals(options); // Example usage: const userVals = await listVals({ limit: 5 }); console.log('User vals:', userVals.data); createVal(valInfo) Creates a new val. Use case: Programmatically creating vals based on user input. import { valTownUser } from "https://esm.town/v/iamseeley/valTownUser"; export const createVal = (valInfo: any) => valTownUser.createVal(valInfo); // Example usage: const newVal = await createVal({ name: 'myNewVal', code: 'console.log("Hello, World!");' }); console.log('Created val:', newVal); updateVal(valId, updates) Updates an existing val. Use case: Implementing an "edit val" feature in your application. deleteVal(valId) Deletes a specific val. Use case: Allowing users to remove their vals through your interface. SQLite Database Operations executeSqlite(statement) Executes a SQLite statement. Use case: Running custom queries on the user's database. listTables() Lists all tables in the user's SQLite database. Use case: Displaying the structure of a user's database. getTableSchema(tableName) Retrieves the schema of a specific table. Use case: Showing the structure of a particular table. getTableContent(tableName, limit) Retrieves the content of a specific table. Use case: Displaying the data stored in a user's table.
3
yawnxyz avatar
yawnxyz
luciaValtownSqlite
Script
A reorganization of: https://www.val.town/v/stevekrouse/lucia_adapter https://esm.town/v/stevekrouse/lucia_adapter_base
1
yawnxyz avatar
yawnxyz
lucia_sqlite
Script
Forked from stevekrouse/lucia_sqlite
0
stevekrouse avatar
stevekrouse
populateTwitterDB
Script
Poll Twitter & Populate SQlite database The twitter API (or in this case someone else's wrapper over the twitter API) is finicky, so we just try to get one handle per minute, and shove whatever we get into our database, which could be an error message (this is why handles don't have a unique index).
0
stevekrouse avatar
stevekrouse
getShowcaseVals
Script
Get vals that were created in the last month, augmented with all sorts of AI and screenshots, and shoved in a sqlite database for @stevekrouse/showcase.
1
stevekrouse avatar
stevekrouse
lucia_sqlite
Script
Forked from pomdtr/lucia_sqlite
1
byjonathanleung avatar
byjonathanleung
csvToArray
Script
// https://www.30secondsofcode.org/js/s/csv-to-array
0
rodrigotello avatar
rodrigotello
valTownInspoList
Script
Val Town inspiration & use cases list List [as object] used in Val Town's use cases and inspiration. Check it out at in /examples/use-cases and /docs/tutorial/4
1
dthyresson avatar
dthyresson
whatsThatInHotDogs
HTTP
What's that in Hot Dogs? Inspired by the 2014 Boston Baseball Hackday submission, this val shows how many hot dogs a baseball player can buy in a year based on his annual salary and the average price of a hot dog sold at their home team's stadium. Back then, the team spent most of the hackday time collecting data, building s javascript app from scratch and then deployed to Heroku. It took some time. It had much nicer design, artwork, styling, etc to be sure. I wanted to see how quickly a similar app could be created and made available on Val.town 10 years later. I asked Chat GPT to build the app: You are a javascript web developer and a baseball fan. Build a web app using Hono called "What's that in hot dogs?". The app should let you select a baseball player. Based on 1) the player annual salary calculate the number of hot dogs they could buy based on the average price of a hot dog sold at their stadium. For example, Mike Trout played for the Los Angeles Angels and makes $35M per year. The Los Angeles Angels play at Angel Stadium a hot dog costs $8. That means he can buy 35,000,000/8 = 4.375M hot dogs. The app lets you pick a player and then will display an emoji icon of a hot dog. One emoji hot dog is worth 100,000 hot dogs. So picking Mike Trout will show 43.75 (or 44) hot dog icons. It worked! But, it only had one player's worth of data. The app needs more player salary and hot dog price data. Find the top players in each MLB team, their salary, and the price of a hot dog at their home stadium. I then asked for a small improvement: Improve the app by also showing the team the play plays for, the stadium, salary and price of the hot dog. Include it in a nice table below the hot dog emoji list. Within 10 minutes, I had a working "What's that in Hot Dogs?". I then re-worked the headings and added a legend and it matched what I remember seeing back in 2014 ... but built and deployed in minutes versus hours. Note: Much of the 2014 team's time was spent collecting data manually by looking up players' salaries and finding the cost of a hot dog at stadiums. In this example, I've not validated that ChaptGPT correctly identified these figures.
0
stevekrouse avatar
stevekrouse
postgresExample
Script
// Get the connection string from the environment variable "DATABASE_URL"
0
postpostscript avatar
postpostscript
sqliteExplorerApp
HTTP
Forked from nbbaier/sqliteExplorerApp
0
applemetabank avatar
applemetabank
billGeneratorWebApp
HTTP
@jsxImportSource https://esm.sh/react@18.2.0
0
joseph_c100 avatar
joseph_c100
smallboatsapi
HTTP
An API that fetches the html table of small boat arrivals data from the UK gov website. This data is from the last 7 days and updated daily.
0
adjacent avatar
adjacent
kalshi
HTTP
Forked from lucaskohorst/kalshi
0
benvinegar avatar
benvinegar
counterscaleWeeklyReport
Cron
// borrowed from: https://github.com/benvinegar/counterscale/blob/main/app/analytics/query.ts#L24
1
petermillspaugh avatar
petermillspaugh
june2024
Script
@jsxImportSource https://esm.sh/preact
0