When using the ExoSense GraphQL API, you can download content associated to an Asset.
Here is the quick summary of steps:
-
Have your Asset ID (assume already queried / stored / cached)
-
Get the Asset’s information including the which IoT edge devices are associated to the asset via it’s signal channel sources.
query
query asset($assetId: ID!) { asset(id: $assetId) { id name meta description signals { # id # name channel { id #properties } } } }
variables
{"assetId": "<ASSET_ID>"}
-
Consolidate the list of devices (typically it’s just one). Note that a device is a combination of the Product (IoT Connector) ID and the unique Device Identifier.
-
Query the Asset for all content created by a User or the API
query
query assetContents($filters: ContentFilters, $pagination: Pagination, $id: [ID!], $devices: [AssetContentsDeviceInput]) { assetContents(filters: $filters, pagination: $pagination, id: $id, devices: $devices) { assetContents { id name associations { type id } tags { name value } contentType createdBy { ... on Device { pid identity } ... on User { name } } type lastModified length } totalCount } }
variables
{ "filters": { "contentTypes": [], "orderBy": "updated_at", "sort": "desc", "association": { "type": "asset", "id": "<ASSET_ID>" } }, "pagination": { "limit": 50, "offset": 0 }, "devices": None }
-
Query the for all content uploaded by the device(s).
Same query
variables
{ "filters": { "contentTypes": [], "orderBy": "updated_at", "sort": "desc", "association": { "type": "asset", "id": "<ASSET_ID>" } }, "pagination": { "limit": 50, "offset": 0 }, "id": None, "devices":[ { "product_id": "<PRODUCT_ID>", "device_id": "<DEVICE_ID>" } ] }
-
Get the URLs for these content files
query
query ContentDownload($id: ID!) { content(id: $id) { id url name lastModified } }
variables
{"id": "<CONTENT_ID>"}
query DeviceAssetContent($input: DeviceAssetContentInput!) { deviceAssetContent(input: $input) { url } }
variables
{ "input": { "id": "CONTENT_ID", "product_id": "<PRODUCT_ID>", "device_id": "<DEVICE_ID" } }
-
Download the files using the returned URLs.
Python Example