A lightweight, edge-rendered wallpaper API built with Cloudflare Workers & Hono.
- Multi-Source Aggregation: Fetch wallpapers from multiple popular platforms using a unified interface.
- Scheduled Updates: Uses Cloudflare Workers Cron Triggers (
0 0 * * *) to automatically fetch and cache a daily collection of wallpapers into Cloudflare KV. - Direct Image Redirects: Every source includes a
/picendpoint that directly redirects the client to the raw image URL. - Edge-Ready: Built for Cloudflare Workers for global, low-latency responses.
- Type-Safe Validation: Query parameters are strictly validated using Valibot.
- Modern Tooling: Uses Biome for fast formatting and linting.
.
βββ src/
β βββ index.ts # Main application entry point and router setup
β βββ jobs/
β β βββ updateWallpapers.ts # Scheduled cron job to fetch and cache wallpapers in KV
β βββ routes/ # API route definitions and parameter validation
β β βββ bing.ts
β β βββ pexels.ts
β β βββ random.ts
β β βββ unsplash.ts
β β βββ wallhaven.ts
β βββ services/ # Core logic and external API integrations
β β βββ bing.ts
β β βββ pexels.ts
β β βββ random.ts
β β βββ unsplash.ts
β β βββ wallhaven.ts
β βββ utils/ # Shared utilities (fetch client, array shuffler)
β βββ client.ts
β βββ shuffle.ts
βββ wrangler.jsonc # Cloudflare Workers configuration
βββ biome.json # Biome linter/formatter configuration
βββ package.json # Project dependencies and scripts
-
Clone the repository and install dependencies:
npm install
-
Set up Environment Variables:
Create a
.dev.varsfile in the root directory for local development to store your API keys:UNSPLASH_ACCESS_KEY=your_unsplash_key PEXELS_API_KEY=your_pexels_key WALLHAVEN_API_KEY=your_wallhaven_key
-
Start the local development server:
npm run dev
npm run dev- Start the local development server using Wrangler.npm run deploy- Deploy the project to Cloudflare Workers.npm run lint- Check for linting errors using Biome.npm run fmt- Format code using Biome.npm run typecheck- Run TypeScript compiler checks.