Gateway API to fetch the Gateway locations./TTN V3

Hello,everyone.
I read the API reference but I don’t know how.

curl -G "https://eu1.cloud.thethings.network/api/v3/gateways/{gateway_ids.gateway_id}/Location

The response is
{“code”:12,“message”:“Not Implemented”}

https://www.thethingsindustries.com/docs/reference/api/gateway/#message:Location

This is the parameter I want to use.
advice please.

You can use the Packet Broker mapper API

You can also use the API of The Things Stack for this. If the location of your gateway is not public, or your deployment is not connected to Packet Broker, you should use the GatewayRegistry.Get API method.

The GatewayRegistry.Get API method returns a Gateway message. The locations are inside the antennas field, so you need to request that field from the API.

The API Reference page explains how you request specific fields from the API:

Fields may be specified in HTTP requests by appending them as query string parameters.

So you should use GET /api/v3/gateways/{gateway_ids.gateway_id}?field_mask=antennas:

Pro tip: that same API Reference page suggests how to use the Console as an example:

you can always inspect requests in the Console using your browser’s inspector. All of the data displayed in the Console is pulled using HTTP API requests, and this should give you some insight in to how they are formed.


Here’s an example with cURL:

% curl -s 'https://eu1.cloud.thethings.network/api/v3/gateways/pancakes?field_mask=antennas,location_public' -H 'Accept: application/json' --compressed -H 'Authorization: Bearer MFRWG.REDACTED.REDACTED' | jq
{
  ...
  "antennas": [
    {
      "location": {
        "latitude": 52.0xxx,
        "longitude": 4.3xxx,
        "altitude": xx,
        "source": "SOURCE_REGISTRY"
      }
    }
  ],
  "location_public": true
}
2 Likes

Hello,
Thank you so much.
I succeeded in getting location information.