Location API

The Location API is available from version v0.5.

List Locations

URL: https://www.commcarehq.org/a/[domain]/api/[version]/location/

Locations can be filtered by the following attributes as request parameters:

  • site_code

  • external_id

  • created_at

  • last_modified

  • latitude

  • longitude

Sample output:

    {
      "meta": {
        "limit": 20,
        "next": null,
        "offset": 0,
        "previous": null,
        "total_count": 2
      },
      "objects": [
        {
          "created_at": "2023-05-09T16:10:47.225938",
          "domain": "[domain]",
          "external_id": null,
          "id": 1,
          "last_modified": "2023-05-09T16:10:47.225947",
          "latitude": null,
          "location_data": {},
          "location_id": "f373a6837c1243938abfc56618cce88b",
          "location_type": "https://www.commcarehq.org/a/[domain]/api/v0.5/location_type/1/",
          "longitude": null,
          "name": "Namibia",
          "parent": null,
          "resource_uri": "https://www.commcarehq.org/a/[domain]/api/v0.5/location/f373a6837c1243938abfc56618cce88b/",
          "site_code": "namibia"
        },
        ...
      ]
    }

Location Details

URL: https://www.commcarehq.org/a/[domain]/api/[version]/location/[location_id]

The Location API is read-only. Only the GET request method is supported.

Sample output:

    {
      "created_at": "2023-05-09T16:10:47.225938",
      "domain": "[domain]",
      "external_id": null,
      "id": 1,
      "last_modified": "2023-05-09T16:10:47.225947",
      "latitude": null,
      "location_data": {},
      "location_id": "f373a6837c1243938abfc56618cce88b",
      "location_type": "https://www.commcarehq.org/a/[domain]/api/v0.5/location_type/1/",
      "longitude": null,
      "name": "Namibia",
      "parent": null,
      "resource_uri": "https://www.commcarehq.org/a/[domain]/api/v0.5/location/f373a6837c1243938abfc56618cce88b/",
      "site_code": "namibia"
    }

List Location Types

URL: https://www.commcarehq.org/a/[domain]/api/[version]/location_type/

Sample output:

    {
      "meta": {
        "limit": 20,
        "next": null,
        "offset": 0,
        "previous": null,
        "total_count": 1
      },
      "objects": [
        {
          "administrative": true,
          "code": "country",
          "domain": "[domain]",
          "id": 1,
          "name": "Country",
          "parent": null,
          "resource_uri": "https://www.commcarehq.org/a/[domain]/api/v0.5/location_type/1/",
          "shares_cases": false,
          "view_descendants": false
        }
      ]
    }


Location Type Details

URL: https://www.commcarehq.org/a/[domain]/api/[version]/location_type/[id]

The Location API is read-only. Only the GET request method is supported.

Sample output:

    {
      "administrative": true,
      "code": "country",
      "domain": "[domain]",
      "id": 1,
      "name": "Country",
      "parent": null,
      "resource_uri": "https://www.commcarehq.org/a/[domain]/api/v0.5/location_type/1/",
      "shares_cases": false,
      "view_descendants": false
    }