Data API
A read-only API of static JSON files. No authentication, no rate limit, and every response can be cached. Paths carry a version number, so a client written against v1 keeps working.
Base URL and format
Base URL: https://medievalbulgaria.com/data/v1
- Every response is UTF-8 JSON with Content-Type application/json. GeoJSON files are served the same way.
- A path that exists returns 200. A path that does not exist returns 404 with a plain-text body. There are no other statuses.
- Files change only when the site is deployed. They are served with Cache-Control max-age=3600. Checking once a day is enough.
- Responses carry Access-Control-Allow-Origin: *, so a browser page on any domain can fetch them.
- There is no server-side filtering, paging or search. Download the dataset file and filter it in your code. The largest list, pages.json, is under 1 MB.
- To find a record's id, open its page on the site: the last path segment of the URL is the id.
Endpoints
Paths are relative to the base URL.
| Path | Returns |
|---|---|
/index.json | Every dataset with its description, record count and URL; the export files with their columns; the GeoJSON years; the MCP endpoint. |
/{dataset}.json | A whole dataset: dataset, count, licence and items. |
/{dataset}/{id}.json | One record with all its fields. |
/territories/{year}.geojson | The political boundaries of the Balkans in one atlas year as a GeoJSON FeatureCollection, one MultiPolygon per realm. Years: 1186, 1205, 1230, 1261, 1300, 1331, 1355, 1371, 1396. |
/openapi.json | An OpenAPI 3.1 description of these endpoints. |
Dataset URLs
| Dataset file | Records | Record files |
|---|---|---|
/rulers.json | 129 | /rulers/{id}.json |
/dynasties.json | 5 | none; the dataset file is complete |
/battles.json | 15 | /battles/{id}.json |
/battle-record.json | 161 | none; the dataset file is complete |
/coins.json | 114 | /coins/{id}.json |
/places.json | 27 | /places/{id}.json |
/manuscripts.json | 26 | /manuscripts/{id}.json |
/events.json | 24 | none; the dataset file is complete |
/glossary.json | 53 | none; the dataset file is complete |
/map-periods.json | 9 | none; the dataset file is complete |
/pages.json | 179 | /pages/{id}.json |
/sources.json | 11 | none; the dataset file is complete |
Record conventions
- Every record has an id. It is the slug the site uses in the record's URL: ivan-asen-ii for a ruler, battle-klokotnitsa for a battle, tarnovo for a place.
- Text that exists in both languages is an object with bg and en keys. A field that has no value is null.
- Every record has url.en and url.bg, the absolute address of its page on the site.
- A dataset file holds the fields needed for a table. A record file holds every field, including long text. Small datasets have no record files.
- A citation is an object with source, page and url. The source is an id in the sources dataset.
- Fields may be added to v1 at any time. No field will be renamed or removed in v1; such a change would be published as v2.
Example record
The ruler kaloyan, with the biography and images left out:
{
"id": "kaloyan",
"name": {
"bg": "Калоян",
"en": "Kaloyan"
},
"epithet": {
"bg": "Романоубиец",
"en": "the Roman-slayer"
},
"title": "цар",
"dynasty": "asen",
"reigned": true,
"reign": {
"from": 1197,
"to": 1207
},
"born": null,
"died": 1207,
"family": {
"father": null,
"mother": null,
"spouses": [],
"children": [
"vitleem"
],
"siblings": [
"petar-iv",
"ivan-asen-i",
"na-asenina-i",
"na-asenina-ii"
],
"predecessor": "petar-iv",
"successor": "boril"
},
"evidence": [
{
"source": "bozhilov-gyuzelev-medieval-bulgaria",
"page": 609,
"url": "https://medievalbulgaria.com/sources/bozhilov-gyuzelev-medieval-bulgaria"
}
],
"wikidata": "Q294439",
"url": {
"en": "https://medievalbulgaria.com/people/kaloyan",
"bg": "https://medievalbulgaria.com/bg/people/kaloyan"
}
}Fields by dataset
Field names are as they appear in the JSON.
rulers: id, name, epithet, title, dynasty, reigned, reign (from, to), born, died, female, wikidata, portrait, url. Record file only: variants, dateNote, floruit, family (father, mother, spouses, children, siblings, predecessor, successor), notes, biography (paragraphs), evidence (citations), wikipedia, images.dynasties: id, name, from, to, rulers (ids).battles: id, year, date, name, location, coordinates (lat, lng), outcome, result, belligerents, commanders (person: id when a page exists; name), mapYear, url. Record file only: page, the full article record.battle-record: id, year, kind, side, ruler, opponent, result (win, draw, loss), name, note, sources (citations).coins: id, catalogueNumber, catalogueNumberConfident, ruler, rulerName, reign, metal, imitative, title, mint, obverse, reverse, diameterMm, weightG, rarity, cataloguePage, specimens (image, width, height, cataloguePage), drawings (same), url.places: id, kind, name, altNames, modern, lat, lng, role, rulers, battles, manuscripts, pages, image (url, caption, author, licence, source), url.manuscripts: id, kind, title, altTitles, date, yearFrom, yearTo, summary, language, material, extent, script, repository, shelfmark, city, digitalUrl, commonsUrl, rulers, places, url.events: id, year, month, day, title, description, url.glossary: id, category, term, definition.map-periods: id, year, label, description, realms (name, fill, ruler, situation, bulgariaLink, evidence), geojson, url.pages: id, type, title, summary, readingLevels, citations, url. Record file only: aliases, keyEvents, keyPeople, body (scholar, reader, simple; each with bg and en, Markdown).sources: id, authors, title, language, publisher, place, year, edition, isbn, about, url.
Examples
Shell
# every tsar who reigned, as "name (from–to)"
curl -s https://medievalbulgaria.com/data/v1/rulers.json \
| jq -r '.items[] | select(.reigned) | "\(.name.en) (\(.reign.from)–\(.reign.to))"'
# one battle, with its article
curl -s https://medievalbulgaria.com/data/v1/battles/battle-klokotnitsa.json | jq '.commanders, .page.title'JavaScript
const response = await fetch("https://medievalbulgaria.com/data/v1/coins.json");
const { items } = await response.json();
const silverOfIvanAlexander = items.filter(
(coin) => coin.ruler === "ivan-aleksandar" && coin.metal === "silver",
);
for (const coin of silverOfIvanAlexander) {
console.log(coin.catalogueNumber, coin.title.en, coin.mint.en ?? "mint unknown", coin.url.en);
}Python
import pandas as pd
import requests
record = requests.get("https://medievalbulgaria.com/data/v1/battle-record.json").json()["items"]
frame = pd.json_normalize(record)
# wins, draws and losses per opponent
print(frame.groupby(["opponent", "result"]).size().unstack(fill_value=0))
# a ruler's full record, with the cited pages
ruler = requests.get("https://medievalbulgaria.com/data/v1/rulers/kaloyan.json").json()
print(ruler["name"]["en"], ruler["reign"], [cite["source"] for cite in ruler["evidence"]])Search endpoints
Two endpoints are served by the site's backend rather than as files. They are the same endpoints the site's search page uses.
GET /api/site-search
Searches the site's own content and returns matching pages with a snippet and URL. Parameters: q (required), lang (en or bg), kind (person, page, coin, manuscript, realm), k (maximum number of results). No model is called, so there is no limit.
POST /api/site-search/answer
Answers a question from the source books with numbered citations, or states that the books do not cover it. The JSON body has two fields, query and lang. Each call runs a language model, so the endpoint allows a burst of 5 calls and 120 calls a day per IP address. Over the limit it returns 429.
curl "https://medievalbulgaria.com/api/site-search?q=Klokotnitsa&lang=en&k=5"
curl -X POST https://medievalbulgaria.com/api/site-search/answer \
-H "Content-Type: application/json" \
-d '{"query": "Why was Klokotnitsa decisive?", "lang": "en"}'Errors
Static files return 404 when the path does not exist. The search endpoints return a JSON object with an error field and a 4xx or 5xx status.