Query Data
Query your stored videos, images, and other data using a type-safe query builder.
Basic Queries
Section titled “Basic Queries”Query videos and images with the built-in convenience methods:
import { createClient } from "zapdos-js";
const client = createClient({ apiKey: process.env.ZAPDOS_API_KEY,});
// Get all videosconst videos = await client.videos().fetch();
// Get all imagesconst images = await client.images().fetch();
// Get background jobsconst jobs = await client.jobs().fetch();
// Get scenes for a specific videoconst scenes = await client.scenes("video-object-id").fetch();
Custom Queries
Section titled “Custom Queries”Build custom queries with the query builder:
// Query with filtersconst result = await client .from("object_storage") .select("id", "metadata", "created_at") .where("metadata->>'content_type'", "~", "^video/") .where("metadata->>'size'", ">", "1000000") .limit(10) .fetch();
if (result.data) { result.data.forEach((item) => { console.log(item.id, item.metadata); });}
Query Builder Methods
Section titled “Query Builder Methods”Chain methods to build complex queries:
const result = await client .from("object_storage") .select("id", "metadata", "created_at") .where("field", "operator", "value") .sort("desc") // or "asc" .limit(20) .cursor("pagination-cursor") // for pagination .fetch();
Available Operators
Section titled “Available Operators”=
— equals!=
— not equals>
— greater than<
— less than>=
— greater than or equal<=
— less than or equalLIKE
— SQL LIKE (case-sensitive)ILIKE
— SQL ILIKE (case-insensitive)~
— regex match!~
— regex not matchIS
— for NULL checks onlyIS NOT
— for NOT NULL checks only@>
— array contains (JSON/array fields)
JSON Queries
Section titled “JSON Queries”Query JSON metadata fields:
// Check content type.where("metadata->>'content_type'", "=", "video/mp4")
// Check numeric values.where("metadata->>'size'", ">", "5000000")
// Check arrays (parents).where("metadata->'parents'", "@>", '["parent-id"]')
Single Results
Section titled “Single Results”Get exactly one result:
const video = await client.videos().limit(1).single();
if (video.data) { console.log("Found video:", video.data.id);} else { console.log("No video found");}
Error Handling
Section titled “Error Handling”All queries return result objects:
const result = await client.videos().fetch();
if (result.error) { console.error("Query failed:", result.error.message);} else { console.log("Found videos:", result.data.length);}