Timelory API Documentation

The Timelory REST API provides programmatic access to historical data including empire borders (GeoJSON), dynasty information, ruler genealogies, and timeline structures.

Base URL: https://api.timelory.com/api

Table of Contents

Historical Regions API

Access GeoJSON data for historical empire and nation borders.

GET /regions/postgis

Returns GeoJSON FeatureCollection of all historical regions for a specific year.

Query Parameters

ParameterTypeRequiredDescription
yearintegerYesYear to query. Use negative numbers for BCE (e.g., -500 for 500 BCE)

Example Request

GET https://api.timelory.com/api/regions/postgis?year=-500

Example Response

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {
        "name": "Achaemenid Empire",
        "start_year": -550,
        "end_year": -330,
        "color": "#8B4513"
      },
      "geometry": {
        "type": "Polygon",
        "coordinates": [[[44.0, 33.0], [50.0, 33.0], ...]]
      }
    }
  ]
}
GET /regions/timeline

Returns list of available years in the historical regions dataset.

Example Response

{
  "success": true,
  "data": {
    "years": [-3000, -2900, -2800, ..., 2020],
    "minYear": -3000,
    "maxYear": 2020
  }
}

Dynasties API

Access dynasty metadata and ruler information.

GET /dynasties

Returns list of all available dynasties.

Example Response

{
  "success": true,
  "data": [
    {
      "id": "assyrian",
      "name": "Assyrian Empire",
      "description": "Ancient Mesopotamian empire...",
      "startYear": -2025,
      "endYear": -609,
      "capital": "Nineveh",
      "imageUrl": "https://timelory.com/images/assyria.jpg"
    }
  ]
}
GET /dynasties/{id}

Returns detailed information about a specific dynasty.

GET /dynasties/{id}/rulers

Returns all rulers for a specific dynasty with events.

Example Response

{
  "success": true,
  "data": [
    {
      "id": "ashurbanipal",
      "name": "Ashurbanipal",
      "title": "King of Assyria",
      "startYear": -669,
      "endYear": -631,
      "description": "Last great Assyrian king...",
      "events": [
        {
          "year": -640,
          "title": "Library of Nineveh",
          "description": "Created greatest cuneiform collection",
          "type": "cultural"
        }
      ]
    }
  ]
}

Timelines API

Access and manage timeline data structures.

GET /timelines

Returns list of public timelines.

GET /timelines/{id}

Returns a specific timeline with all tracks and items.

Timeline Structure

{
  "id": "assyrian-timeline",
  "name": "Assyrian Empire Timeline",
  "description": "Complete history of Assyria",
  "tracks": [
    {
      "id": "old_assyrian",
      "name": "Old Assyrian Period",
      "startYear": -2025,
      "endYear": -1750,
      "color": "#7C3AED",
      "items": [
        {
          "id": "erishum_i",
          "name": "Erishum I",
          "start": -1974,
          "end": -1935,
          "events": [...]
        }
      ]
    }
  ]
}

Authentication

Most read endpoints are public. Write operations require authentication.

POST /auth/login

Authenticate and receive a bearer token.

Request Body

{
  "email": "user@example.com",
  "password": "your-password"
}

Using the Token

Authorization: Bearer {token}

Rate Limits

TierRequests/HourNotes
Anonymous100Public endpoints only
Free Account1,000All read endpoints
Premium10,000Full API access

Error Responses

{
  "success": false,
  "error": "Error message",
  "code": "ERROR_CODE"
}

Common Error Codes

CodeHTTP StatusDescription
UNAUTHORIZED401Missing or invalid authentication
NOT_FOUND404Resource not found
RATE_LIMITED429Too many requests
INVALID_PARAM400Invalid query parameter

SDKs & Libraries

Official SDKs coming soon. For now, use any HTTP client:

// JavaScript/TypeScript
const response = await fetch('https://api.timelory.com/api/regions/postgis?year=-500');
const data = await response.json();

// Python
import requests
response = requests.get('https://api.timelory.com/api/regions/postgis', params={'year': -500})
data = response.json()