Search
JokeGenerator
@charmaine
Joke Generator Returns a random joke from https://official-joke-api.appspot.com/random_joke Example:
HTTP
export default async function(req: Request) {
// Return a random joke with API
const response = await fetch("https://official-joke-api.appspot.com/random_joke");
BrowserbaseFetcherFromURL
@willthereader
// 1st stable version is v13
HTTP
const BROWSERBASE_API_KEY = Deno.env.get("BROWSERBASE_API_KEY");
const TIMEOUT = 30000; // 30 seconds timeout
export default async function server(request: Request): Promise<Response> {
// Array of URLs to scrape
const urls = [
classicIvoryFrog
@apulza
// Fetches a random joke.
Script
// ... imports ...
// Fetches a random joke.
async function fetchRandomJoke() {
const response = await fetch(
"https://official-joke-api.appspot.com/random_joke",

vtTokenSessionAuthSafe
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
Script
export function vtTokenSessionAuth(handler) {
return async function(req: Request) {
const { passwordAuth } = await import("https://esm.town/v/stevekrouse/vtTokenSessionAuth");
const { verifyToken } = await import("https://esm.town/v/pomdtr/verifyToken?v=1");

httpNull
@augustohp
// For debugging/inspecting webhooks requests ...
Script
// For debugging/inspecting webhooks requests ...
export async function httpNull(req: express.Request, res: express.Response) {
res.end("Success");

buildDoeMenuCalendar
@tal
An interactive, runnable TypeScript val by tal
Script
type Line = Parameters<typeof calendarItemForLine>[1];
type Context = Parameters<typeof calendarItemForLine>[0];
export async function buildDoeMenuCalendar(context: Context, storeValue) {
const ical = await import("npm:ical-generator");
let dailyOfferings: Line | undefined;
squareroot
@gueejla
Get the square root of any number! React formatting borrowed from https://www.val.town/v/jdan/infoboxCrawler and https://www.val.town/v/roramigator/focusForestApp
HTTP
import { sillyCSS } from "https://esm.town/v/gueejla/sillyCSS";
function App() {
// Calculate square root from url parameter "inputNum"
</div>
function quickMath() {
const url = new URL(window.location.href);
return [inputNum, sqrtNum, result];
function showMath(inputNum, sqrtNum) {
const canvasRef = useRef(null);
return canvasRef;
function drawLine(ctx, startX, startY, endX, endY) {
ctx.beginPath();
ctx.stroke();
function client() {
createRoot(document.getElementById("root")).render(<App />);
client();
function server(req: Request): Promise<Response> {
return new Response(
brilliantCoralCockroach
@dmaretskyi
An interactive, runnable TypeScript val by dmaretskyi
HTTP
export default async function(req: Request): Promise<Response> {
return Response.json({ ok: true });

redditNew
@alexdmejias
An interactive, runnable TypeScript val by alexdmejias
Script
return fetchJSON(
`https://www.reddit.com/r/astoria.json`,
export default async function server(req: Request) {
const a = await redditNew({ r: "astoria" });
console.log("wasd");

pipedream
@stevekrouse
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!
Script
Pipedream offers an Accounts API to handle OAuth for you, automatically, and for free. [How to do it is covered in this guide](https://docs.val.town/integrations/google-sheets/#use-pipedreams-accounts-api).
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:
```ts
const calendar = await pipeDreamGoogle("calendar", accountId);
// Function to get free/busy information
async function getFreeBusyTimes(calendarId: string) {
const now = new Date();
import { google } from "npm:googleapis";
export async function getAccessToken(accountId: string, bearer = Deno.env.get("pipedream")) {
const response = await fetchJSON(
return response.data.credentials.oauth_access_token;
export function googleService(service: string, accessToken: string) {
return google[service]({
Authorization: `Bearer ${accessToken}`,
export async function pipeDreamGoogle(service: string, accountId: string, bearer = Deno.env.get("pipedream")) {
const accessToken = await getAccessToken(accountId, bearer);
valle_tmp_60810043295012031222118327195818
@janpaul123
An interactive, runnable TypeScript val by janpaul123
HTTP
export default async function(req: Request): Promise<Response> {
const html = `
<!DOCTYPE html>
fetchIpfsPosts
@stevedylandev
An interactive, runnable TypeScript val by stevedylandev
Script
let endDate = Math.floor(currentDate.getTime() / 1000);
let startDate = Math.floor(currentDate.setDate(currentDate.getDate() - 7) / 1000);
export async function fetchIPFSPosts() {
try {
const soRes = await fetch(
accomplishedBeigeGuineafowl
@kakomam
// Sends an email with the joke.
Script
async function fetchRandomJoke() {
const response = fetch(
"https://official-joke-api.appspot.com/random_joke",