Geographic map data as a single API call
mapjson returns topojson (or geojson) for any geographic layer in a single AJAX call. The shortest possible call returns 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 |
low |
Geometry resolution. See Detail Levels below. | |
properties |
none |
name, nameOfficial, iso2, iso3, isoNum, continent, subregion, areakm2, capital, capitalLat, capitalLng |
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. 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 |
|---|---|---|---|
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.
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 for very small territories below 10m resolution (e.g. Vatican City).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
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"
}
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 |
| 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 Barb. |
| AR | ARG | Argentina |
| AM | ARM | Armenia |
| AW | ABW | Aruba |
| AT | AUT | Austria |
| AZ | AZE | Azerbaijan |
| BS | BHS | Bahamas |
| BH | BHR | Bahrain |
| BD | BGD | Bangladesh |
| BB | BRB | Barbados |
| BY | BLR | Belarus |
| BE | BEL | Belgium |
| BZ | BLZ | Belize |
| BJ | BEN | Benin |
| BM | BMU | Bermuda |
| BT | BTN | Bhutan |
| BO | BOL | Bolivia |
| BA | BIH | Bosnia and Herz. |
| BW | BWA | Botswana |
| IO | IOT | Br. Indian Ocean Ter. |
| BR | BRA | Brazil |
| VG | VGB | British Virgin Is. |
| 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 Is. |
| CF | CAF | Central African Rep. |
| TD | TCD | Chad |
| CL | CHL | Chile |
| CN | CHN | China |
| CO | COL | Colombia |
| KM | COM | Comoros |
| CG | COG | Congo |
| CK | COK | Cook Is. |
| CR | CRI | Costa Rica |
| CI | CIV | Côte d'Ivoire |
| HR | HRV | Croatia |
| CU | CUB | Cuba |
| CW | CUW | Curaçao |
| CY | CYP | Cyprus |
| CZ | CZE | Czechia |
| CD | COD | Dem. Rep. Congo |
| DK | DNK | Denmark |
| DJ | DJI | Djibouti |
| DM | DMA | Dominica |
| DO | DOM | Dominican Rep. |
| EC | ECU | Ecuador |
| EG | EGY | Egypt |
| SV | SLV | El Salvador |
| GQ | GNQ | Eq. Guinea |
| ER | ERI | Eritrea |
| EE | EST | Estonia |
| SZ | SWZ | eSwatini |
| ET | ETH | Ethiopia |
| FO | FRO | Faeroe Is. |
| FK | FLK | Falkland Is. |
| FJ | FJI | Fiji |
| FI | FIN | Finland |
| PF | PYF | Fr. Polynesia |
| TF | ATF | Fr. S. 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 |
| 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 I. and McDonald Is. |
| 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 |
| JM | JAM | Jamaica |
| JP | JPN | Japan |
| JE | JEY | Jersey |
| JO | JOR | Jordan |
| KZ | KAZ | Kazakhstan |
| KE | KEN | Kenya |
| KI | KIR | Kiribati |
| XK | XKX | 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 Is. |
| MR | MRT | Mauritania |
| MU | MUS | Mauritius |
| 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 |
| MP | MNP | N. Mariana Is. |
| 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 |
| 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 Is. |
| PL | POL | Poland |
| PT | PRT | Portugal |
| PR | PRI | Puerto Rico |
| QA | QAT | Qatar |
| RO | ROU | Romania |
| RU | RUS | Russia |
| RW | RWA | Rwanda |
| GS | SGS | S. Geo. and the Is. |
| SS | SSD | S. Sudan |
| SH | SHN | Saint Helena |
| LC | LCA | Saint Lucia |
| WS | WSM | Samoa |
| SM | SMR | San Marino |
| ST | STP | São Tomé and Principe |
| SA | SAU | Saudi Arabia |
| SN | SEN | Senegal |
| RS | SRB | Serbia |
| SC | SYC | Seychelles |
| SL | SLE | Sierra Leone |
| SG | SGP | Singapore |
| SX | SXM | Sint Maarten |
| SK | SVK | Slovakia |
| SI | SVN | Slovenia |
| SB | SLB | Solomon Is. |
| SO | SOM | Somalia |
| ZA | ZAF | South Africa |
| KR | KOR | South Korea |
| ES | ESP | Spain |
| LK | LKA | Sri Lanka |
| BL | BLM | St-Barthélemy |
| MF | MAF | St-Martin |
| KN | KNA | St. Kitts and Nevis |
| PM | SPM | St. Pierre and Miquelon |
| VC | VCT | St. Vin. and Gren. |
| SD | SDN | Sudan |
| SR | SUR | Suriname |
| SE | SWE | Sweden |
| CH | CHE | Switzerland |
| SY | SYR | Syria |
| CN-TW | TWN | Taiwan |
| TJ | TJK | Tajikistan |
| TZ | TZA | Tanzania |
| TH | THA | Thailand |
| TL | TLS | Timor-Leste |
| TG | TGO | Togo |
| TO | TON | Tonga |
| TT | TTO | Trinidad and Tobago |
| TN | TUN | Tunisia |
| TR | TUR | Turkey |
| TM | TKM | Turkmenistan |
| TC | TCA | Turks and Caicos Is. |
| TV | TUV | Tuvalu |
| UM | UMI | U.S. Minor Outlying Is. |
| VI | VIR | U.S. Virgin Is. |
| UG | UGA | Uganda |
| UA | UKR | Ukraine |
| AE | ARE | United Arab Emirates |
| GB | GBR | United Kingdom |
| US | USA | United States of America |
| UY | URY | Uruguay |
| UZ | UZB | Uzbekistan |
| VU | VUT | Vanuatu |
| VA | VAT | Vatican |
| VE | VEN | Venezuela |
| VN | VNM | Vietnam |
| EH | ESH | W. Sahara |
| WF | WLF | Wallis and Futuna Is. |
| YE | YEM | Yemen |
| ZM | ZMB | Zambia |
| ZW | ZWE | Zimbabwe |