Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 6 Current »

The Location API is available from version v0.5.

Version v0.5 is read-only. It allows you to list locations and get location details.

Version v0.6 adds the ability to create and update locations.

List Locations

GET 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

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

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"
    }

Create Location

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

Available from version v0.6.

Update Location

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

Available from version v0.6.

List Location Types

GET 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

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

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
    }

  • No labels