A dataset of
every war.
HistWarDB turns Wikidata's crowdsourced conflict records into a clean, analysis-ready panel dataset — built for historians, political scientists, and anyone who needs rigorous, reproducible war data.
Built for rigorous historical analysis
Every record goes through anti-noise filtering and chronological sanity checks before it reaches your DataFrame.
Dynamic SPARQL pipeline
Fetches conflicts in 25-year temporal chunks to bypass Wikidata query limits and maximize data completeness.
Anti-noise filtering
Automatically excludes peacekeeping missions (wd:Q35349), military exercises (wd:Q1151430), and non-state actors.
Historical state support
Tracks entities like the German Empire, Qing dynasty, and Kingdom of Montenegro with built-in lifespan sanity checks.
Flexible analytical views
Transform data into long format, binary matrices, conflict-name mappings, or keyword search results — on demand.
Interactive visualizations
Out-of-the-box Plotly heatmaps to visualize global conflict intensity across centuries.
Tested & reproducible
Network I/O, query construction, and cleaning logic are separated into independent modules with a full pytest suite — no live Wikidata access required to run it.
From install to heatmap in four lines
Works locally or on Google Colab.
from histwardb import HistWarDB # Initialize the dataset from 1700 to 2026 gwd = HistWarDB(start_year=1700, end_year=2026) # Query specific countries in long format france_uk_wars = gwd(countries=["France", "United Kingdom"], view="long", only_in_war=True) # Plot an interactive heatmap for the top 15 conflict-prone states gwd.plot_heatmap(top_n=15, from_year=1800, to_year=2026).show()
One call, six shapes of data
Every view respects the same filters: countries, from_date/to_date, only_in_war, keyword.
| View | Returns |
|---|---|
"long" | Tidy DataFrame: Country, Year, War_State, Active_Conflicts. |
"binary" | Wide pivot: countries × years, 1 = at war, 0 = peace. |
"names" | Wide pivot with literal conflict names active per year. |
"list" | Alphabetical list of unique conflict names under current filters. |
"countries" | Sorted list of active states matching the query. |
"conflicts" | Sorted list of unique conflicts matching the query. |
Three layers, independently testable
Network I/O, query construction, and data cleaning never mix — which is what makes the full test suite run without touching the live Wikidata endpoint.
SPARQL construction
Pure functions build the query text for each 25-year chunk. No network, no side effects.
Network layer
An injectable requests-like session executes the query. Tests swap in a fake session.
Parsing & filtering
Anachronism checks, lifespan consistency, and grid construction — all pure, all unit-tested.
Cite it in your research
Machine-readable citation metadata is also available in CITATION.cff.
@software{histwardb2026,
author = {Manto, Vincenzo and Dal Cero, Riccardo},
title = {HistWarDB: A Dynamic Wikidata-Based Historical War Dataset},
year = {2026},
url = {https://github.com/VincenzoManto/histwardb}
}
Start querying history.
Open source, MIT-licensed, and ready for your next research project.