Browse Cities
API

Search a city, then fetch the full timing payload.

The SunriseTime API lets you discover supported city slugs first, then request sun, moon, and prayer data in one structured response. The current catalog covers 500 indexed cities.

Access model

  • Public beta
  • No API key required right now
  • Best for read-only integrations and lightweight tooling
  • Anonymous rollout target: 100 requests per IP per day

Product basics

  • Versioned under /api/v1/
  • Structured meta block on every JSON response
  • Browser-side CORS is still limited to first-party origins
  • API JSON responses send X-Robots-Tag: noindex

Current cache policy

  • /api/v1/times: 15-minute cache window
  • /api/v1/cities: 60-minute cache window
  • /api/v1/openapi.json: 60-minute cache window

Quickstart

Resolve a city slug first, then request timing data with the returned slug.

1. Resolve a city slug

curl "https://sunrisetime.co/api/v1/cities?query=london&limit=3"

2. Fetch timing data

curl "https://sunrisetime.co/api/v1/times?city=london&date=2026-03-29"

Endpoints

These three endpoints are enough for most external integrations.

Parameters

Keep the flow simple: discover a slug, then request one city at a time.

/api/v1/cities

Parameter Required Notes
query No City, slug, country, or admin region. Empty query returns popular cities.
limit No Default 10, max 25.

/api/v1/times

Parameter Required Notes
city Yes Stable city slug such as london, istanbul, or new-york.
date No Optional local date in YYYY-MM-DD format.

Response shape

The JSON stays grouped by use case instead of exposing only low-level calculation internals.

JSON

  • meta: version, endpoint, docs URL, cache TTL, query echo
  • city: slug, name, coordinates, timezone, population metadata
  • links: related site and API URLs for the resolved city
  • sun, goldenHour, moon, and prayerTimes blocks

Sample response

{
  "meta": {
    "version": "v1",
    "endpoint": "/api/v1/times",
    "cacheTtlSeconds": 900
  },
  "city": {
    "slug": "london",
    "name": "London",
    "timezone": "Europe/London"
  },
  "sun": {
    "sunrise": "6:44 AM",
    "sunset": "7:26 PM"
  },
  "moon": {
    "phase": "Waxing Crescent",
    "illumination": 12
  },
  "prayerTimes": {
    "fajr": "5:10 AM",
    "maghrib": "7:26 PM"
  }
}

Integration examples

Command-line and server-side usage work best right now. Third-party browser access should wait until broader CORS controls are available.

cURL

curl "https://sunrisetime.co/api/v1/times?city=london&date=2026-03-29"

JavaScript

const cityLookup = await fetch("https://sunrisetime.co/api/v1/cities?query=london&limit=1");
const cityResult = await cityLookup.json();
const citySlug = cityResult.cities[0]?.slug;

const timingResponse = await fetch(`https://sunrisetime.co/api/v1/times?city=${citySlug}&date=2026-03-29`
);
const timingData = await timingResponse.json();

console.log(timingData.sun.sunrise, timingData.prayerTimes.maghrib);

Error model

Errors return structured JSON, which makes external handling more predictable.

Code Status Meaning
missing_city 400 The city query parameter was not sent to /api/v1/times.
invalid_date 400 The date value was not in YYYY-MM-DD format.
unknown_city 404 The provided city slug does not exist in the current index.
invalid_limit 400 The limit value sent to /api/v1/cities was invalid.

Operational next steps

Use these three links when you want to validate assumptions, inspect public slugs, or ask for higher-volume access.