Dynamic REST API Response
# Background
The response of REST API may have a huge number of fields, but we only need small part of these fields in many cases. This results in unnecessary data computation and network traffic cost. Dynamic response is an option to address the mentioned problems.
# fields
and views
in API request
# Concept
The field
and view
are the two most important concepts to achieve our goal.
- The
field
is a specific field in the API response. - The
view
is a collection offield
s.
TIP
By specifying one or more fields
and views
in API request to ask API server only compute and return the interested fields.
# Parameter name
fields
: The fields to return, user can specify multiple fields in the request.views
: The views to return, user can specify multiple views in the request.
TIP
If both fields
and views
are specified, then all combined fields will be returned.
# Common views
The common views are the view names that can be applied to all supported APIs.
basic
: Returning the basic fields, each API will have their own basic fields.full
: Returning all supported fields.
# Default view
If both fields
and views
are empty, then basic view will be returned.
# Examples
# Fetch devices by fields
GET /devices?fields=hostname,active_clients
1
# Fetch devices by views
GET /devices?views=basic,status
1
# Fetch devices by fields
and views
GET /devices?views=location,status&fields=hostname
1
# view
to fields
mapping
# Device APIs
View | Fields |
---|---|
basic | org_id, serial_number, service_tag, mac_address, simulated, device_function, product_type, hostname, ip_address, software_version, device_admin_state, connected |
status | device_admin_state, connected |
client | active_clients |
location | location_id, locations |
detail | org_id, create_time, update_time, serial_number, service_tag, mac_address, simulated, device_function, product_type, hostname, ip_address, software_version, device_admin_state, connected, last_connect_time, primary_dns_server_address, subnet_mask, default_gateway, ipv6_address, ipv6_netmask, display_version |
full | create_time, update_time, org_id, org_name, location_id, serial_number, mac_address, device_function, product_type, hostname, ip_address, software_version, device_admin_state, connected, last_connect_time, network_policy_name, network_policy_id, primary_ntp_server_address, primary_dns_server_address, subnet_mask, default_gateway, ipv6_address, ipv6_netmask, simulated, display_version, active_clients, locations |
# Client APIs
View | Fields |
---|---|
basic | org_id, hostname, mac_address, ip_address, ipv6_address, os_type, device_id, connected, online_time, offline_time, connection_type, ssid, port |
status | connected, online_time, offline_time |
location | location_id, locations |
metrics | client_health, application_health, network_health, radio_health |
iot | mobility, category, description |
detail | create_time, update_time, org_id, org_name, location_id, hostname, mac_address, ip_address, ipv6_address, os_type, device_id, device_function, device_name, device_mac_address, username, user_profile_name, connected, online_time, offline_time, vlan, connection_type, ssid, port, bssid, port_type_name, interface_name, auth, encryption_method, channel, rssi, snr, wing_ap, vendor, radio_type |
full | create_time, update_time, org_id, org_name, location_id, hostname, mac_address, ip_address, ipv6_address, os_type, device_id, device_function, device_name, device_mac_address, username, user_profile_name, connected, online_time, offline_time, vlan, connection_type, ssid, port, bssid, port_type_name, interface_name, auth, encryption_method, channel, rssi, snr, wing_ap, vendor, mobility, category, description, locations, client_health, application_health, network_health, radio_health, radio_type |
LastUpdated: 2022/05/12, 19:30:31