How to work with the gateway API

Hi Guys,

I’m having good progress with the application APIs and the webhooks to onboard my sensors on my webinterface.

Now, I would like to move on to also include data of the gateway.

Unfortunately, this doesn’t seem to be as easy or well supported as the sensor nodes.

I would just like to receive basic data like last received, ontime, uplinks etc.

I have read the documentation for the gateway api

and from what I see, you can do an http get request:
HTTP bindings GET /api/v3/gs/gateways/{gateway_id}/connection/stats

So I’ve tried the following python code snippet:

from requests.auth import HTTPBasicAuth
import requests

url = ''
headers = {'Accept': 'application/json'}
auth = HTTPBasicAuth('<apikey>', '<private pi key>')

req = requests.get(url, headers=headers, auth=auth)


But I receive a 401 authentication failed error.

When I enter the url in my browser, I can see some information about my gateway:

This from @htdvisser may be relevant:

Sorry guys…
Here is the working solution, just put the api key in the header.
Reference: Using the API | The Things Stack for LoRaWAN

Minimum code example:
import requests

url = '<gateway_id>/connection/stats'
headers = {'Authorization': 'Bearer NNSXS.XXX',
    'Accept': 'application/json'}

req = requests.get(url, headers=headers)


Opps, my bad, should have spotted the headers!

@descartes I just hope my newbish forum entries will help some other guys → eventually edit the topic name.

Anyways, another question: can you also receive GPS information for the gateway using the api?

We are all new to v3 and learning as we go. Topic name seems appropriate!

Not so much the GPS but the location set on the console if set to public.

It’s held in the Antenna section: