Sunrise Sunset API

Find sunrise/sunset times anywhere in the world


Like most of us, Andy loves sunsets. After realizing it was difficult to find the exact sunrise and sunset times localized to a users’ coordinates, he built the Sunrise Sunset API where users can find sunrise or sunset times in any location in the world. Users simply put in any coordinates, on any day, and the API will support fetching the correct date and time of sunrise and sunset.

Leveraging an open source library to calculate sunrise and sunset times, the Sunrise Sunset API uses a simple math equation to calculate the times, converting times based on location and time zone. Common use cases for the API include Traveling, Photography, Farming & Agriculture, Planning Outdoor Activities (i.e. Cycling).

How do they use Cloudflare

Andy has been using Cloudflare since 2012 after moving DNS and domains to Cloudflare. To build the Sunrise Sunset API, Andy utilized Cloudflare Workers and Cloudflare Pages to build out the API and website.

Previously, the Sunrise Sunset API used a fetch request to Vercel. After experiencing latency concerns and becoming more familiar with how edge computing works, he figured out how to leverage the Developer Platform to replace his Vercel edge compute. Realizing that a Vercel edge file can be a Cloudflare Worker, Andy migrated the Sunrise Sunset API to Workers which now fetches 500K+ requests per day with speed and reliability.

As Sunrise Sunset API considers offering more products/features over time including scaling out to more cities and pulling in more details like city descriptions, Andy is considering moving the entire project frontend to Cloudflare, adding tools like R2 storage and Images to build out the future of the API.

Why Cloudflare?

“We love the pricing based on usage and the scale we can achieve with Workers is amazing!” With Workers, I have 100% uptime and can check out the dashboard to monitor how many request we’re getting”