Skip to content

Instantly share code, notes, and snippets.

@oalders
Last active March 20, 2026 13:57
Show Gist options
  • Select an option

  • Save oalders/e9063de9e3173e7894ae5c77c05330a2 to your computer and use it in GitHub Desktop.

Select an option

Save oalders/e9063de9e3173e7894ae5c77c05330a2 to your computer and use it in GitHub Desktop.
OpenCage South Africa responses missing state_code - 10 examples

OpenCage South Africa Responses Missing state_code

Sample of reverse geocoding queries made between August 2025 and March 2026.


Example 1: Johannesburg (-26.1574, 28.1106)

Major city in Gauteng province, missing state_code.

{
  "documentation": "https://opencagedata.com/api",
  "licenses": [
    {
      "name": "see attribution guide",
      "url": "https://opencagedata.com/credits"
    }
  ],
  "results": [
    {
      "annotations": {
        "DMS": {
          "lat": "26° 9' 26.65332'' S",
          "lng": "28° 6' 37.96452'' E"
        },
        "MGRS": "35JPM1099606410",
        "Maidenhead": "KG43bu32gf",
        "Mercator": {
          "x": 3129251.633,
          "y": -2999758.208
        },
        "OSM": {
          "note_url": "https://www.openstreetmap.org/note/new#map=17/-26.15740/28.11055&layers=N",
          "url": "https://www.openstreetmap.org/?mlat=-26.15740&mlon=28.11055#map=17/-26.15740/28.11055"
        },
        "UN_M49": {
          "regions": {
            "AFRICA": "002",
            "SOUTHERN_AFRICA": "018",
            "SUB-SAHARAN_AFRICA": "202",
            "WORLD": "001",
            "ZA": "710"
          },
          "statistical_groupings": ["LEDC"]
        },
        "callingcode": 27,
        "currency": {
          "iso_code": "ZAR",
          "name": "South African Rand",
          "symbol": "R"
        },
        "flag": "🇿🇦",
        "geohash": "ke7gpwjqp4w14gwfp56s",
        "timezone": {
          "name": "Africa/Johannesburg",
          "offset_string": "+0200",
          "short_name": "SAST"
        }
      },
      "components": {
        "ISO_3166-1_alpha-2": "ZA",
        "ISO_3166-1_alpha-3": "ZAF",
        "_category": "building",
        "_normalized_city": "Johannesburg",
        "_type": "building",
        "city": "Johannesburg",
        "continent": "Africa",
        "country": "South Africa",
        "country_code": "za",
        "house_number": "35",
        "postcode": "",
        "road": "Stone Way"
      },
      "confidence": 10,
      "formatted": "35 Stone Way, Johannesburg, South Africa",
      "geometry": {
        "lat": -26.1574037,
        "lng": 28.1105457
      }
    }
  ],
  "status": {
    "code": 200,
    "message": "OK"
  },
  "timestamp": {
    "created_http": "Wed, 20 Aug 2025 19:18:31 GMT",
    "created_unix": 1755717511
  },
  "total_results": 1
}

Example 2: Cape Town (-33.9599, 18.4809)

Major city in Western Cape province, missing state_code.

{
  "documentation": "https://opencagedata.com/api",
  "licenses": [
    {
      "name": "see attribution guide",
      "url": "https://opencagedata.com/credits"
    }
  ],
  "results": [
    {
      "annotations": {
        "DMS": {
          "lat": "33° 57' 35.65656'' S",
          "lng": "18° 28' 51.29868'' E"
        },
        "MGRS": "34HBH6723039430",
        "Maidenhead": "JF96fa79ro",
        "OSM": {
          "note_url": "https://www.openstreetmap.org/note/new#map=17/-33.95990/18.48092&layers=N",
          "url": "https://www.openstreetmap.org/?mlat=-33.95990&mlon=18.48092#map=17/-33.95990/18.48092"
        },
        "UN_M49": {
          "regions": {
            "AFRICA": "002",
            "SOUTHERN_AFRICA": "018",
            "SUB-SAHARAN_AFRICA": "202",
            "WORLD": "001",
            "ZA": "710"
          },
          "statistical_groupings": ["LEDC"]
        },
        "callingcode": 27,
        "flag": "🇿🇦",
        "geohash": "k3vnu9c3hwcyr3pz2jed",
        "timezone": {
          "name": "Africa/Johannesburg",
          "offset_string": "+0200",
          "short_name": "SAST"
        }
      },
      "components": {
        "ISO_3166-1_alpha-2": "ZA",
        "ISO_3166-1_alpha-3": "ZAF",
        "_category": "building",
        "_normalized_city": "Cape Town",
        "_type": "building",
        "city": "Cape Town",
        "continent": "Africa",
        "country": "South Africa",
        "country_code": "za",
        "house_number": "8",
        "postcode": "",
        "road": "Park"
      },
      "confidence": 10,
      "formatted": "8 Park, Cape Town, South Africa",
      "geometry": {
        "lat": -33.9599046,
        "lng": 18.4809163
      }
    }
  ],
  "status": {
    "code": 200,
    "message": "OK"
  },
  "timestamp": {
    "created_http": "Wed, 20 Aug 2025 19:18:21 GMT",
    "created_unix": 1755717501
  },
  "total_results": 1
}

Example 3: Cape Town (-33.9084, 18.4061) - Another Cape Town location

{
  "documentation": "https://opencagedata.com/api",
  "licenses": [
    {
      "name": "see attribution guide",
      "url": "https://opencagedata.com/credits"
    }
  ],
  "results": [
    {
      "annotations": {
        "DMS": {
          "lat": "33° 54' 30.38904'' S",
          "lng": "18° 24' 21.90636'' E"
        },
        "MGRS": "34HBH6016944965",
        "Maidenhead": "JF96ec81rx",
        "OSM": {
          "note_url": "https://www.openstreetmap.org/note/new#map=17/-33.90844/18.40609&layers=N",
          "url": "https://www.openstreetmap.org/?mlat=-33.90844&mlon=18.40609#map=17/-33.90844/18.40609"
        },
        "UN_M49": {
          "regions": {
            "AFRICA": "002",
            "SOUTHERN_AFRICA": "018",
            "SUB-SAHARAN_AFRICA": "202",
            "WORLD": "001",
            "ZA": "710"
          },
          "statistical_groupings": ["LEDC"]
        },
        "callingcode": 27,
        "flag": "🇿🇦",
        "timezone": {
          "name": "Africa/Johannesburg",
          "offset_string": "+0200",
          "short_name": "SAST"
        }
      },
      "components": {
        "ISO_3166-1_alpha-2": "ZA",
        "ISO_3166-1_alpha-3": "ZAF",
        "_category": "building",
        "_normalized_city": "Cape Town",
        "_type": "building",
        "city": "Cape Town",
        "continent": "Africa",
        "country": "South Africa",
        "country_code": "za",
        "house_number": "32",
        "postcode": "",
        "road": "Sydney Road"
      },
      "confidence": 10,
      "formatted": "32 Sydney Road, Cape Town, South Africa",
      "geometry": {
        "lat": -33.9084414,
        "lng": 18.4060851
      }
    }
  ],
  "status": {
    "code": 200,
    "message": "OK"
  },
  "timestamp": {
    "created_http": "Sat, 21 Feb 2026 18:22:34 GMT",
    "created_unix": 1771698154
  },
  "total_results": 1
}

Example 4: Kempton Park (-26.1041, 28.2168)

City in Gauteng province, missing state_code.

{
  "documentation": "https://opencagedata.com/api",
  "licenses": [
    {
      "name": "see attribution guide",
      "url": "https://opencagedata.com/credits"
    }
  ],
  "results": [
    {
      "annotations": {
        "DMS": {
          "lat": "26° 6' 14.88312'' S",
          "lng": "28° 13' 0.49944'' E"
        },
        "MGRS": "35JPM2167312215",
        "Maidenhead": "KG43cv65aa",
        "OSM": {
          "note_url": "https://www.openstreetmap.org/note/new#map=17/-26.10413/28.21681&layers=N",
          "url": "https://www.openstreetmap.org/?mlat=-26.10413&mlon=28.21681#map=17/-26.10413/28.21681"
        },
        "UN_M49": {
          "regions": {
            "AFRICA": "002",
            "SOUTHERN_AFRICA": "018",
            "SUB-SAHARAN_AFRICA": "202",
            "WORLD": "001",
            "ZA": "710"
          },
          "statistical_groupings": ["LEDC"]
        },
        "callingcode": 27,
        "flag": "🇿🇦",
        "timezone": {
          "name": "Africa/Johannesburg",
          "offset_string": "+0200",
          "short_name": "SAST"
        }
      },
      "components": {
        "ISO_3166-1_alpha-2": "ZA",
        "ISO_3166-1_alpha-3": "ZAF",
        "_category": "place",
        "_normalized_city": "Kempton Park",
        "_type": "city",
        "city": "Kempton Park",
        "continent": "Africa",
        "country": "South Africa",
        "country_code": "za",
        "postcode": ""
      },
      "confidence": 10,
      "formatted": "Kempton Park, South Africa",
      "geometry": {
        "lat": -26.1041342,
        "lng": 28.2168054
      }
    }
  ],
  "status": {
    "code": 200,
    "message": "OK"
  },
  "timestamp": {
    "created_http": "Sun, 31 Aug 2025 23:07:15 GMT",
    "created_unix": 1756681635
  },
  "total_results": 1
}

Example 5: Benoni (-26.1466, 28.3520)

City in Gauteng province, missing state_code.

{
  "documentation": "https://opencagedata.com/api",
  "licenses": [
    {
      "name": "see attribution guide",
      "url": "https://opencagedata.com/credits"
    }
  ],
  "results": [
    {
      "annotations": {
        "DMS": {
          "lat": "26° 8' 47.76720'' S",
          "lng": "28° 21' 7.26084'' E"
        },
        "MGRS": "35JPM3514607378",
        "Maidenhead": "KG43eu24ft",
        "OSM": {
          "note_url": "https://www.openstreetmap.org/note/new#map=17/-26.14660/28.35202&layers=N",
          "url": "https://www.openstreetmap.org/?mlat=-26.14660&mlon=28.35202#map=17/-26.14660/28.35202"
        },
        "UN_M49": {
          "regions": {
            "AFRICA": "002",
            "SOUTHERN_AFRICA": "018",
            "SUB-SAHARAN_AFRICA": "202",
            "WORLD": "001",
            "ZA": "710"
          },
          "statistical_groupings": ["LEDC"]
        },
        "callingcode": 27,
        "flag": "🇿🇦",
        "timezone": {
          "name": "Africa/Johannesburg",
          "offset_string": "+0200",
          "short_name": "SAST"
        }
      },
      "components": {
        "ISO_3166-1_alpha-2": "ZA",
        "ISO_3166-1_alpha-3": "ZAF",
        "_category": "road",
        "_normalized_city": "Benoni",
        "_type": "road",
        "city": "Benoni",
        "continent": "Africa",
        "country": "South Africa",
        "country_code": "za",
        "postcode": "",
        "road": "Street"
      },
      "confidence": 10,
      "formatted": "Street, Benoni, South Africa",
      "geometry": {
        "lat": -26.146602,
        "lng": 28.3520169
      }
    }
  ],
  "status": {
    "code": 200,
    "message": "OK"
  },
  "timestamp": {
    "created_http": "Wed, 20 Aug 2025 19:18:14 GMT",
    "created_unix": 1755717494
  },
  "total_results": 1
}

Example 6: Virginia (-28.0946, 26.8745)

Town in Free State province, missing state_code.

{
  "documentation": "https://opencagedata.com/api",
  "licenses": [
    {
      "name": "see attribution guide",
      "url": "https://opencagedata.com/credits"
    }
  ],
  "results": [
    {
      "annotations": {
        "DMS": {
          "lat": "28° 5' 40.58808'' S",
          "lng": "26° 52' 28.02180'' E"
        },
        "MGRS": "35JMJ8766692311",
        "Maidenhead": "KG31kv47wh",
        "OSM": {
          "note_url": "https://www.openstreetmap.org/note/new#map=17/-28.09461/26.87445&layers=N",
          "url": "https://www.openstreetmap.org/?mlat=-28.09461&mlon=26.87445#map=17/-28.09461/26.87445"
        },
        "UN_M49": {
          "regions": {
            "AFRICA": "002",
            "SOUTHERN_AFRICA": "018",
            "SUB-SAHARAN_AFRICA": "202",
            "WORLD": "001",
            "ZA": "710"
          },
          "statistical_groupings": ["LEDC"]
        },
        "callingcode": 27,
        "flag": "🇿🇦",
        "timezone": {
          "name": "Africa/Johannesburg",
          "offset_string": "+0200",
          "short_name": "SAST"
        }
      },
      "components": {
        "ISO_3166-1_alpha-2": "ZA",
        "ISO_3166-1_alpha-3": "ZAF",
        "_category": "road",
        "_normalized_city": "Virginia",
        "_type": "road",
        "city": "Virginia",
        "continent": "Africa",
        "country": "South Africa",
        "country_code": "za",
        "postcode": "",
        "road": "Abel Street"
      },
      "confidence": 10,
      "formatted": "Abel Street, Virginia, South Africa",
      "geometry": {
        "lat": -28.0946078,
        "lng": 26.8744505
      }
    }
  ],
  "status": {
    "code": 200,
    "message": "OK"
  },
  "timestamp": {
    "created_http": "Wed, 20 Aug 2025 19:25:39 GMT",
    "created_unix": 1755717939
  },
  "total_results": 1
}

Example 7: Groblersdal (-25.1713, 29.4016)

Town in Limpopo province, missing state_code.

{
  "documentation": "https://opencagedata.com/api",
  "licenses": [
    {
      "name": "see attribution guide",
      "url": "https://opencagedata.com/credits"
    }
  ],
  "results": [
    {
      "annotations": {
        "DMS": {
          "lat": "25° 10' 16.73148'' S",
          "lng": "29° 24' 5.68044'' E"
        },
        "MGRS": "35JQN4205013924",
        "Maidenhead": "KG44qt88ev",
        "OSM": {
          "note_url": "https://www.openstreetmap.org/note/new#map=17/-25.17131/29.40158&layers=N",
          "url": "https://www.openstreetmap.org/?mlat=-25.17131&mlon=29.40158#map=17/-25.17131/29.40158"
        },
        "UN_M49": {
          "regions": {
            "AFRICA": "002",
            "SOUTHERN_AFRICA": "018",
            "SUB-SAHARAN_AFRICA": "202",
            "WORLD": "001",
            "ZA": "710"
          },
          "statistical_groupings": ["LEDC"]
        },
        "callingcode": 27,
        "flag": "🇿🇦",
        "timezone": {
          "name": "Africa/Johannesburg",
          "offset_string": "+0200",
          "short_name": "SAST"
        }
      },
      "components": {
        "ISO_3166-1_alpha-2": "ZA",
        "ISO_3166-1_alpha-3": "ZAF",
        "_category": "building",
        "_normalized_city": "Groblersdal",
        "_type": "building",
        "city": "Groblersdal",
        "continent": "Africa",
        "country": "South Africa",
        "country_code": "za",
        "house_number": "2",
        "postcode": "",
        "road": "Voortrekker Street"
      },
      "confidence": 10,
      "formatted": "2 Voortrekker Street, Groblersdal, South Africa",
      "geometry": {
        "lat": -25.1713143,
        "lng": 29.4015779
      }
    }
  ],
  "status": {
    "code": 200,
    "message": "OK"
  },
  "timestamp": {
    "created_http": "Wed, 20 Aug 2025 19:43:43 GMT",
    "created_unix": 1755719023
  },
  "total_results": 1
}

Example 8: Oudtshoorn Nu (-33.5344, 22.2340)

Town in Western Cape province, missing state_code.

{
  "documentation": "https://opencagedata.com/api",
  "licenses": [
    {
      "name": "see attribution guide",
      "url": "https://opencagedata.com/credits"
    }
  ],
  "results": [
    {
      "annotations": {
        "DMS": {
          "lat": "33° 32' 3.96168'' S",
          "lng": "22° 14' 2.38704'' E"
        },
        "MGRS": "34HFH1457888781",
        "Maidenhead": "KF16cl81br",
        "OSM": {
          "note_url": "https://www.openstreetmap.org/note/new#map=17/-33.53443/22.23400&layers=N",
          "url": "https://www.openstreetmap.org/?mlat=-33.53443&mlon=22.23400#map=17/-33.53443/22.23400"
        },
        "UN_M49": {
          "regions": {
            "AFRICA": "002",
            "SOUTHERN_AFRICA": "018",
            "SUB-SAHARAN_AFRICA": "202",
            "WORLD": "001",
            "ZA": "710"
          },
          "statistical_groupings": ["LEDC"]
        },
        "callingcode": 27,
        "flag": "🇿🇦",
        "timezone": {
          "name": "Africa/Johannesburg",
          "offset_string": "+0200",
          "short_name": "SAST"
        }
      },
      "components": {
        "ISO_3166-1_alpha-2": "ZA",
        "ISO_3166-1_alpha-3": "ZAF",
        "_category": "road",
        "_normalized_city": "Oudtshoorn Nu",
        "_type": "road",
        "city": "Oudtshoorn Nu",
        "continent": "Africa",
        "country": "South Africa",
        "country_code": "za",
        "postcode": "",
        "road": "Street"
      },
      "confidence": 10,
      "formatted": "Street, Oudtshoorn Nu, South Africa",
      "geometry": {
        "lat": -33.5344338,
        "lng": 22.2339964
      }
    }
  ],
  "status": {
    "code": 200,
    "message": "OK"
  },
  "timestamp": {
    "created_http": "Wed, 20 Aug 2025 19:17:59 GMT",
    "created_unix": 1755717479
  },
  "total_results": 1
}

Example 9: Overstrand Nu (-34.5874, 19.4004)

Coastal area in Western Cape province, missing state_code.

{
  "documentation": "https://opencagedata.com/api",
  "licenses": [
    {
      "name": "see attribution guide",
      "url": "https://opencagedata.com/credits"
    }
  ],
  "results": [
    {
      "annotations": {
        "DMS": {
          "lat": "34° 35' 14.76060'' S",
          "lng": "19° 24' 1.26612'' E"
        },
        "MGRS": "34HCG5329371544",
        "Maidenhead": "JF95qj89ba",
        "OSM": {
          "note_url": "https://www.openstreetmap.org/note/new#map=16/-34.58743/19.40035&layers=N",
          "url": "https://www.openstreetmap.org/?mlat=-34.58743&mlon=19.40035#map=16/-34.58743/19.40035"
        },
        "UN_M49": {
          "regions": {
            "AFRICA": "002",
            "SOUTHERN_AFRICA": "018",
            "SUB-SAHARAN_AFRICA": "202",
            "WORLD": "001",
            "ZA": "710"
          },
          "statistical_groupings": ["LEDC"]
        },
        "callingcode": 27,
        "flag": "🇿🇦",
        "timezone": {
          "name": "Africa/Johannesburg",
          "offset_string": "+0200",
          "short_name": "SAST"
        }
      },
      "components": {
        "ISO_3166-1_alpha-2": "ZA",
        "ISO_3166-1_alpha-3": "ZAF",
        "_category": "place",
        "_normalized_city": "Overstrand Nu",
        "_type": "city",
        "city": "Overstrand Nu",
        "continent": "Africa",
        "country": "South Africa",
        "country_code": "za",
        "postcode": ""
      },
      "confidence": 10,
      "formatted": "Overstrand Nu, South Africa",
      "geometry": {
        "lat": -34.5874335,
        "lng": 19.4003517
      }
    }
  ],
  "status": {
    "code": 200,
    "message": "OK"
  },
  "timestamp": {
    "created_http": "Thu, 05 Feb 2026 06:10:41 GMT",
    "created_unix": 1770271841
  },
  "total_results": 1
}

Example 10: Kgetleng River Local Municipality (-25.8594, 26.8972)

Interesting case: Has state ("North West") and ISO_3166-2 (["ZA-NW"]) but NO state_code.

{
  "documentation": "https://opencagedata.com/api",
  "licenses": [
    {
      "name": "see attribution guide",
      "url": "https://opencagedata.com/credits"
    }
  ],
  "results": [
    {
      "annotations": {
        "DMS": {
          "lat": "25° 51' 33.99840'' S",
          "lng": "26° 53' 49.99920'' E"
        },
        "MGRS": "35JMM8970239877",
        "Maidenhead": "KG34kd73qr",
        "OSM": {
          "edit_url": "https://www.openstreetmap.org/edit?node=262720865#map=16/-25.85944/26.89722",
          "note_url": "https://www.openstreetmap.org/note/new#map=16/-25.85944/26.89722&layers=N",
          "url": "https://www.openstreetmap.org/?mlat=-25.85944&mlon=26.89722#map=16/-25.85944/26.89722"
        },
        "UN_M49": {
          "regions": {
            "AFRICA": "002",
            "SOUTHERN_AFRICA": "018",
            "SUB-SAHARAN_AFRICA": "202",
            "WORLD": "001",
            "ZA": "710"
          },
          "statistical_groupings": ["LEDC"]
        },
        "callingcode": 27,
        "flag": "🇿🇦",
        "timezone": {
          "name": "Africa/Johannesburg",
          "offset_string": "+0200",
          "short_name": "SAST"
        },
        "wikidata": "Q3643783"
      },
      "bounds": {
        "northeast": {
          "lat": -25.819444,
          "lng": 26.937222
        },
        "southwest": {
          "lat": -25.899444,
          "lng": 26.857222
        }
      },
      "components": {
        "ISO_3166-1_alpha-2": "ZA",
        "ISO_3166-1_alpha-3": "ZAF",
        "ISO_3166-2": ["ZA-NW"],
        "_category": "place",
        "_normalized_city": "Kgetleng River Local Municipality",
        "_type": "city",
        "city": "Kgetleng River Local Municipality",
        "continent": "Africa",
        "country": "South Africa",
        "country_code": "za",
        "county": "Bojanala Platinum District Municipality",
        "postcode": "8348",
        "state": "North West",
        "town": "Koster"
      },
      "confidence": 7,
      "formatted": "Kgetleng River Local Municipality, Bojanala Platinum District Municipality, South Africa",
      "geometry": {
        "lat": -25.859444,
        "lng": 26.897222
      }
    }
  ],
  "status": {
    "code": 200,
    "message": "OK"
  },
  "timestamp": {
    "created_http": "Sun, 08 Feb 2026 20:56:12 GMT",
    "created_unix": 1770584172
  },
  "total_results": 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment