HistWarDB 🌍⚔️
Advanced Historical & Sovereign War Dataset powered by Wikidata
HistoricalWarDB (HistWarDB) is a dynamic, programmatic Python toolkit designed to extract, clean, and analyze global warfare data from Wikidata spanning from 1700 to the present. Built for researchers, historians, and data scientists, it bridges the gap between crowdsourced knowledge and rigorous historical data pipelines, supporting both modern sovereign states and historical empires.
Key Features
- Dynamic SPARQL Pipeline: Fetches conflicts using 25-year temporal chunks to bypass query limits and ensure high data completeness.
- Rigorous Anti-Noise Filtering: Automatically excludes peacekeeping missions (
wd:Q35349), military exercises (wd:Q1151430), and non-state actors. - Historical State Support: Seamlessly tracks historical entities (e.g., German Empire, Qing dynasty, Kingdom of Montenegro) with built-in lifespan sanity checks.
- Flexible Analytical Views: Instantly transforms data into long formats, binary matrices (
0/1), conflict name mappings, or customLIKEkeyword search results. - Interactive Visualizations: Out-of-the-box Plotly heatmap generation to visualize global conflict intensity over centuries.
- Tested and reproducible: Network I/O, SPARQL query construction, and data-cleaning logic are separated into independent, unit-tested modules — no live Wikidata access required to run the test suite.
Project layout
src/histwardb/
query.py # SPARQL query construction (pure, no I/O)
core.py # HistWarDB class: fetch, parse, clean, analytical views
tests/ # pytest suite (parsing, filtering, views, mocked network)
HistWarDB.ipynb # usage demo notebook (Colab-compatible)
Installation
pip install git+https://github.com/VincenzoManto/histwardb.git
For local development (editable install + test/lint tooling):
git clone https://github.com/VincenzoManto/histwardb.git
cd histwardb
pip install -e ".[dev]"
Quick Start
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)
print(france_uk_wars.head())
# Get a binary matrix for specific historical periods
binary_view = gwd(countries="German Empire", view="binary", from_date="1900-01-01", to_date="1918-12-31")
# Plot an interactive heatmap for the top 15 conflict-prone states
gwd.plot_heatmap(top_n=15, from_year=1800, to_year=2026).show()
Supported Views (view parameter)
The dataset interface supports multiple analytical views via the gwd(...) call:
"long": Standard tidy DataFrame containing columns:Country,Year,War_State, andActive_Conflicts."binary": Wide pivot table with countries as rows, years as columns, and binary values (1= at war,0= peace)."names": Wide pivot table containing the literal names of active conflicts per year."list": Alphabetical list of all unique conflict names extracted under current filters."countries"/"conflicts": Sorted lists of active entities or unique conflicts matching the query criteria.
Testing
The test suite never queries the live Wikidata endpoint. The HistWarDB
class accepts an injectable session object for its HTTP calls, and all
parsing/filtering logic (histwardb.core.parse_bindings,
clean_dataframe, build_long_grid) is pure and tested against static
fixtures:
pip install -e ".[dev]"
pytest --cov=histwardb
See CONTRIBUTING.md for details.
Citation
If you use HistWarDB in your academic research, working paper, or data science project, please cite it using the following format (also available in machine-readable form in CITATION.cff):
@software{histwardb2026,
author = {Vincenzo Manto},
title = {HistWarDB: A Dynamic Wikidata-Based Historical War Dataset},
year = {2026},
url = {https://github.com/VincenzoManto/histwardb}
}
License
Distributed under the MIT License. See LICENSE for more information.
Metadata
Release files for histwardb 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| histwardb-0.1.0.tar.gz | 15.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| histwardb-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 27.8 kB
Release files / histwardb-0.1.0.tar.gz
| Download URL | histwardb-0.1.0.tar.gz |
|---|---|
| Size | 15.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5cf6d18c3988d7bdf936bd3b40b03fd46d17c80ae35d4976eaca227d7aa5f6fa
|
|
BLAKE2b-256 checksum How to use checksums |
f8746e6c5f06d3f70dc0eb903c892330064c7e01dfa1290f39ec45d475f9c6cd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.
Transparency logRelease files / histwardb-0.1.0-py3-none-any.whl
| Download URL | histwardb-0.1.0-py3-none-any.whl |
|---|---|
| Size | 11.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5843a5a0339c04abc7ea019c4ad13cd3c7a1ef43adf004a50368690e9325a0cd
|
|
BLAKE2b-256 checksum How to use checksums |
88cb5747b1d9a479c0f538141af8a845eb744aea3b0ff5eca4fae6a7d36f1028
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.
Transparency log