Register/get info about a device using Python and HTTP

Hi

I want to register a device using http endpoints, with no success.

I’m using Python and the requests library, and tried the following
(based on https://www.thethingsnetwork.org/docs/applications/manager/):

import requests

endpoint = 'http://discovery.thethingsnetwork.org'
accessKey = 'ttn-account-v2.xxxxxxxxxxxxx..'
key = 'Key {}'.format(accessKey)
response = requests.get(endpoint, headers={'Authorization': key})

but I’m getting response 404, which is most likely me not doing it right.

How should I set it up, if I wanted to receive all devices in an application in my get request? I.e. this: https://www.thethingsnetwork.org/docs/applications/manager/api.html#getdevicesforapplication

Any help is appriciated, thanks.

That’s not what’s listed in the documentation?

Community endpoints

Use the following endpoints for the community network:

  • gRPC: <region>.thethings.network:1904
  • HTTP: http://<region>.thethings.network:8084

Replace <region> with the last part of the handler you registered your application to, e.g. eu, us-west, asia-se or brazil.

Also, for HTTP it needs a full URL, with a path appended to the domain name. Like:

GetDevicesForApplication

Available HTTP Endpoints:

  • GET /applications/{app_id}/devices

…with {app_id} replaced with the human readable ID you entered in TTN Console for your application (not its AppEUI).

So, something like:

endpoint = 'http://eu.thethings.network:8084/applications/my_app/devices'

(Works for me.)

1 Like