🏛️ Chinese History Toolkits
Map any year to its Chinese dynasty / reign-era / epoch — and back.
English · 中文 · Online Docs
A typed, dependency-light Python API for Chinese historical chronology: look up any 年号 / 朝代 / 历史时期 by name or by year, from the Paleolithic through 清.
✨ Features
- 🔁 Two-way lookup — name →
(begin, end)years; year → list of all parallel polities. - 🪨 Full timeline — 旧石器 / 新石器 prehistoric brackets through 清.
- 📚 Selectable chronology — 上古 dating is contested scholarship, so pick the source you trust: 上海图书馆, 夏商周断代工程, or 万国鼎《中国历史纪年表》.
- 🧭 Disambiguated — reused names resolve correctly (
夏(窦建德)≠ 上古夏), and an ambiguous 年号 raises rather than guessing. - 🌐 Alias-friendly — pass
aliases={"新石器": {"Neolithic", "Neo"}}to accept foreign-language input. - ⚡ Lightweight — only
pandasat runtime; data ships with the package, no network needed.
🚀 Quickstart
# From PyPI — distribution name is `chinese_history_toolkits`
pip install chinese_history_toolkits
# Or from source
git clone https://github.com/SongshGeoLab/chinese_history_toolkits.git
cd chinese_history_toolkits
uv sync --all-extras
Note — the PyPI distribution name is
chinese_history_toolkits(verbose), but the import name is the short acronymchhiskitfor daily use.
import chhiskit
# Name → years
chhiskit.get_age_from_cultural_period("康熙") # → (1662.0, 1722.0)
chhiskit.get_age_from_cultural_period("唐", level="dynasty") # → (618.0, 907.0)
chhiskit.get_age_from_cultural_period("新石器", level="epoch") # → (-10000.0, -2070.0)
# Year → matching polities (multiple are normal — 三国, 隋末, etc.)
[m.dynasty_id for m in chhiskit.get_cultural_periods_from_year(250)]
# → ['三国', '吴', '蜀', '魏']
# BP convention (radiocarbon, 1950 reference)
chhiskit.get_age_from_cultural_period("商", level="dynasty", anno_domini=False)
# → (3550.0, 2996.0)
# Foreign aliases
chhiskit.get_age_from_cultural_period(
"Neolithic", level="epoch",
aliases={"新石器": {"Neolithic", "Neo"}},
)
# → (-10000.0, -2070.0)
📚 Choosing a chronology
Scholars disagree about 上古 dating — the disagreement is real scholarship, not data error — so this library lets you pick rather than deciding for you:
chhiskit.get_age_from_cultural_period("夏", level="epoch") # → (-2070.0, ...) 夏商周断代工程 (default)
chhiskit.get_age_from_cultural_period("夏", level="epoch", source="shl") # → (-1989.0, ...) 上海图书馆
chhiskit.get_age_from_cultural_period("夏", level="epoch", source="wgd") # → (-2100.0, ...) 万国鼎 1956
chhiskit.set_default_source("shl") # or set a preference once
chhiskit.list_sources() # what each source covers
Sources overlay the base table and fall back to it where they are silent, so asking a source for something it never covered warns you rather than quietly handing you someone else's numbers. See Chronology Sources.
📖 Documentation
| 📖 Quick Start | Install + first lookup, 5 minutes |
| 📚 API Reference | Every parameter, with worked examples |
| 🗺️ Epochs Reference | EPOCH_MAP + PREHISTORIC_EPOCHS |
| 🕰️ Chronology Sources | Which source says what, and how to pick |
Build the site locally:
make docs # serve at http://127.0.0.1:8000
make docs-build # static build
🧪 Development
make test # pytest
pre-commit run --all-files # black + ruff + flake8 + mypy + interrogate
make tox # Python 3.10–3.13 matrix
The test file tests/test_dynasties.py is the executable spec — 125 cases organized into one class per behavior cluster, each with a docstring explaining what it pins.
How the shipped data is produced, audited and regenerated is documented for maintainers in data/dynasties/readme.md.
📄 Data attribution
| Source | Used for |
|---|---|
| 上海图书馆开放数据平台 | Base table — 朝代 / 年号 / 帝王 |
| 夏商周断代工程 (2000) | 上古 chronology (source="xsz", default) |
| 万国鼎《中国历史纪年表》(中华书局, 1956) | 国号 / 朝代 spans (source="wgd") |
Every modification to the upstream data is recorded row-by-row in dynasty_drops.md, each with a link back to the source record.
🤝 Contributing
PRs welcome. Please:
- Run
pre-commit run --all-filesandmake test(must pass). - New behavior → new test in
tests/test_dynasties.pywith a docstring describing what it pins. - Touching the data? See
data/dynasties/readme.md— regenerated artifacts are committed alongside the change so the diff is its own audit trail.
📜 License
MIT — see LICENSE.
👤 Author
Metadata
Release files for chinese_history_toolkits 0.2.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 | Provenance | Actions |
|---|---|---|---|---|
| chinese_history_toolkits-0.2.0.tar.gz | 235.8 kB | Without provenance | Details for chinese_history_toolkits-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| chinese_history_toolkits-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for chinese_history_toolkits-0.2.0-py3-none-any.whl |
Total release size: 281.3 kB
Release files / chinese_history_toolkits-0.2.0.tar.gz
| Download URL | chinese_history_toolkits-0.2.0.tar.gz |
|---|---|
| Size | 235.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8ff09a7a6b003bfae1264dbe574f0584ed31db0665b603db41f2b1c125f5f47a
|
|
BLAKE2b-256 checksum How to use checksums |
87ae39db0ed53196959d3d93c3a220ce1635943a2e7d706f1e1259c8559fecb1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / chinese_history_toolkits-0.2.0-py3-none-any.whl
| Download URL | chinese_history_toolkits-0.2.0-py3-none-any.whl |
|---|---|
| Size | 45.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
76c939aa1dcbac473f9b420162dff9acf4ecae7d152ef2275499ab0b5f6da9cf
|
|
BLAKE2b-256 checksum How to use checksums |
a729e3dc57fc56521e0475ba0fbbea843738b48dd010947a6efc37f56bffae75
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for chinese_history_toolkits 0.2.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.