# Get client statistics in a hierarchy view from FitCon using curl ## :memo: Introduction This document introduces how to get the clients statistics in certain hierarchy view from FitCon using [curl](https://curl.se/) step by step. ## :memo: Where do I start? ### Step 1: Get the login session token Use the following curl command to retrieve the login session token from FitCon: ``` curl -X GET https://{HOST_IP}/api/v1/user/auth -H "email: {USER_NAME}" -H "password: {PASSWORD}" --insecure ``` **=={HOST_IP}==**: The FitCon IP address **=={USER_NAME}==**: The FitCon login name **=={PASSWORD}==**: The FitCon password. If the authentication is passed, FitCon will return with the session token in the http response, the http response will be in JSON format like this: :::info {     "code": 200,     "message": {         "id": "610a53b1265244cb80f937e9",         "id_token": "**eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhZG1pbkBzZW5hby5jb20iLCJvcGVyYXRvcl9lbWFpbCI6ImFkbWluQHNlbmFvLmNvbSIsIm9wZXJhdG9yX25hbWUiOiJhYiBjZCIsInNjb3BlcyI6WyJzeXN0ZW1fYWRtaW4iXSwiZXhwIjoxNjg1NjEyMjk5fQ.rW9T2T0YEI9RcvwmtODm_BnQcwQq5uimBuQwMJubUyQ**",         "refresh_token": "a80d3c3aeead4ac0aa04c337d2524884",         "created_time": 1628066737000,         "modified_time": 1685526650000,         "last_login_time": 1685610320000,         "system_role": "system_admin",         "utc_time": 1685610499000     } } ::: We needs the string in ==id_token== field(the string in **Bold**) above for the next steps. :::info **Note:** If the ==id_token== expired, you need to run Step 1 again to get the new ==id_token==. ::: ### Step 2: Get the hv ids Once you get the ==id_token== in Step 1, use it in the next steps to get the data you need. First, you will need to get the hv ids of the FitCon, use the following curl command to get them: ``` curl -X GET https://{HOST_IP}/api/v1/orgs/1/hvs -H "authorization: Bearer {TOKEN_ID}" --insecure ``` **=={HOST_IP}==**: The FitCon IP address **=={TOKEN_ID}==**: The token_id field in Step 1 response The response looks like the following: :::info [     {         "id": "60b83e13a783ad2a01cd85fc",         "name": "root",         "networks": [],         "**hierarchy_views**": [             "**60b83e99dcf61564c17e9f2e**",             "**64786b308b37503db2ca1932**"         ],         "created_time": 1622687251000,         "modified_time": 1622687251000,         "org_id": "60b83e13a783ad2a01cd85fb"     },     {         "id": "**60b83e99dcf61564c17e9f2e**",         "name": "HV_1",         "networks": [         {             "id": "60b83f5fdcf61564c17e9f2f",             "name": "Network_1",             "parent_hierarchy_view_id": "60b83e99dcf61564c17e9f2e",             "description": "Network 1 Description",             "country": "Taiwan",             "time_zone": "Europe/Tirane",             "created_time": 1622687583000,             "modified_time": 1685526651000,             "users": [],             "ap_counts": 1,             "switch_counts": 0,             "skykey_counts": 0,             "device_counts": 1,             "client_counts": 0          }          ],         "hierarchy_views": [],         "created_time": 1622687385000,         "modified_time": 1622687385000,         "parent_hierarchy_view_id": "60b83e13a783ad2a01cd85fc"     },     {         "id": "**64786b308b37503db2ca1932**",         "name": "12333",         "networks": [],         "hierarchy_views": [],         "created_time": 1685613360000,         "modified_time": 1685613360000,         "parent_hierarchy_view_id": "60b83e13a783ad2a01cd85fc"     } ] ::: The hierarchy view id in the ==hierarchy_views== above can be used to get the client statistics in the next step. ### Step 3: Get the client statistics in a hierarchy view Once you get the hierarchy view id in Step 2, you can use it to get the client statistics data in the hierarchy view. ``` curl -X GET https://{HOST_IP}/api/v1/orgs/1/hvs/{HV_ID}/statistics/clients -H "authorization: Bearer {TOKEN_ID}" --insecure ``` **=={HOST_IP}==**: The FitCon IP address **=={HV_ID}==**: The hierarchy view id get in Step 2 **=={TOKEN_ID}==**: The token_id field in Step 1 response The response looks like the following: :::info {     "size": 1,     "clients": [     {         "device_name": "Apple_device",         "original_device_name": "Apple_device",         "mac": "7a:11:a9:9d:7c:e5",         "last_seen": 1685682703000,         "last_ap": "88:dc:97:1b:7a:c5",         "ap_name": "EWS356-FIT",         "network_name": "Network_1",         "ssid_profile_id": "60b83f5fdcf61564c17e9f31",         "ssid_id": 1,         "ssid_name": "356_test",         "os": "Apple iOS",         "vendor": "Other",         "vendor_short": "Other",         "ip": "172.20.6.85",         "rssi": -21,         "rate": 780,         "band": "5GHz",         "hierarchy_view_id": "60b83e99dcf61564c17e9f2e",         "network_id": "60b83f5fdcf61564c17e9f2f",         "scope": null,         "access": "normal",         "is_block_enable": true,         "is_vip_enable": true,         "is_favorite": false,         "download": 16607232,         "upload": 4026368,         "usage": 20633600     }     ] } ::: The client statistic data above is what we want to get.