# Get devices details

## Devices details

<mark style="color:blue;">`GET`</mark> `https://api.connect.jfrog.io/v1/devices_details`

Using this call you will get all details of your devices. You can choose to get details of all devices or all devices in a specific project/group or get the details of just a single device.

#### Request Body

| Name                                          | Type    | Description                                                                                                                                                     |
| --------------------------------------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| user\_token<mark style="color:red;">\*</mark> | string  | This is your account token. You can find it under the Settings category on the dashboard.                                                                       |
| device\_token                                 | string  | This is the token of the device you want to get the details of.  **If you set the `device_token`, other parameters will be ignored.**                           |
| group\_name                                   | string  | This is the group name of the group you would like to get all its device details. Using **`group_name`** parameter will work only if **`project_name`** is set. |
| project\_name                                 | string  | This is the project name of the project you would like to get all its devices state.                                                                            |
| limit                                         | integer | <p>The number of results per page.<br><em>The maximum <code>limit</code> is 50.</em><br><strong>Default is 20.</strong></p>                                     |
| offset                                        | integer | <p>Offset to start pagination search results.<br><strong>This should be the last <code>device\_id</code> from the previous request.</strong></p>                |
| device\_name                                  | String  | <p>Returns the details of a specific device, defined by name.</p><p><strong>the name must be exactly equal.</strong></p>                                        |

{% tabs %}
{% tab title="200: OK  The value of the "message" parameter is a JSON object with the keys:" %}

```json
{
    "more": false,
    "message": [
            {"device_id": 123456,
             "device_uuid": "d-1234-1234",
             "device_name": "My-Device-1",
             "upswift_version": "5.1",
             "project": "Test",
             "group": "Production",
             "device_ip": "10.10.10.10",
             "last_keepalive": "2020-02-08 16:12:11",
             "cpu_usage": 65,
             "ram_usage": 15,
             "disk_usage": 1022.1,
             "address": "Nurenberg, Germany",
             "lat": 49.4521,
             "lng": 11.0767,
             "is_update_trigger_set": false,
             "description": "device description example",
             "registered_date": "2020-02-07 16:12:11",
             "tags": ["London", "Lab Device", "4inch-screen"],
             "updates": [
                         {"update_id": 1234,
                         "update_status": "success",
                         "update_version": "v1.1",
                         "comment": "Some kind of a comment",
                         "deployment_schedule_time": "2020-02-08 16:12:11"
                         },
                         {
                         update_id": 5555,
                         "update_status": "pending",
                         "update_version": "v1.2",
                         "comment": "Some kind of a comment",
                         "deployment_schedule_time": "2020-03-09 19:12:11"
                         }
                         ],
             "updates_v2": [
                         {"flow_name": "Some Name",
                         "update_status": "success",
                         "comment": "Some kind of a comment",
                         "deployment_schedule_time": "2020-02-08 16:12:11",
                         "deployment_start_time": "2020-02-08 16:12:11",
                         "deployment_finish_time": "2020-02-08 16:12:11",
                         "apps_updated": [{"app_name": "app1", "app_new_version": "v1.1"}],
                         "deployment_type": "manual"
                         },
                         {
                         "flow_name": "Some Name2",
                         "update_status": "failed",
                         "comment": "Some kind of a comment",
                         "deployment_schedule_time": "2020-02-08 16:12:11",
                         "deployment_start_time": "2020-02-08 16:12:11",
                         "deployment_finish_time": "2020-02-08 16:12:11",
                         "apps_updated": [{"app_name": "app1", "app_new_version": "v1.1"}],
                         "deployment_type": "api-deployment"
                         }
                         ],
             "apps": [{"app_name": "default_app", 
                       "version": "v1.1"}],
             "mac_addresses": ["ff:ff:ff:ff:ff:ff", "ff:ff:ff:ff:ff:ff", "ff:ff:ff:ff:ff:ff"],
             }
             ]
 }
```

{% endtab %}

{% tab title="400 Error occurred." %}

```json
{"error_message": "<ERROR_MESSAGE>"}
```

{% endtab %}

{% tab title="429 Rate limit reached." %}

```
{}
```

{% endtab %}
{% endtabs %}

<details>

<summary>List of supported objects</summary>

```json
1. device_id -  Integer - The ID of the device.
2. device_name - String - The name of the device. 
3. upswift_version - String - Upswift Agent version. 
4. device_uuid - string - The UUID of the device (as shown in the dashboard)
5. project - String - The name of the project this device is registered to. 
6. group - String - The name of the group this device is registered to. 
7. device_ip - String - The IP of the device. 
8. last_keepalive - String(DATETIME) -  The last time a keep-alive message received from that device. 
9. cpu_usage -  Integer - The current CPU usage of the device (Percentage - value can be 0-100). 
10. ram_usage - Integer - The current RAM usage of the device (Percentage - value can be 0-100). 
11. disk_usage - Float - The current Disk usage of the device (MegaBytes). 
12. address - String - The current address set for this device. 
13. lat - Float - The current Latitude parameter set for this device. 
14. lng - Float - The current Longitude parameter set for this device. 
15. is_update_trigger_set - Boolean - If the parameter update trigger is currently set. valid values true/false.
16. description - String - The description of that device.
17. registered_date - String(DATETIME) - The date when this device has been registered to the platform.
18. tags - List of Strings - A list of all of the tags for this device.

19. updates - List of JSONs - The last 5 updates of that device with information regarding those updates.
 Each JSON includes the next parameters:
       1. update_id - Integer - The ID of the update.      
       2. update_status - String - The status of the update. 
 Possible values are: 
             pending - The update is pending and will be deployed at the scheduled time.
             in_progress - The update is in progress state, meaning it is currently being deployed. 
             success - The update successfully finished the deployment. failed - The deployment failed.      
       3. update_version - String - The version of the update.      
       4. comment - String - The comment set to the update when it was created.      
       5. deployment_schedule_time - String(DATETIME) - The time the deployment was scheduled to. By default this is the update creation time. Please note the value is UTC time with the next format: Year-Month-Day Hour:Minute:Second.
       
20. updates_v2 - List of JSONs - the last 5 updates (v2) of that device with information regarding those updates. Each JSON includes the next parameters:
            1. flow_name - String - The name of the flow that was deployed.
            2. deployment_status - String - The status of the update. Possible values are: pending - The update is pending and will be deployed at the scheduled time. 
                        pending - The update is pending and will be deployed if the Update Window is open.
                        in_progress - The update is in progress state, meaning it is currently being deployed. 
                        success - The update successfully finished deployment. failed - The deployment failed.
            3. comment - String - The comment set to the deployment when it was created.
            4. deployment_scheduled_time - String(DATETIME) - The time the deployment was scheduled to. By default this is the deployment creation time. Please note the value is UTC time with the next format: Year-Month-Day Hour:Minute:Second.
            5. apps_updated - List of JSONs - The apps that were set during the deployment. The JSON object contains 2 keys: {"app_name": "<name>", "app_new_version": "<version>"}
            6. deployment_type - String - The type of the deployment. Possible values are: manual, api-deployment.
            
21. apps - List of JSONs - A list of apps that this device has and their versions. the JSON object contains 2 keys: {"app_name": "<name>", "version": "<version>"}. The value of "more" is a boolean representing if there are more devices to query.
```

</details>

{% hint style="info" %}
If no parameters are set, the first 20 devices of that user will be returned.
{% endhint %}

#### Example

{% tabs %}
{% tab title="Python" %}

```python
import json
import requests
json_content = {'project_name': 'MYPROJECT',
                'group_name': 'Production',
                'user_token': 'YYYYYYYYYYYYYYY'}

call_request = requests.get("https://api.connect.jfrog.io/v1/devices_details", json=json_content)
call_response = json.loads(call_request.text)

if call_request.status_code != 200:
    if call_request.status_code == 429:
        error = "API limit reached"
    else:
        error = call_response["error_message"]
    print(error)
else:
    for device in call_response["message"]:
        device_name = device["device_name"]
        device_id = device["device_id"]
        device_uuid = device["device_uuid"]
        upswift_version = device["upswift_version"]
        project = device["project"]
        group = device["group"]
        device_ip = device["device_ip"]
        last_keepalive = device["last_keepalive"]
        cpu_usage = device["cpu_usage"]
        ram_usage = device["ram_usage"]
        address = device["address"]
        lat = device["lat"]
        lng = device["lng"]
        is_update_trigger_set = device["is_update_trigger_set"]
        description = device["description"]
        registered_date = device["registered_date"]
        updates = device["updates"]
        tags = device["tags"]
        updates = device["updates_v2"]
        apps = device["apps"]
        mac_addresses = device["mac_addresses"]

```

{% endtab %}
{% endtabs %}
