Geographic map data as a single API call
mapjson returns topojson (or geojson) for any geographic layer in a single API call. The shortest possible call returns Natural Earth 110m world countries with no attached properties — the most common use case for a world map.
// Minimal call — 110m world countries, no properties
d3.json("https://api.mapjson.com/v1/geo").then(topo => {
const countries = topojson.feature(topo, topo.objects.geo);
// draw your map
});
// With filtering and properties
d3.json("https://api.mapjson.com/v1/geo?layer=countries&filter=europe&detail=medium&properties=name,iso2")
.then(topo => { /* ... */ });
| Parameter | Default | Options | Description |
|---|---|---|---|
layer |
countries |
Which geographic layer to return. All layers return polygon or line geometry. See Layers below. | |
filter |
world |
Filters output to a continent, country, or region. Accepts a continent slug, ISO alpha-2 country code (FR), ISO 3166-2 region code (US-MA), or full country name (France). Use layer=regions&filter=US to get one country's regions. Use layer=districts&filter=US for all US counties, or filter=US-MA for just Massachusetts counties. Region-level filter is required for districts — continent slugs and world are not accepted. |
|
detail |
auto |
Geometry resolution. auto (the default) serves the right level for your filter — e.g. filter=PL&layer=regions returns high (the only tier with Poland's regions) while filter=US returns low. See Detail Levels below. |
|
properties |
none |
name, nameOfficial, iso2, iso3, isoNum, continent, subregion, areakm2, population, gdp, capital, capitalLat, capitalLng, currencies, languages, idd, demonym, flag, borders |
Comma-separated list of properties to attach to each feature. Only applies to the countries layer — the worker merges these from a lookup table at request time. Omit entirely for geometry-only output (smallest response). Districts and regions include gid, name, parent_gid, and iso2 by default; the properties parameter is ignored for those layers. |
format |
topojson |
Output format. Topojson is smaller and faster to render. Geojson is more compatible with other tools. |
disputed: true property, and the 44 landlocked states carry a landlocked: true property. Supports filter, detail, properties.filter=US to get one country's regions.gid for easy data joins. Use filter=US for all US counties, or filter=US-MA for a single state. The detail parameter is ignored — districts always return at high resolution.gid. A state filter is required: filter=US-MA. Served per state at 1:500k; detail is ignored. Note: PO-box-only ZIPs have no polygon, and boundaries are census approximations. Public domain (US Census Bureau).detail.detail.detail.| Value | Source resolution | Best for | Typical file size |
|---|---|---|---|
auto default |
the right tier for your filter | “just works” — you don't pick a level | varies |
low |
110m (Natural Earth) | World maps, small insets, thumbnails | ~100 KB |
medium |
50m (Natural Earth) | Continent-level maps | ~300 KB |
high |
10m (Natural Earth) or DIVA-GIS for small countries | Country and regional maps | ~2 MB |
filter is an ISO alpha-2 country code and detail=high, the API automatically serves a higher-resolution file for ~60 small countries and territories (Monaco, Aruba, Singapore, Martinique, etc.) that are too small for Natural Earth 10m. No change to your API call is needed.
low and first appear at medium. Rather than fail silently: /v1/catalog reports each country's minDetail (the lowest detail that includes it); a single-country request that comes back empty carries a top-level notice naming the detail to use; and a world or continent request includes a top-level omitted array of every country that only exists at a higher detail.
detail=auto (the default) uses that coverage map so you never have to pick a level: a single-country request is served at the lowest tier that actually includes it. This matters most for regions — most countries' subdivisions only exist at high (filter=PL&layer=regions → high, its 16 voivodeships), while a few large federations are coarser (US → low, CA/BR/IN/AU → medium). The response carries an X-Detail-Served header with the tier you got; pass an explicit detail to override.
Only applies to the countries layer. No properties are returned by default — pass ?properties=name,iso2 to request specific fields, keeping the response as small as possible. Regions and districts include gid, name, parent_gid, and iso2 in every response automatically; passing properties has no effect on those layers.
null.areakm2 for density, or gdp for GDP-per-capita. null for territories without an estimate.null where unavailable."🇫🇷").iso2 codes of countries sharing a land border (e.g. France → ["AD","BE","DE","IT","LU","MC","ES","CH"]). Authoritative adjacency that doesn't depend on shared-arc topology — so it's complete even for countries topojson.neighbors() can't detect (France, Norway, the Netherlands, Morocco). null for island nations and territories with no land neighbours.{code, name, symbol} (ISO 4217) — most countries have one, a few have two.{code, name} — official/national languages, ISO 639-3 code plus English name.{root, suffixes} — international dialing prefix. Concatenate root + a suffix for a full calling code (e.g. root "+1", suffix "212" → +1-212, New York)."French").currencies, languages, idd, and demonym return null for territories without an official ISO 3166-1 assignment (disputed territories, Antarctica, etc. — 249 of mapjson's 265 countries/territories have a match).
https://api.mapjson.com/v1/geo
https://api.mapjson.com/v1/geo?layer=countries&filter=europe&detail=medium&properties=name,iso2
https://api.mapjson.com/v1/geo?layer=regions&filter=FR&detail=high
https://api.mapjson.com/v1/geo?layer=regions&filter=US&detail=medium
https://api.mapjson.com/v1/geo?layer=regions&filter=PL&detail=high
https://api.mapjson.com/v1/geo?layer=lakes&detail=medium&format=geojson
https://api.mapjson.com/v1/points?type=city&filter=US-MA
The default response is a topojson Topology object. The feature collection is always at topo.objects.geo regardless of which layer you requested. All responses include Access-Control-Allow-Origin: *.
{
"type": "Topology",
"objects": {
"geo": {
"type": "GeometryCollection",
"geometries": [
{
"type": "Polygon",
"arcs": [[0, 1, 2]],
"properties": {
"name": "France",
"iso2": "FR",
"iso3": "FRA",
"isoNum": "250",
"continent": "Europe",
"capital": "Paris",
"capitalLat": 48.8566,
"capitalLng": 2.3515
}
}
// ...
]
}
},
"arcs": [ ... ]
}
When no properties parameter is given, each feature's properties object is empty ({}).
Filtered topojson responses have unreferenced arcs pruned, making them significantly smaller than the equivalent geojson. Shared border arcs are deduplicated in topojson; geojson re-emits full floating-point coordinates for every feature independently.
| Request | topojson | geojson |
|---|---|---|
filter=FR&detail=low |
765 B | 2.3 KB |
filter=DE&detail=high |
27 KB | 114 KB |
filter=world&detail=low |
91 KB | 426 KB |
Sizes are uncompressed. gzip compression narrows the gap somewhat; topojson still wins for all request types.
Every feature returned by the API has a stable gid property — a string key you can use to join map geometry to your own data. gid values are always present in the response, regardless of the properties parameter.
US, FR, DE. Matches the filter parameter values and the same codes used by virtually every external dataset.US-CA, DE-BY, FR-IDF. Where Natural Earth does not carry an official ISO 3166-2 code, the HASC code is used instead (e.g. US.CA). The catalog endpoint flags which source applies.06037 (Los Angeles), 36061 (Manhattan). The first two digits are the state FIPS, which maps directly to the state's ISO 3166-2 via the catalog.02139 (Cambridge MA), 90210 (Beverly Hills). Matches the ZIP codes in your data for ~95% of use cases; parent_gid is the state's ISO 3166-2.Features below the country level carry a parent_gid property that links upward through the hierarchy. You can traverse the full tree without downloading extra geometry.
district 06037 (Los Angeles County)
└─ region US-CA (California)
└─ country US (United States)
The parent_gid of a region is always a country ISO alpha-2. The parent_gid of a district is always the state's ISO 3166-2.
The catalog lists every gid in a layer with its name, parent, and all known external codes — useful for building lookup tables or crosswalks without downloading geometry.
GET /v1/catalog?layer=countries GET /v1/catalog?layer=regions&filter=PL GET /v1/catalog?layer=districts&filter=US GET /v1/catalog?layer=districts&filter=US-MA
filter is required for regions, districts, and postal. Accepts the same values as /v1/geo: an ISO alpha-2 country code (US) or an ISO 3166-2 region code (US-MA) for districts. Omitting it returns an error. The countries layer ignores filter.
Returns a JSON array. Example entry for a region:
{
"gid": "US-CA",
"name": "California",
"layer": "regions",
"parent_gid": "US",
"iso2": "US",
"gid_source": "iso3166-2"
}
Country entries additionally carry minDetail — the lowest detail level whose geometry includes that country. Small nations that Natural Earth omits at 110m report "medium" or "high", so you can request the right detail up front instead of getting an empty response. Example country entry:
{
"gid": "CV",
"name": "Cabo Verde",
"layer": "countries",
"parent_gid": null,
"iso2": "CV",
"iso3": "CPV",
"isoNum": "132",
"continent": "Africa",
"subregion": "Western Africa",
"minDetail": "medium"
}
The gid is chosen to match codes your data already uses. Census, CDC, BLS, and most US federal sources use 5-digit FIPS for counties — join on gid directly. For countries, ISO alpha-2 is the most widely used identifier in web APIs and statistical databases. For states and international regions, ISO 3166-2 is used by Eurostat, NUTS crosswalks, and most administrative data sources. Where a dataset uses a different code system, use the catalog to build a translation table.
Use these ISO alpha-2 codes with the filter parameter (e.g. filter=DE) to retrieve a specific country.
* Informal code — not officially assigned by ISO 3166-1.
| ISO2 | ISO3 | Name |
|---|---|---|
| AF | AFG | Afghanistan |
| XA | XAX | Akrotiri * |
| AX | ALA | Åland |
| AL | ALB | Albania |
| DZ | DZA | Algeria |
| AS | ASM | American Samoa |
| AD | AND | Andorra |
| AO | AGO | Angola |
| AI | AIA | Anguilla |
| AQ | ATA | Antarctica |
| AG | ATG | Antigua and Barbuda |
| AR | ARG | Argentina |
| AM | ARM | Armenia |
| AW | ABW | Aruba |
| XH | XHX | Ashmore and Cartier Islands * |
| AU | AUS | Australia |
| AT | AUT | Austria |
| AZ | AZE | Azerbaijan |
| BS | BHS | Bahamas |
| BH | BHR | Bahrain |
| XN | XNX | Bajo Nuevo Bank * |
| BD | BGD | Bangladesh |
| BB | BRB | Barbados |
| BY | BLR | Belarus |
| BE | BEL | Belgium |
| BZ | BLZ | Belize |
| BJ | BEN | Benin |
| BM | BMU | Bermuda |
| BT | BTN | Bhutan |
| XT | XTX | Bir Tawil * |
| BO | BOL | Bolivia |
| BQ | BES | Bonaire, Sint Eustatius and Saba |
| BA | BIH | Bosnia and Herzegovina |
| BW | BWA | Botswana |
| BR | BRA | Brazil |
| XB | XBX | Brazilian Island * |
| IO | IOT | British Indian Ocean Territory |
| VG | VGB | British Virgin Islands |
| BN | BRN | Brunei |
| BG | BGR | Bulgaria |
| BF | BFA | Burkina Faso |
| BI | BDI | Burundi |
| CV | CPV | Cabo Verde |
| KH | KHM | Cambodia |
| CM | CMR | Cameroon |
| CA | CAN | Canada |
| KY | CYM | Cayman Islands |
| CF | CAF | Central African Republic |
| TD | TCD | Chad |
| CL | CHL | Chile |
| CN | CHN | China |
| CX | CXR | Christmas Island |
| XL | XLX | Clipperton Island * |
| CC | CCK | Cocos Islands |
| CO | COL | Colombia |
| KM | COM | Comoros |
| CG | COG | Congo |
| CK | COK | Cook Islands |
| XO | XOX | Coral Sea Islands * |
| CR | CRI | Costa Rica |
| HR | HRV | Croatia |
| CU | CUB | Cuba |
| CW | CUW | Curaçao |
| CY | CYP | Cyprus |
| XZ | XZX | Cyprus U.N. Buffer Zone * |
| CZ | CZE | Czechia |
| DK | DNK | Denmark |
| XD | XDX | Dhekelia * |
| DJ | DJI | Djibouti |
| DM | DMA | Dominica |
| DO | DOM | Dominican Republic |
| CD | COD | DR Congo |
| EC | ECU | Ecuador |
| EG | EGY | Egypt |
| SV | SLV | El Salvador |
| GQ | GNQ | Equatorial Guinea |
| ER | ERI | Eritrea |
| EE | EST | Estonia |
| SZ | SWZ | Eswatini |
| ET | ETH | Ethiopia |
| FK | FLK | Falkland Islands |
| FO | FRO | Faroe Islands |
| FJ | FJI | Fiji |
| FI | FIN | Finland |
| FR | FRA | France |
| GF | GUF | French Guiana |
| PF | PYF | French Polynesia |
| TF | ATF | French Southern and Antarctic Lands |
| GA | GAB | Gabon |
| GM | GMB | Gambia |
| GE | GEO | Georgia |
| DE | DEU | Germany |
| GH | GHA | Ghana |
| GI | GIB | Gibraltar |
| GR | GRC | Greece |
| GL | GRL | Greenland |
| GD | GRD | Grenada |
| GP | GLP | Guadeloupe |
| GU | GUM | Guam |
| GT | GTM | Guatemala |
| GG | GGY | Guernsey |
| GN | GIN | Guinea |
| GW | GNB | Guinea-Bissau |
| GY | GUY | Guyana |
| HT | HTI | Haiti |
| HM | HMD | Heard Island and McDonald Islands |
| HN | HND | Honduras |
| HK | HKG | Hong Kong |
| HU | HUN | Hungary |
| IS | ISL | Iceland |
| IN | IND | India |
| ID | IDN | Indonesia |
| IR | IRN | Iran |
| IQ | IRQ | Iraq |
| IE | IRL | Ireland |
| IM | IMN | Isle of Man |
| IL | ISR | Israel |
| IT | ITA | Italy |
| CI | CIV | Ivory Coast |
| JM | JAM | Jamaica |
| JP | JPN | Japan |
| JE | JEY | Jersey |
| JO | JOR | Jordan |
| KZ | KAZ | Kazakhstan |
| KE | KEN | Kenya |
| KI | KIR | Kiribati |
| XK | — | Kosovo * |
| KW | KWT | Kuwait |
| KG | KGZ | Kyrgyzstan |
| LA | LAO | Laos |
| LV | LVA | Latvia |
| LB | LBN | Lebanon |
| LS | LSO | Lesotho |
| LR | LBR | Liberia |
| LY | LBY | Libya |
| LI | LIE | Liechtenstein |
| LT | LTU | Lithuania |
| LU | LUX | Luxembourg |
| MO | MAC | Macao |
| MG | MDG | Madagascar |
| MW | MWI | Malawi |
| MY | MYS | Malaysia |
| MV | MDV | Maldives |
| ML | MLI | Mali |
| MT | MLT | Malta |
| MH | MHL | Marshall Islands |
| MQ | MTQ | Martinique |
| MR | MRT | Mauritania |
| MU | MUS | Mauritius |
| YT | MYT | Mayotte |
| MX | MEX | Mexico |
| FM | FSM | Micronesia |
| MD | MDA | Moldova |
| MC | MCO | Monaco |
| MN | MNG | Mongolia |
| ME | MNE | Montenegro |
| MS | MSR | Montserrat |
| MA | MAR | Morocco |
| MZ | MOZ | Mozambique |
| MM | MMR | Myanmar |
| NA | NAM | Namibia |
| NR | NRU | Nauru |
| NP | NPL | Nepal |
| NL | NLD | Netherlands |
| NC | NCL | New Caledonia |
| NZ | NZL | New Zealand |
| NI | NIC | Nicaragua |
| NE | NER | Niger |
| NG | NGA | Nigeria |
| NU | NIU | Niue |
| NF | NFK | Norfolk Island |
| KP | PRK | North Korea |
| MK | MKD | North Macedonia |
| XC | XCX | Northern Cyprus * |
| MP | MNP | Northern Mariana Islands |
| NO | NOR | Norway |
| OM | OMN | Oman |
| PK | PAK | Pakistan |
| PW | PLW | Palau |
| PS | PSE | Palestine |
| PA | PAN | Panama |
| PG | PNG | Papua New Guinea |
| PY | PRY | Paraguay |
| PE | PER | Peru |
| PH | PHL | Philippines |
| PN | PCN | Pitcairn Islands |
| PL | POL | Poland |
| PT | PRT | Portugal |
| PR | PRI | Puerto Rico |
| QA | QAT | Qatar |
| RE | REU | Réunion |
| RO | ROU | Romania |
| RU | RUS | Russia |
| RW | RWA | Rwanda |
| SH | SHN | Saint Helena |
| KN | KNA | Saint Kitts and Nevis |
| LC | LCA | Saint Lucia |
| PM | SPM | Saint Pierre and Miquelon |
| VC | VCT | Saint Vincent and the Grenadines |
| BL | BLM | Saint-Barthélemy |
| MF | MAF | Saint-Martin |
| WS | WSM | Samoa |
| SM | SMR | San Marino |
| ST | STP | São Tomé and Principe |
| SA | SAU | Saudi Arabia |
| XR | XRX | Scarborough Reef * |
| SN | SEN | Senegal |
| RS | SRB | Serbia |
| XE | XEX | Serranilla Bank * |
| SC | SYC | Seychelles |
| XG | XGX | Siachen Glacier * |
| SL | SLE | Sierra Leone |
| SG | SGP | Singapore |
| SX | SXM | Sint Maarten |
| SK | SVK | Slovakia |
| SI | SVN | Slovenia |
| SB | SLB | Solomon Islands |
| SO | SOM | Somalia |
| XS | XSX | Somaliland * |
| ZA | ZAF | South Africa |
| GS | SGS | South Georgia and South Sandwich Islands |
| KR | KOR | South Korea |
| SS | SSD | South Sudan |
| XF | XFX | Southern Patagonian Ice Field * |
| ES | ESP | Spain |
| XP | XPX | Spratly Islands * |
| LK | LKA | Sri Lanka |
| SD | SDN | Sudan |
| SR | SUR | Suriname |
| SJ | SJM | Svalbard and Jan Mayen |
| SE | SWE | Sweden |
| CH | CHE | Switzerland |
| SY | SYR | Syria |
| TW | TWN | Taiwan |
| TJ | TJK | Tajikistan |
| TZ | TZA | Tanzania |
| TH | THA | Thailand |
| TL | TLS | Timor-Leste |
| TG | TGO | Togo |
| TK | TKL | Tokelau |
| TO | TON | Tonga |
| TT | TTO | Trinidad and Tobago |
| TN | TUN | Tunisia |
| TR | TUR | Türkiye |
| TM | TKM | Turkmenistan |
| TC | TCA | Turks and Caicos Islands |
| TV | TUV | Tuvalu |
| UG | UGA | Uganda |
| UA | UKR | Ukraine |
| AE | ARE | United Arab Emirates |
| GB | GBR | United Kingdom |
| US | USA | United States |
| UM | UMI | United States Minor Outlying Islands |
| VI | VIR | United States Virgin Islands |
| UY | URY | Uruguay |
| UZ | UZB | Uzbekistan |
| VU | VUT | Vanuatu |
| VA | VAT | Vatican City |
| VE | VEN | Venezuela |
| VN | VNM | Vietnam |
| WF | WLF | Wallis and Futuna Islands |
| EH | ESH | Western Sahara |
| YE | YEM | Yemen |
| ZM | ZMB | Zambia |
| ZW | ZWE | Zimbabwe |
Point datasets — places rather than boundaries — are served from a separate endpoint, always as GeoJSON (points have no shared geometry, so topojson and detail don't apply). Today the only type is city; more point types will follow.
| Parameter | Default | Options | Description |
|---|---|---|---|
type |
city |
Which point dataset to return. city covers the world's most populous cities plus every national capital — each carries a capital boolean (true for national capitals). |
|
filter |
world |
Restrict to a continent, country, or region — same values as /v1/geo: a continent slug, ISO alpha-2 country code (FR), ISO 3166-2 region code (US-MA), or country name (France). Every point is pre-tagged with its country and admin1 region, so filter=US-MA returns only the points in Massachusetts. |
|
format |
geojson |
Points are GeoJSON only. |
Each feature carries name, countryIso2, countryName, continent, region (the admin-1 gid, always matching the regions layer: ISO 3166-2 where Natural Earth carries it, e.g. US-MA; Natural Earth's placeholder codes elsewhere, e.g. Kosovo's XK-X20; null only for Hargeysa — Natural Earth has no usable coding for Somaliland), popMetro, and capital (true for national capitals, false otherwise). popMetro is the metropolitan / urban-agglomeration population (e.g. Tokyo ≈ 35.7M for Greater Tokyo, not the ~9M city proper).
GET /v1/points?type=city&filter=FR — a standard GeoJSON FeatureCollection of Point features:
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": { "type": "Point", "coordinates": [2.353, 48.8581] },
"properties": {
"name": "Paris",
"nameLocal": null,
"countryIso2": "FR",
"countryName": "France",
"continent": "Europe",
"region": "FR-75",
"popMetro": 9904000,
"capital": true
}
}
// ...
]
}
Every city carries capital — true for national capitals, false otherwise. coordinates are [longitude, latitude], per GeoJSON.
Every dataset mapjson serves is open and free to use. Attribution by area:
countries, regions, districts and physical layers (110m / 50m / 10m); most country attributes (name, ISO codes, continent, subregion, capital, population, gdp); and the city / capital points, including popMetro.areakm2, currencies, languages, idd, demonym, flag, and borders.postal (US ZIP code) layer.