Get Device Metadata by End Device API

Hi,

We are using The Things Stack v.3.8 on Docker. Is there any option to get device metadata (Name , Description, Location, …) by device_id using the End Device API?

When I used a HTTP binding of EndDeviceRegistry.Get method,

GET /api/v3/applications/{end_device_ids.application_ids.application_id}/devices/{end_device_ids.device_id}

I only received the ids (device_id, application_id, dev_eui, join_eui) and the timestamps (created, updated).

{
    "ids": {
        "device_id": "{end_device_ids.device_id}",
        "application_ids": {
            "application_id": "{end_device_ids.application_ids.application_id}"
        },
        "dev_eui": "0018B2XXXXXXXXX",
        "join_eui": "0018B2XXXXXXXXX"
    },
    "created_at": "2020-08-28T14:40:19.285Z",
    "updated_at": "2020-09-09T16:06:22.747Z"
}

The End Device was created by the Console with correct Name and Description.

Thank you, for your answers.

1 Like

When using the HTTP API to get information about end devices, you need to:

  1. Query the service(s) that “owns” the fields you’re interested in. The API Reference has an overview of which fields are owned by which service. In your case, all fields are “owned” by the EndDeviceRegistry service of the Identity Server.
  2. Specify the fields you want to receive in the “field mask”. You can do this by writing the field paths in the query string. In your case, it would be ?field_mask=name,description,locations to get the name, description and locations fields.

We should probably document this second point better (cc: @benolayinka)

Ok, I get it.

Source of my confusion has been the End Device APIs Reference on a docs site.

There is a mention of the field mask, but there is not stated a form and a structure for the HTTP API. Whether it is an HTTP parameter (?field_mask or ?field-mask or ?fieldmask), or a special default setting for the Identity Server in stack config ttn-lw-stack.yml file, e.g.:

is:
  # Email configuration for "thethings.example.com"
  email:
    sender-name: 'The Things Stack'
    ...
  # Special default setting mentioned above
  api:
    field-mask: '<name>,<description>, ...'

Thank you for your explanation. It is clear to me, now.

@mmiskov, thanks for your feedback. I’ve pushed an update to our documentation which I hope clarifies exactly the question you have. If you have time, take a look at the pull request and let us know if it looks clear to you.

@benolayinka, thank you for documentation update. It looks much clearer to me.

1 Like

This topic was automatically closed after 30 days. New replies are no longer allowed.