Air quality API examples & templates
Use these vals as a playground to view and fork Air quality API examples and templates on Val Town. Run any example below or find templates that can be used as a pre-built solution.
decepulis
MuxAITranscript
HTTP
Generate CuePoints and transcripts for your Mux video Adapted from the blog post, Build an AI-powered interactive video transcript with Mux Player CuePoints This Val exposes an HTTP endpoint that takes a Mux Asset ID and a list of speakers and Uses Mux's auto-generated captions to generate a CuePoints object for Mux Player Uses AssemblyAI for speaker labeling (diarization) Uses GPT-4o to format text Fork it and use it as a foundation for your own interactive video transcript project. Usage: Required environment variables: Mux Access token details ( MUX_TOKEN_ID , MUX_TOKEN_SECRET ) This endpoint requires an existing Mux asset that's ready with an audio-only static rendition associated with it. You can run this val to create a new one for testing. AssemblyAI API key ( ASSEMBLYAI_API_KEY ). Get it from their dashboard here OpenAI API key ( OPENAI_API_KEY ). Get it from their dashboard here Make a POST request to the Val's endpoint with the following body, replacing the values with your own asset ID and the list of speakers. Speakers are listed in order of appearance. {
"asset_id": "00OZ8VnQ01wDNQDdI8Qw3kf01FkGTtkMq2CW901ltq64Jyc",
"speakers": ["Matt", "Nick"]
} Limitations This is just a demo, so it's obviously not battle hardened. The biggest issue is that it does this whole process synchronously, so if the any step takes longer than the Val's timeout, you're hosed.
0
stevekrouse
cerebras_searcher
HTTP
Cerebras Searcher a Perplexity clone that uses the SerpAPI to do RAG
and summaries with Cerebras ( requires a SerpAPI key ) This val might not be working because we're out of SerpAPI credits,
but if you fork it and get your own SerpAPI key, it should work. Comment on this
val if you still have trouble, thanks! Setup Fork this val Sign up for Cerebras and get an API key Save it in a Val Town environment variable called CEREBRAS_API_KEY Get a SerpAPI key (free trial available) Set your SerpAPI API key into you Val Town Environment Variables Done!
3
yieldray
decorator_router
Script
Decorator Router Fair simple decorator based router, with GET/POST and middleware support. demo live demo: https://yieldray-decorator_router_demo.web.val.run/ import { get, post, all, use, registered, handler, type Context } from "https://esm.town/v/yieldray/decorator_router";
import { parseBearerAuth, transformResponse } from "https://esm.sh/serve-router@1.1.0/utils";
interface User {
id: number;
name: string;
}
const users: User[] = [
{ id: 0, name: "Alice" },
{ id: 1, name: "Ray" },
];
class _Server {
/**
* Decorator @get: Parses URLSearchParams into an object as the first parameter.
*/
@get("/users")
getAllUsers() {
return users; // Automatically wrapped in a Response.json
}
@get("/getUserByName") // GET /getUserByName?name=Alice
getUserByName({ name }: Record<string, string>) {
const user = users.find((u) => u.name === name);
if (user) {
return user; // Automatically wrapped as Response.json(user)
}
// Optionally, manually return a Response object
return Response.json({ error: "not found" }, { status: 404 });
}
@get("/user/:id") // GET /user/123
user(_: unknown, { params: { id } }: Context) {
return users.find((u) => u.id === Number(id));
}
/**
* Decorator @post: Parses the request body into an object as the first parameter.
*/
@post("/user") // POST /user
async createUser(user: User) {
if (users.find((u) => u.id === user.id)) {
return { error: "already exists!" };
}
await users.push(user); // Assume insertion into a database
return { ok: true, users };
}
@post("/user/:id") // POST /user/123
async updateUser(user: User, { params: { id }, request }: Context) {
const token = parseBearerAuth(request.headers.get("Authorization")!);
// Additional logic here...
}
@all("/")
home({ request }: { request: Request }) {
return {
registered,
method: request.method,
url: request.url,
headers: Object.fromEntries(request.headers.entries()),
};
}
@use("/*")
async corsMiddleware({ next, request }: Context) {
const resp = await next();
return transformResponse(resp, {
headers: {
"Access-Control-Allow-Origin": request.headers.get("origin") || "*",
},
});
}
}
// For Deno:
Deno.serve(handler);
// For val.town:
export default handler;
0
ejfox
inventory
HTTP
* This val creates an interactive tech stack wizard that generates a video game-style inventory screen.
* It uses React for the UI, leverages emoji and Unicode symbols for a visually rich experience, and
* incorporates Tailwind CSS for elegant, grayscale styling.
* The wizard allows users to select tools, libraries, and APIs, then displays them in a shareable format.
0