On This Day API Documentation

The On This Day API is an incredibly easy to use historical event data feed for your website or app. Responses are supplied in JSON format, making it easy for experienced developers to get up in running.

In this guide we will go over how to make an API call and work with the response. No API key is required but requests will be limited to 5 per 30 second period by IP, if you have an active subscription, your key will work across all of our services.

Contents

  1. Basic API Structure
  2. How to fetch historical events for your website or app
  3. API Response
  4. Use Limits

1. Basic API Structure

On This Day API calls are designed to be easy to use and understand. The response data is formatted as a JSON object array. Pre-formatted HTML output is available in addition to raw text values.

The basic elements of an API call are as follows:

https://api.viewbits.com/v1/onthisday?m=[month]&d=[day]&key=[your_key]

where:

  • /v1/onthisday = On This Day API URL. Required.
  • [month] = Numerical representation of month 1-12.
  • [day] = Numerical representation of day 1-31.
  • [your_key] = Optional. API key for use with premium subscriptions, be sure to obfuscate or hide this in your source code to prevent hijacking.

2. How to fetch historical events for your website or app

The most efficient way for developers to load historical data is to cache the response into a local JSON file within your app rather than calling the API each time you want to display data. This will keep a cache of events that you can iterate through locally and allow you to have data on hand in the event that the API service is down.

Sample Requests

3. Response

The resulting data is formatted as a JSON object array, grouped by event type. A timestamp is also provided for cache updating.

{
"info":"OnThisDay API",
"date":"January_26",
"updated":"1706312978",
"data":{
"Events":[{event object},{event object}],
"Births":[{event object},{event object}],
"Deaths":[{event object},{event object}]
}
  • “Events” = Significant historical events occurring on the input day.
  • “Births” = Notable births from popular figures occurring on the input date.
  • “Deaths” = Notable deaths from popular figures occurring on the input date.

Each object group contains raw text, pre-formatted HTML, and anchor link arrays.

  • “text” = Raw text data.
  • “html” = Pre-formatted HTML data.
  • “links” = Anchor link array, contains anchor tag, raw text, and raw URL.

4. API Use Limits

Requests are restricted to 5 per 30 second period by default. An API key or registered IP is required for unlimited access and to disable CORS. We require that you show attribution with a backlink when using the free version of this API.