Skip to content

Commit c051558

Browse files
dr5hnclaude
andcommitted
docs(readme): lead with API + Export Tool, demote others, drop low-value sections
- Promote REST API and Export Tool to a 'Recommended for production' lead section since they're the two managed, billed products that fund the rest. - Demote NPM, PyPI, direct download, browser/timezones packages, and the rest of the ecosystem into a collapsed 'Other ways to use the data' section. They're still discoverable, just no longer competing for the hero space. - Stats block: drop the <sub> wrapper so the font matches body text. - License callout: 'attribution required' surfaced explicitly in the intro tagline; license section restated 'derivatives must be shared under the same license'. - Remove the 'Picking a format' bullet list and 'Repository architecture' section entirely (low signal for the average reader). - Remove the coverage matrix table; format list above is enough. - Drop the API response-time bullet (more appropriate for the docs site). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent e9cc548 commit c051558

1 file changed

Lines changed: 64 additions & 179 deletions

File tree

README.md

Lines changed: 64 additions & 179 deletions
Original file line numberDiff line numberDiff line change
@@ -4,179 +4,125 @@
44

55
# Countries States Cities Database
66

7-
A comprehensive, community-maintained dataset of **countries, states, cities, and postcodes** — published in 11 formats and free under the [Open Database License](LICENSE).
7+
A comprehensive, community-maintained dataset of **countries, states, cities, and postcodes** — published in 11 formats and free under the [Open Database License](LICENSE) **(attribution required)**.
88

99
[![License: ODbL-1.0](https://img.shields.io/badge/License-ODbL--1.0-brightgreen.svg?style=flat-square)](LICENSE)
1010
[![GitHub stars](https://img.shields.io/github/stars/dr5hn/countries-states-cities-database.svg?style=flat-square)](https://github.com/dr5hn/countries-states-cities-database/stargazers)
1111
![release](https://img.shields.io/github/v/release/dr5hn/countries-states-cities-database?style=flat-square)
1212
[![NPM](https://img.shields.io/npm/v/@countrystatecity/countries.svg?style=flat-square&label=npm)](https://www.npmjs.com/package/@countrystatecity/countries)
1313
[![PyPI](https://img.shields.io/pypi/v/countrystatecity-countries.svg?style=flat-square&label=pypi)](https://pypi.org/project/countrystatecity-countries/)
1414

15-
[**API**](https://countrystatecity.in/) ·
16-
[**NPM**](https://www.npmjs.com/package/@countrystatecity/countries) ·
17-
[**Demo**](https://demo.countrystatecity.in/) ·
18-
[**Docs**](https://docs.countrystatecity.in/) ·
19-
[**Playground**](https://playground.countrystatecity.in/) ·
20-
[**Export Tool**](https://export.countrystatecity.in/)
21-
2215
</div>
2316

24-
<sub>
2517
Total Regions : 6 <br>
2618
Total Sub Regions : 22 <br>
2719
Total Countries : 250 <br>
2820
Total States/Regions/Municipalities : 5,299 <br>
2921
Total Cities/Towns/Districts : 153,765 <br>
3022
Total Timezones : 427 (100% IANA coverage) <br>
3123
Last Updated On: April 28, 2026
32-
</sub>
3324

3425
---
3526

36-
## Overview
27+
## Recommended for production
3728

38-
- **250** countries · **5,299** states · **153,765** cities · **100k+** postcodes across ~50 countries
39-
- **11 formats** — JSON, MySQL, PostgreSQL, SQLite, SQL Server, MongoDB, XML, YAML, CSV, GeoJSON, TOON
40-
- **19 languages** of country and state names plus native script
41-
- **100% IANA timezone coverage** for cities
42-
- **Validated foreign keys** on every PR — no orphans
43-
- **ODbL-licensed** — commercial use, modification, and redistribution all allowed
29+
The two managed products below are the fastest path to shipping. They're actively maintained, billed for sustainability, and back the rest of the ecosystem.
30+
31+
### REST API — `api.countrystatecity.in`
32+
33+
Query countries, states, cities, and postcodes from any language. Free tier for prototyping; paid tiers for production.
34+
35+
```bash
36+
curl https://api.countrystatecity.in/v1/countries/IN/states/MH/cities \
37+
-H "X-CSCAPI-KEY: $YOUR_API_KEY"
38+
```
39+
40+
[**Get an API key →**](https://countrystatecity.in/) ·
41+
[Documentation](https://docs.countrystatecity.in/) ·
42+
[Interactive playground](https://playground.countrystatecity.in/) ·
43+
[OpenAPI spec](https://github.com/dr5hn/csc-swagger) ·
44+
[Status](https://status.countrystatecity.in/)
45+
46+
### Export Tool — `export.countrystatecity.in`
47+
48+
Build tailored datasets in your browser — pick country, region, format, and field selection, then download.
49+
50+
[**Launch the Export Tool →**](https://export.countrystatecity.in/)
4451

4552
---
4653

47-
## Quick start
54+
## Other ways to use the data
4855

49-
### JavaScript / TypeScript
56+
<details>
57+
<summary><strong>NPM (JavaScript / TypeScript)</strong></summary>
5058

5159
```bash
5260
npm install @countrystatecity/countries
5361
```
5462

5563
```js
5664
import { Country, State, City } from '@countrystatecity/countries';
57-
5865
const usStates = State.getStatesOfCountry('US');
59-
const sf = City.getCitiesOfState('US', 'CA').find(c => c.name === 'San Francisco');
6066
```
6167

62-
Zero dependencies, TypeScript-first, tree-shakeable, works offline.
6368
[GitHub](https://github.com/dr5hn/countrystatecity-countries) ·
6469
[NPM](https://www.npmjs.com/package/@countrystatecity/countries)
6570

66-
### Python
71+
</details>
72+
73+
<details>
74+
<summary><strong>PyPI (Python)</strong></summary>
6775

6876
```bash
6977
pip install countrystatecity-countries
7078
```
7179

7280
```python
7381
from countrystatecity_countries import Country, State, City
74-
7582
us_states = State.get_states_of_country('US')
7683
```
7784

78-
Plays well with Django, Flask, FastAPI.
7985
[GitHub](https://github.com/dr5hn/countrystatecity-pypi) ·
8086
[PyPI](https://pypi.org/project/countrystatecity-countries/)
8187

82-
### REST API
88+
</details>
8389

84-
```bash
85-
curl https://api.countrystatecity.in/v1/countries/IN/states/MH/cities \
86-
-H "X-CSCAPI-KEY: $YOUR_API_KEY"
87-
```
88-
89-
Use from any language.
90-
[Get a key](https://countrystatecity.in/) ·
91-
[Docs](https://docs.countrystatecity.in/) ·
92-
[Playground](https://playground.countrystatecity.in/) ·
93-
[OpenAPI spec](https://github.com/dr5hn/csc-swagger) ·
94-
[Status](https://status.countrystatecity.in/)
95-
96-
### Direct download
90+
<details>
91+
<summary><strong>Direct download (gzipped exports)</strong></summary>
9792

98-
Every format ships as a gzipped asset on each
99-
[GitHub Release](https://github.com/dr5hn/countries-states-cities-database/releases).
93+
Every format ships as a `.gz` asset on each [GitHub Release](https://github.com/dr5hn/countries-states-cities-database/releases).
10094

10195
```bash
10296
curl -LO https://github.com/dr5hn/countries-states-cities-database/releases/latest/download/json-cities.json.gz
10397
gunzip json-cities.json.gz
10498
```
10599

106-
Smaller reference files (countries, states, schema) live in the repo.
107-
Use `git clone --depth 1` for a fast clone.
100+
Smaller reference files (countries, states, schema) live in the repo. Use `git clone --depth 1` for a fast clone.
108101

109-
### Custom slices
102+
</details>
110103

111-
The [Export Tool](https://export.countrystatecity.in/) builds tailored datasets —
112-
pick by region, country, or format with custom field selection.
113-
114-
---
104+
<details>
105+
<summary><strong>Other packages and platforms</strong></summary>
115106

116-
## Ecosystem
107+
- [`@countrystatecity/countries-browser`](https://github.com/dr5hn/countrystatecity-countries-browser) — CDN-loaded, lazy
108+
- [`@countrystatecity/timezones`](https://github.com/dr5hn/countrystatecity-timezones) — dedicated timezone data
109+
- [Database browser](https://demo.countrystatecity.in/) — query and explore live data
110+
- [Encyclopedia](https://countrystatecity.org/) — country profiles and insights
111+
- [Community Manager](https://manager.countrystatecity.in/) — submit corrections via web UI
112+
- [CLI](https://cli.countrystatecity.in/) — terminal access
113+
- [Kaggle](https://www.kaggle.com/datasets/darshangada/countries-states-cities-database/data) · [Data.world](https://data.world/dr5hn/country-state-city)
117114

118-
### Data products
119-
120-
| Product | Use case | Links |
121-
|---|---|---|
122-
| `@countrystatecity/countries` (NPM) | JavaScript / TypeScript apps, offline use | [npmjs](https://www.npmjs.com/package/@countrystatecity/countries) · [GitHub](https://github.com/dr5hn/countrystatecity-countries) |
123-
| `countrystatecity-countries` (PyPI) | Python apps | [pypi](https://pypi.org/project/countrystatecity-countries/) · [GitHub](https://github.com/dr5hn/countrystatecity-pypi) |
124-
| `@countrystatecity/countries-browser` | CDN-loaded, lazy, no bundled data | [GitHub](https://github.com/dr5hn/countrystatecity-countries-browser) |
125-
| `@countrystatecity/timezones` | Dedicated timezone data | [GitHub](https://github.com/dr5hn/countrystatecity-timezones) |
126-
| Raw exports (this repo) | SQL / CSV / JSON / etc. | [Releases](https://github.com/dr5hn/countries-states-cities-database/releases) |
127-
128-
### Services
129-
130-
| Service | Use case | Link |
131-
|---|---|---|
132-
| REST API | Production apps in any language | [countrystatecity.in](https://countrystatecity.in/) |
133-
| API documentation | Endpoints, parameters, examples | [docs.countrystatecity.in](https://docs.countrystatecity.in/) |
134-
| Interactive playground | Try requests live in Swagger UI | [playground.countrystatecity.in](https://playground.countrystatecity.in/) |
135-
| OpenAPI specification | Generate SDKs in any language | [csc-swagger](https://github.com/dr5hn/csc-swagger) |
136-
| Status page | Uptime and incident history | [status.countrystatecity.in](https://status.countrystatecity.in/) |
137-
138-
### Tools
139-
140-
| Tool | Use case | Link |
141-
|---|---|---|
142-
| Export Tool | Slice the database by country / region / format | [export.countrystatecity.in](https://export.countrystatecity.in/) |
143-
| Database browser | Query and explore live data | [demo.countrystatecity.in](https://demo.countrystatecity.in/) |
144-
| Encyclopedia | Country profiles and geographical insights | [countrystatecity.org](https://countrystatecity.org/) |
145-
| Community Manager | Submit data corrections via web UI | [manager.countrystatecity.in](https://manager.countrystatecity.in/) |
146-
| Command line interface | Query CSC data from your terminal | [cli.countrystatecity.in](https://cli.countrystatecity.in/) |
147-
148-
### Also distributed via
149-
150-
[Kaggle](https://www.kaggle.com/datasets/darshangada/countries-states-cities-database/data) — data-science notebooks ·
151-
[Data.world](https://data.world/dr5hn/country-state-city) — analytics platforms
115+
</details>
152116

153117
---
154118

155-
## Available formats
156-
157-
**Core (every release):**
158-
JSON, MySQL, PostgreSQL, SQLite, SQL Server, MongoDB, XML, YAML, CSV.
159-
160-
**Specialty:**
119+
## What's in the data
161120

162-
- **GeoJSON** — RFC 7946, Point geometry. Drops into Leaflet, Mapbox, PostGIS.
163-
- **[TOON](https://github.com/toon-format/toon)** — Token-Oriented Object Notation,
164-
~40% fewer tokens than JSON for LLM context windows.
165-
- **DuckDB** — convert SQLite via [`bin/scripts/export/import_duckdb.py`](bin/scripts/export/import_duckdb.py)
166-
for analytics workloads.
167-
168-
**Coverage matrix:**
169-
170-
| Table | Per-table file | Combined file |
171-
|---|---|---|
172-
| Regions, Subregions, Countries, States, Cities | All formats ||
173-
| Postcodes (~50 countries) | All formats ||
174-
| Country + States, Country + Cities | JSON only ||
175-
| Full world (Country + State + Cities) || JSON, MySQL, PostgreSQL, SQLite, SQL Server, MongoDB |
176-
177-
---
178-
179-
## Performance
121+
- **250** countries · **5,299** states / regions · **153,765** cities · **100k+** postcodes across ~50 countries
122+
- **19 languages** of country and state names plus native script
123+
- **100% IANA timezone coverage** for cities
124+
- **Validated foreign keys** on every contribution
125+
- **Formats:** JSON, MySQL, PostgreSQL, SQLite, SQL Server, MongoDB, XML, YAML, CSV, GeoJSON, [TOON](https://github.com/toon-format/toon) (LLM-optimised, ~40% fewer tokens than JSON)
180126

181127
| Format | Export time | Size | Compressed |
182128
|---|---:|---:|---:|
@@ -190,52 +136,18 @@ JSON, MySQL, PostgreSQL, SQLite, SQL Server, MongoDB, XML, YAML, CSV.
190136
| YAML | 17s | 68 MB ||
191137
| SQLite | 45s | 89 MB ||
192138

193-
**API response times (typical):** countries 50ms · states 180ms · cities by state 80ms · search 120ms.
194-
195-
**Picking a format:**
196-
197-
- Web / mobile → JSON or CSV
198-
- Direct database import → MySQL, PostgreSQL, SQLite, SQL Server
199-
- Maps / GIS → GeoJSON
200-
- AI / LLM context → TOON
201-
- Analytics / OLAP → SQLite or DuckDB
202-
203-
---
204-
205-
## Repository architecture
206-
207-
Two-phase build. JSON in version control, MySQL as the canonical store,
208-
every format auto-regenerated.
209-
210-
```
211-
contributions/ → [Python import] → MySQL → [PHP export] → json/, csv/, xml/, sql/, ...
212-
```
213-
214-
- **Contributors** edit JSON in `contributions/`. GitHub Actions re-imports,
215-
exports every format, and uploads `.gz` assets to a Release.
216-
- **Maintainers** can also work SQL-first — `sync_mysql_to_json.py` rewrites
217-
the contributions tree from MySQL.
218-
- **Users** download the format they want; they're all in sync per release.
219-
220-
Every PR runs schema, cross-reference, coordinate-bounds, and duplicate
221-
validators. Full build and maintenance reference:
222-
[`.claude/CLAUDE.md`](.claude/CLAUDE.md).
223-
224139
---
225140

226141
## Contributing
227142

228-
The easiest way is the [Community Manager](https://manager.countrystatecity.in/)
229-
browse, search, and submit corrections through a web UI with end-to-end tracking.
143+
The easiest way is the [Community Manager](https://manager.countrystatecity.in/) — submit corrections through a web UI with end-to-end tracking.
230144

231145
To edit JSON directly:
232146

233-
1. Fork and clone the repository (`git clone --depth 1` is fastest).
234-
2. Edit files under `contributions/cities/`, `contributions/states/`,
235-
`contributions/countries/`, or `contributions/postcodes/`.
236-
3. **Required** for new cities: `name`, `state_id`, `state_code`, `country_id`,
237-
`country_code`, `latitude`, `longitude`. **Optional**: `timezone`, `wikiDataId`, `native`.
238-
4. **Omit** `id`, `created_at`, `updated_at`, `flag` — auto-managed by MySQL on import.
147+
1. Fork and clone (`git clone --depth 1`).
148+
2. Edit files under `contributions/cities/`, `contributions/states/`, `contributions/countries/`, or `contributions/postcodes/`.
149+
3. **Required** for new cities: `name`, `state_id`, `state_code`, `country_id`, `country_code`, `latitude`, `longitude`. **Optional**: `timezone`, `wikiDataId`, `native`.
150+
4. **Omit** `id`, `created_at`, `updated_at`, `flag` — auto-managed on import.
239151
5. Open a pull request with a clear data source.
240152

241153
```json
@@ -256,48 +168,19 @@ To edit JSON directly:
256168
[Contribution guidelines](.github/CONTRIBUTING.md) ·
257169
[Multi-level territories policy](MULTI_LEVEL_TERRITORIES.md)
258170

259-
> Don't edit the auto-generated directories (`json/`, `csv/`, `xml/`, `yml/`,
260-
> `sql/`, etc.). They're rebuilt from MySQL on every release.
261-
262-
---
263-
264-
## Optional snippets
265-
266-
### MongoDB import
267-
268-
```bash
269-
curl -LO https://github.com/dr5hn/countries-states-cities-database/releases/latest/download/mongodb-world-mongodb-dump.tar.gz
270-
tar -xzvf mongodb-world-mongodb-dump.tar.gz
271-
mongorestore --host localhost:27017 --db world mongodb-dump/world
272-
```
273-
274-
### SQLite to DuckDB
275-
276-
```bash
277-
pip install duckdb
278-
python3 bin/scripts/export/import_duckdb.py \
279-
--input sqlite/world.sqlite3 \
280-
--output duckdb/world.db
281-
```
171+
> Don't edit the auto-generated directories (`json/`, `csv/`, `xml/`, `yml/`, `sql/`, etc.). They're rebuilt from MySQL on every release.
282172
283173
---
284174

285175
## License and attribution
286176

287-
Licensed under the [Open Database License (ODbL v1.0)](LICENSE).
288-
Use commercially, modify, redistribute — give credit and keep derivatives open.
177+
Licensed under the [Open Database License (ODbL v1.0)](LICENSE). Commercial use, modification, and redistribution all permitted. **Attribution is required**, and derivatives must be shared under the same license.
289178

290179
```
291180
Data by Countries States Cities Database
292181
https://github.com/dr5hn/countries-states-cities-database | ODbL v1.0
293182
```
294183

295-
## Disclaimer
296-
297-
Community-maintained data may contain errors or lag behind geopolitical
298-
changes. Verify critical data with official sources.
299-
[Report issues](https://github.com/dr5hn/countries-states-cities-database/issues).
300-
301184
---
302185

303186
## Support
@@ -323,6 +206,10 @@ You can also [plant a tree](https://ecologi.com/darshangada?r=60f2a36e67efcb18f7
323206
</a>
324207
</p>
325208

209+
## Disclaimer
210+
211+
Community-maintained data may contain errors or lag behind geopolitical changes. Verify critical data with official sources. [Report issues](https://github.com/dr5hn/countries-states-cities-database/issues).
212+
326213
---
327214

328215
<div align="center">
@@ -335,6 +222,4 @@ You can also [plant a tree](https://ecologi.com/darshangada?r=60f2a36e67efcb18f7
335222
<img src="https://contrib.rocks/image?repo=dr5hn/countries-states-cities-database&anon=1" />
336223
</a>
337224

338-
<sub>Made with <a href="https://contrib.rocks">contrib.rocks</a></sub>
339-
340225
</div>

0 commit comments

Comments
 (0)