FeaturesTemplatesShowcaseTownie
AI
BlogDocsPricing
Log inSign up
wolf
wolfBingImageOfDay
Public
Like
BingImageOfDay
Home
Code
4
README.md
C
backupImage.tsx
fetchBingImage.tsx
H
index.tsx
Branches
1
Pull requests
Remixes
History
Environment variables
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
README.md
Code
/
README.md
Search
3/22/2025
Viewing readonly version of main branch: v23
View latest version
README.md

Bing Image of the Day Archive

This Val Town project fetches, displays, and archives the Bing Image of the Day, providing an API to access both current and historical images.

Project Overview

The service provides several capabilities:

  • Fetch the current Bing Image of the Day
  • Archive images to Val Town blob storage with date-based naming
  • List all archived images with their dates
  • Retrieve specific historical images by date

API Endpoints

EndpointMethodDescription
/GETReturns the current Bing Image of the Day
/listGETReturns a JSON object listing all archived images with dates as keys and URLs as values
/get/:dateGETReturns a specific archived image by date (format: MM-DD-YYYY)
/backupGETManually triggers a backup of the current Bing Image of the Day
/docsGETReturns API documentation in JSON format

Project Structure

This project consists of three main components:

  1. index.tsx - The main HTTP val that provides the API endpoints using the Hono framework
  2. fetchBingImage.tsx - A helper function that handles fetching the image from Bing
  3. backupImage.tsx - A helper function that handles archiving images to blob storage

How It Works

  • The service scrapes the Bing image from a public source (bing.gifposter.com)
  • Images are stored in Val Town's blob storage with keys in the format bing-images-of-day/MM-DD-YYYY.jpg
  • The main API serves both current and archived images with proper caching headers
  • Automation can be set up to trigger the backup endpoint daily to build a complete archive

Usage Examples

View Current Image

GET /

Returns the current Bing Image of the Day as a JPEG with appropriate headers.

List All Archived Images

GET /list

Returns a JSON object like:

{ "1-15-2024": "https://your-val.web.val.run/get/1-15-2024.jpg", "1-14-2024": "https://your-val.web.val.run/get/1-14-2024.jpg", "1-13-2024": "https://your-val.web.val.run/get/1-13-2024.jpg" }

Get Specific Image by Date

GET /get/1-15-2024

Returns the image for January 15, 2024 as a JPEG.

Automation

To create a complete archive, you can:

  1. Set up a daily cron job using Val Town's scheduling to hit the /backup endpoint
  2. Use the endpoint in existing automations that run daily

Technical Implementation

  • Uses TypeScript for type safety
  • Implemented with the Hono framework for robust API routing
  • Leverages Val Town's blob storage for image archiving
  • Follows best practices for error handling and response headers

Credits

  • Image source: Bing's Image of the Day via gifposter.com
  • Hosted on Val Town
Go to top
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Product
FeaturesPricing
Developers
DocsStatusAPI ExamplesNPM Package Examples
Explore
ShowcaseTemplatesNewest ValsTrending ValsNewsletter
Company
AboutBlogCareersBrandhi@val.town
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.