mapjson

Geographic map data as a single API call

https://api.mapjson.com

Overview

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 => { /* ... */ });

Endpoint

GET/v1/geo
  ?layer=countries
  &filter=world
  &detail=low
  &properties=name,iso2,capital
  &format=topojson
Parameter Default Options Description
layer countries
countries regions lakes rivers coastlines
Which geographic layer to return. All layers return polygon or line geometry. See Layers below.
filter world
world europe asia africa north-america south-america oceania antarctica {ISO2}
Filters output to a continent or a specific country (ISO alpha-2 code, e.g. FR). Use {ISO2} with layer=regions to get the administrative regions of one country.
detail low
low medium high ultra
Geometry resolution. See Detail Levels below.
properties none name, nameOfficial, iso2, iso3, isoNum, continent, subregion, capital, capitalLat, capitalLng Comma-separated list of properties to attach to each feature. Omit entirely for geometry-only output (smallest response). Only applies to countries and regions layers.
format topojson
topojson geojson
Output format. Topojson is smaller and faster to render. Geojson is more compatible with other tools.

Layers

countries
polygon
Sovereign countries and territories. All territories included — disputed ones carry a disputed: true property. Supports filter, detail, properties.
regions
polygon
First-level administrative divisions — US states, French departments, German Länder, Polish voivodeships, etc. Use filter=US to get one country's regions.
lakes
polygon
Major lakes and inland water bodies. Supports detail.
rivers
line
Rivers and lake centerlines. Supports detail.
coastlines
line
World coastlines. Supports detail.

Detail Levels

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) Country and regional maps ~2 MB
ultra OSM / GADM Small countries (Andorra, Monaco, Singapore) varies
ultra is not yet available — currently falls back to high.

Properties

Available on countries and regions layers. No properties are returned by default — pass ?properties=name,iso2 to request specific fields. This keeps the default response as small as possible.

nameShort English name (e.g. "France")
nameOfficialFormal name (e.g. "French Republic")
iso2ISO 3166-1 alpha-2 (e.g. "FR")
iso3ISO 3166-1 alpha-3 (e.g. "FRA")
isoNumISO 3166-1 numeric (e.g. "250")
continentContinent name (e.g. "Europe")
subregionSubregion (e.g. "Western Europe")
capitalCapital city name (e.g. "Paris")
capitalLatCapital latitude
capitalLngCapital longitude

Examples

Minimal — world countries, 110m, no properties
https://api.mapjson.com/v1/geo
Europe countries with name and ISO code
https://api.mapjson.com/v1/geo?layer=countries&filter=europe&detail=medium&properties=name,iso2
France administrative regions (departments), high detail
https://api.mapjson.com/v1/geo?layer=regions&filter=FR&detail=high
USA states, medium detail
https://api.mapjson.com/v1/geo?layer=regions&filter=US&detail=medium
Poland voivodeships, high detail
https://api.mapjson.com/v1/geo?layer=regions&filter=PL&detail=high
World lakes, medium detail, as GeoJSON
https://api.mapjson.com/v1/geo?layer=lakes&detail=medium&format=geojson

Response

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: *.

topojson
{
  "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": [ ... ],
  "bbox": [-180, -90, 180, 90]
}

When no properties parameter is given, each feature's properties object is empty ({}).

Country Codes

Use these ISO alpha-2 codes with the filter parameter (e.g. filter=DE) to retrieve a specific country.

235 countries and territories

* Informal code — not officially assigned by ISO 3166-1.

ISO2 ISO3 Name
AFAFGAfghanistan
AXALAÅland
ALALBAlbania
DZDZAAlgeria
ASASMAmerican Samoa
ADANDAndorra
AOAGOAngola
AIAIAAnguilla
AQATAAntarctica
AGATGAntigua and Barb.
ARARGArgentina
AMARMArmenia
AWABWAruba
ATAUTAustria
AZAZEAzerbaijan
BSBHSBahamas
BHBHRBahrain
BDBGDBangladesh
BBBRBBarbados
BYBLRBelarus
BEBELBelgium
BZBLZBelize
BJBENBenin
BMBMUBermuda
BTBTNBhutan
BOBOLBolivia
BABIHBosnia and Herz.
BWBWABotswana
IOIOTBr. Indian Ocean Ter.
BRBRABrazil
VGVGBBritish Virgin Is.
BNBRNBrunei
BGBGRBulgaria
BFBFABurkina Faso
BIBDIBurundi
CVCPVCabo Verde
KHKHMCambodia
CMCMRCameroon
CACANCanada
KYCYMCayman Is.
CFCAFCentral African Rep.
TDTCDChad
CLCHLChile
CNCHNChina
COCOLColombia
KMCOMComoros
CGCOGCongo
CKCOKCook Is.
CRCRICosta Rica
CICIVCôte d'Ivoire
HRHRVCroatia
CUCUBCuba
CWCUWCuraçao
CYCYPCyprus
CZCZECzechia
CDCODDem. Rep. Congo
DKDNKDenmark
DJDJIDjibouti
DMDMADominica
DODOMDominican Rep.
ECECUEcuador
EGEGYEgypt
SVSLVEl Salvador
GQGNQEq. Guinea
ERERIEritrea
EEESTEstonia
SZSWZeSwatini
ETETHEthiopia
FOFROFaeroe Is.
FKFLKFalkland Is.
FJFJIFiji
FIFINFinland
PFPYFFr. Polynesia
TFATFFr. S. Antarctic Lands
GAGABGabon
GMGMBGambia
GEGEOGeorgia
DEDEUGermany
GHGHAGhana
GIGIBGibraltar
GRGRCGreece
GLGRLGreenland
GDGRDGrenada
GUGUMGuam
GTGTMGuatemala
GGGGYGuernsey
GNGINGuinea
GWGNBGuinea-Bissau
GYGUYGuyana
HTHTIHaiti
HMHMDHeard I. and McDonald Is.
HNHNDHonduras
HKHKGHong Kong
HUHUNHungary
ISISLIceland
ININDIndia
IDIDNIndonesia
IRIRNIran
IQIRQIraq
IEIRLIreland
IMIMNIsle of Man
ILISRIsrael
ITITAItaly
JMJAMJamaica
JPJPNJapan
JEJEYJersey
JOJORJordan
KZKAZKazakhstan
KEKENKenya
KIKIRKiribati
XKXKXKosovo *
KWKWTKuwait
KGKGZKyrgyzstan
LALAOLaos
LVLVALatvia
LBLBNLebanon
LSLSOLesotho
LRLBRLiberia
LYLBYLibya
LILIELiechtenstein
LTLTULithuania
LULUXLuxembourg
MOMACMacao
MGMDGMadagascar
MWMWIMalawi
MYMYSMalaysia
MVMDVMaldives
MLMLIMali
MTMLTMalta
MHMHLMarshall Is.
MRMRTMauritania
MUMUSMauritius
MXMEXMexico
FMFSMMicronesia
MDMDAMoldova
MCMCOMonaco
MNMNGMongolia
MEMNEMontenegro
MSMSRMontserrat
MAMARMorocco
MZMOZMozambique
MMMMRMyanmar
MPMNPN. Mariana Is.
NANAMNamibia
NRNRUNauru
NPNPLNepal
NLNLDNetherlands
NCNCLNew Caledonia
NZNZLNew Zealand
NINICNicaragua
NENERNiger
NGNGANigeria
NUNIUNiue
NFNFKNorfolk Island
KPPRKNorth Korea
MKMKDNorth Macedonia
OMOMNOman
PKPAKPakistan
PWPLWPalau
PSPSEPalestine
PAPANPanama
PGPNGPapua New Guinea
PYPRYParaguay
PEPERPeru
PHPHLPhilippines
PNPCNPitcairn Is.
PLPOLPoland
PTPRTPortugal
PRPRIPuerto Rico
QAQATQatar
ROROURomania
RURUSRussia
RWRWARwanda
GSSGSS. Geo. and the Is.
SSSSDS. Sudan
SHSHNSaint Helena
LCLCASaint Lucia
WSWSMSamoa
SMSMRSan Marino
STSTPSão Tomé and Principe
SASAUSaudi Arabia
SNSENSenegal
RSSRBSerbia
SCSYCSeychelles
SLSLESierra Leone
SGSGPSingapore
SXSXMSint Maarten
SKSVKSlovakia
SISVNSlovenia
SBSLBSolomon Is.
SOSOMSomalia
ZAZAFSouth Africa
KRKORSouth Korea
ESESPSpain
LKLKASri Lanka
BLBLMSt-Barthélemy
MFMAFSt-Martin
KNKNASt. Kitts and Nevis
PMSPMSt. Pierre and Miquelon
VCVCTSt. Vin. and Gren.
SDSDNSudan
SRSURSuriname
SESWESweden
CHCHESwitzerland
SYSYRSyria
CN-TWTWNTaiwan
TJTJKTajikistan
TZTZATanzania
THTHAThailand
TLTLSTimor-Leste
TGTGOTogo
TOTONTonga
TTTTOTrinidad and Tobago
TNTUNTunisia
TRTURTurkey
TMTKMTurkmenistan
TCTCATurks and Caicos Is.
TVTUVTuvalu
UMUMIU.S. Minor Outlying Is.
VIVIRU.S. Virgin Is.
UGUGAUganda
UAUKRUkraine
AEAREUnited Arab Emirates
GBGBRUnited Kingdom
USUSAUnited States of America
UYURYUruguay
UZUZBUzbekistan
VUVUTVanuatu
VAVATVatican
VEVENVenezuela
VNVNMVietnam
EHESHW. Sahara
WFWLFWallis and Futuna Is.
YEYEMYemen
ZMZMBZambia
ZWZWEZimbabwe