Overview
Client-mode REST API connectors for Blynk.Cloud: read and write device datastreams, upload timestamped data, raise events and manage devices, templates, webhooks and automations from MQTT, plus an opt-in webhook receiver. This is one of the templates in the Blynk REST API app (blynk). Deploy it alongside the other connectors of that app when they depend on each other (for example a token connector plus an API connector).
Not yet verified against the live vendor API: No Blynk device auth token or OAuth2 client on the factory box; the ready gate needs an authenticated live GET + POST (or broker MQTT round-trip).
Auth
Device connector: device auth token in the query string token={value.json.token} (Blynk has no header form for the Device HTTPS API); suggested secret BLYNK_DEVICE_TOKEN. Platform connector: OAuth2 client credentials (Developers > OAuth2) as HTTP Basic {value.json.basic_auth} on GetAccessToken / RefreshAccessToken, then Authorization: Bearer {value.json.access_token}; suggested secrets BLYNK_CLIENT_BASIC, BLYNK_ACCESS_TOKEN. Platform API needs a Prototype / Production / Enterprise plan. Never commit real tokens. Auth headers used by the template:Authorization: Basic {value.json.basic_auth}, Authorization: Bearer {value.json.access_token}.
Template parameters
| Placeholder | Type | Description | Required |
|---|---|---|---|
RouteName | string | Name of the Blynk Platform Api connector | no |
BaseUrl | string | Blynk Platform Api base URL without trailing slash (e.g. https://fra1.blynk.cloud) | yes |
BASE_ADDRESS default: https://fra1.blynk.cloud.
Events
| Event | Method | Endpoint | Request topic | Response topic | Payload fields |
|---|---|---|---|---|---|
GetAccessToken | POST | /oauth2/token?grant_type=client_credentials | cloud-iot/blynk/oauth-token/create | cloud-iot/blynk/oauth-token/create/response | basic_auth |
RefreshAccessToken | POST | /oauth2/token?grant_type=refresh_token&refresh_token={value.json.refresh_token} | cloud-iot/blynk/oauth-token/refresh | cloud-iot/blynk/oauth-token/refresh/response | basic_auth, refresh_token |
GetOrganization | GET | /api/v1/organization/profile | cloud-iot/blynk/organization/get | cloud-iot/blynk/organization/get/response | access_token |
ListDevices | GET | /api/v2/organization/devices?{value.json.query} | cloud-iot/blynk/device/list | cloud-iot/blynk/device/list/response | access_token, query |
SearchDevices | GET | /api/v1/organization/search/devices?{value.json.query} | cloud-iot/blynk/device/search | cloud-iot/blynk/device/search/response | access_token, query |
GetDevice | GET | /api/v1/organization/device?deviceId={value.json.device_id} | cloud-iot/blynk/device/get | cloud-iot/blynk/device/get/response | access_token, device_id |
GetDeviceOnline | GET | /api/v1/organization/device/online?deviceId={value.json.device_id} | cloud-iot/blynk/device-online/get | cloud-iot/blynk/device-online/get/response | access_token, device_id |
CreateDevice | POST | /api/v1/organization/device/create | cloud-iot/blynk/device/create | cloud-iot/blynk/device/create/response | access_token, body |
UpdateDevice | PUT | /api/v1/organization/device?deviceId={value.json.device_id} | cloud-iot/blynk/device/update | cloud-iot/blynk/device/update/response | access_token, body, device_id |
GetDeviceDatastreams | GET | /api/v2/organization/device/datastreams?deviceId={value.json.device_id}&{value.json.query} | cloud-iot/blynk/device-datastream/get | cloud-iot/blynk/device-datastream/get/response | access_token, device_id, query |
GetDatastreamsBatch | GET | /api/v1/organization/device/datastreams/batch?{value.json.query} | cloud-iot/blynk/device-datastream/batch-get | cloud-iot/blynk/device-datastream/batch-get/response | access_token, query |
UpdateDeviceDatastream | POST | /api/v1/organization/device/datastream | cloud-iot/blynk/device-datastream/update | cloud-iot/blynk/device-datastream/update/response | access_token, body |
UpdateDeviceDatastreams | POST | /api/v1/organization/device/datastreams | cloud-iot/blynk/device-datastream/batch-update | cloud-iot/blynk/device-datastream/batch-update/response | access_token, body |
BatchUpdateProductDevices | POST | /api/v1/organization/product/devices/batch-update | cloud-iot/blynk/product-datastream/batch-update | cloud-iot/blynk/product-datastream/batch-update/response | access_token, body |
UpdateDeviceDatastreamProperty | POST | /api/v1/organization/device/datastream/property | cloud-iot/blynk/device-datastream-property/update | cloud-iot/blynk/device-datastream-property/update/response | access_token, body |
GetDatastreamHistory | GET | /api/v1/organization/device/datastream/history?deviceId={value.json.device_id}&{value.json.query} | cloud-iot/blynk/device-datastream-history/get | cloud-iot/blynk/device-datastream-history/get/response | access_token, device_id, query |
GetDeviceHistory | GET | /api/v1/organization/device/datastreams/history?deviceId={value.json.device_id}&{value.json.query} | cloud-iot/blynk/device-history/get | cloud-iot/blynk/device-history/get/response | access_token, device_id, query |
GetDeviceHistoryAggregated | GET | /api/v1/organization/device/datastreams/history/aggregated?deviceId={value.json.device_id}&{value.json.query} | cloud-iot/blynk/device-history-aggregated/get | cloud-iot/blynk/device-history-aggregated/get/response | access_token, device_id, query |
TriggerDeviceEvent | POST | /api/v1/organization/device/trigger-event | cloud-iot/blynk/device-event/trigger | cloud-iot/blynk/device-event/trigger/response | access_token, body |
GetDeviceTimeline | GET | /api/v1/organization/device/timeline?deviceId={value.json.device_id}&{value.json.query} | cloud-iot/blynk/device-timeline/get | cloud-iot/blynk/device-timeline/get/response | access_token, device_id, query |
ResolveDeviceEvent | POST | /api/v1/organization/device/resolve-event | cloud-iot/blynk/device-event/resolve | cloud-iot/blynk/device-event/resolve/response | access_token, body |
ListDeviceMetafields | GET | /api/v1/organization/device/metafield?deviceId={value.json.device_id} | cloud-iot/blynk/device-metafield/list | cloud-iot/blynk/device-metafield/list/response | access_token, device_id |
UpdateDeviceMetafieldValue | POST | /api/v1/organization/device/metafield | cloud-iot/blynk/device-metafield/update | cloud-iot/blynk/device-metafield/update/response | access_token, body |
ListDeviceLogs | GET | /api/v1/organization/device/logs?deviceId={value.json.device_id}&{value.json.query} | cloud-iot/blynk/device-log/list | cloud-iot/blynk/device-log/list/response | access_token, device_id, query |
ListTemplates | GET | /api/v1/organization/templates?{value.json.query} | cloud-iot/blynk/template/list | cloud-iot/blynk/template/list/response | access_token, query |
ListTemplateDatastreams | GET | /api/v1/organization/template/datastreams?templateId={value.json.template_id} | cloud-iot/blynk/template-datastream/list | cloud-iot/blynk/template-datastream/list/response | access_token, template_id |
ListTags | GET | /api/v1/organization/tags | cloud-iot/blynk/tag/list | cloud-iot/blynk/tag/list/response | access_token |
ListWebhooks | GET | /api/v1/organization/webhooks | cloud-iot/blynk/webhook/list | cloud-iot/blynk/webhook/list/response | access_token |
CreateWebhook | POST | /api/v1/organization/webhook/create | cloud-iot/blynk/webhook/create | cloud-iot/blynk/webhook/create/response | access_token, body |
ListAutomations | GET | /api/v1/organization/automations | cloud-iot/blynk/automation/list | cloud-iot/blynk/automation/list/response | access_token |
ExecuteAutomation | POST | /api/v1/organization/automation/execute | cloud-iot/blynk/automation/execute | cloud-iot/blynk/automation/execute/response | access_token, body |
Deploy
Get the template card (JSON withtemplate and metadata) from the broker, then deploy the connector:
mosquitto_pub -t '$SYS/Coreflux/Command' -m "-routeCode BLYNK_PLATFORM_API"
BASE_ADDRESS already filled in:
DEFINE ROUTE BlynkPlatformApi WITH TYPE REST_API
ADD REST_API_CONFIG
WITH BASE_ADDRESS "https://fra1.blynk.cloud"
WITH ENABLE_CLIENT "true"
WITH USE_SSL "true"
WITH REQUEST_TIMEOUT '30'
WITH DEFAULT_CONTENT_TYPE "application/json"
ADD EVENT GetAccessToken
WITH SOURCE_TOPIC "cloud-iot/blynk/oauth-token/create"
WITH DESTINATION_TOPIC "cloud-iot/blynk/oauth-token/create/response"
WITH METHOD "POST"
WITH ENDPOINT "/oauth2/token?grant_type=client_credentials"
WITH HEADERS
ADD "Accept" "application/json"
ADD "Authorization" "Basic {value.json.basic_auth}"
WITH BODY ""
ADD EVENT RefreshAccessToken
WITH SOURCE_TOPIC "cloud-iot/blynk/oauth-token/refresh"
WITH DESTINATION_TOPIC "cloud-iot/blynk/oauth-token/refresh/response"
WITH METHOD "POST"
WITH ENDPOINT "/oauth2/token?grant_type=refresh_token&refresh_token={value.json.refresh_token}"
WITH HEADERS
ADD "Accept" "application/json"
ADD "Authorization" "Basic {value.json.basic_auth}"
WITH BODY ""
ADD EVENT GetOrganization
WITH SOURCE_TOPIC "cloud-iot/blynk/organization/get"
WITH DESTINATION_TOPIC "cloud-iot/blynk/organization/get/response"
WITH METHOD "GET"
WITH ENDPOINT "/api/v1/organization/profile"
WITH HEADERS
ADD "Accept" "application/json"
ADD "Authorization" "Bearer {value.json.access_token}"
ADD EVENT ListDevices
WITH SOURCE_TOPIC "cloud-iot/blynk/device/list"
WITH DESTINATION_TOPIC "cloud-iot/blynk/device/list/response"
WITH METHOD "GET"
WITH ENDPOINT "/api/v2/organization/devices?{value.json.query}"
WITH HEADERS
ADD "Accept" "application/json"
ADD "Authorization" "Bearer {value.json.access_token}"
ADD EVENT SearchDevices
WITH SOURCE_TOPIC "cloud-iot/blynk/device/search"
WITH DESTINATION_TOPIC "cloud-iot/blynk/device/search/response"
WITH METHOD "GET"
WITH ENDPOINT "/api/v1/organization/search/devices?{value.json.query}"
WITH HEADERS
ADD "Accept" "application/json"
ADD "Authorization" "Bearer {value.json.access_token}"
ADD EVENT GetDevice
WITH SOURCE_TOPIC "cloud-iot/blynk/device/get"
WITH DESTINATION_TOPIC "cloud-iot/blynk/device/get/response"
WITH METHOD "GET"
WITH ENDPOINT "/api/v1/organization/device?deviceId={value.json.device_id}"
WITH HEADERS
ADD "Accept" "application/json"
ADD "Authorization" "Bearer {value.json.access_token}"
ADD EVENT GetDeviceOnline
WITH SOURCE_TOPIC "cloud-iot/blynk/device-online/get"
WITH DESTINATION_TOPIC "cloud-iot/blynk/device-online/get/response"
WITH METHOD "GET"
WITH ENDPOINT "/api/v1/organization/device/online?deviceId={value.json.device_id}"
WITH HEADERS
ADD "Accept" "application/json"
ADD "Authorization" "Bearer {value.json.access_token}"
ADD EVENT CreateDevice
WITH SOURCE_TOPIC "cloud-iot/blynk/device/create"
WITH DESTINATION_TOPIC "cloud-iot/blynk/device/create/response"
WITH METHOD "POST"
WITH ENDPOINT "/api/v1/organization/device/create"
WITH HEADERS
ADD "Accept" "application/json"
ADD "Authorization" "Bearer {value.json.access_token}"
ADD "Content-Type" "application/json"
WITH BODY "{value.json.body}"
ADD EVENT UpdateDevice
WITH SOURCE_TOPIC "cloud-iot/blynk/device/update"
WITH DESTINATION_TOPIC "cloud-iot/blynk/device/update/response"
WITH METHOD "PUT"
WITH ENDPOINT "/api/v1/organization/device?deviceId={value.json.device_id}"
WITH HEADERS
ADD "Accept" "application/json"
ADD "Authorization" "Bearer {value.json.access_token}"
ADD "Content-Type" "application/json"
WITH BODY "{value.json.body}"
ADD EVENT GetDeviceDatastreams
WITH SOURCE_TOPIC "cloud-iot/blynk/device-datastream/get"
WITH DESTINATION_TOPIC "cloud-iot/blynk/device-datastream/get/response"
WITH METHOD "GET"
WITH ENDPOINT "/api/v2/organization/device/datastreams?deviceId={value.json.device_id}&{value.json.query}"
WITH HEADERS
ADD "Accept" "application/json"
ADD "Authorization" "Bearer {value.json.access_token}"
ADD EVENT GetDatastreamsBatch
WITH SOURCE_TOPIC "cloud-iot/blynk/device-datastream/batch-get"
WITH DESTINATION_TOPIC "cloud-iot/blynk/device-datastream/batch-get/response"
WITH METHOD "GET"
WITH ENDPOINT "/api/v1/organization/device/datastreams/batch?{value.json.query}"
WITH HEADERS
ADD "Accept" "application/json"
ADD "Authorization" "Bearer {value.json.access_token}"
ADD EVENT UpdateDeviceDatastream
WITH SOURCE_TOPIC "cloud-iot/blynk/device-datastream/update"
WITH DESTINATION_TOPIC "cloud-iot/blynk/device-datastream/update/response"
WITH METHOD "POST"
WITH ENDPOINT "/api/v1/organization/device/datastream"
WITH HEADERS
ADD "Accept" "application/json"
ADD "Authorization" "Bearer {value.json.access_token}"
ADD "Content-Type" "application/json"
WITH BODY "{value.json.body}"
ADD EVENT UpdateDeviceDatastreams
WITH SOURCE_TOPIC "cloud-iot/blynk/device-datastream/batch-update"
WITH DESTINATION_TOPIC "cloud-iot/blynk/device-datastream/batch-update/response"
WITH METHOD "POST"
WITH ENDPOINT "/api/v1/organization/device/datastreams"
WITH HEADERS
ADD "Accept" "application/json"
ADD "Authorization" "Bearer {value.json.access_token}"
ADD "Content-Type" "application/json"
WITH BODY "{value.json.body}"
ADD EVENT BatchUpdateProductDevices
WITH SOURCE_TOPIC "cloud-iot/blynk/product-datastream/batch-update"
WITH DESTINATION_TOPIC "cloud-iot/blynk/product-datastream/batch-update/response"
WITH METHOD "POST"
WITH ENDPOINT "/api/v1/organization/product/devices/batch-update"
WITH HEADERS
ADD "Accept" "application/json"
ADD "Authorization" "Bearer {value.json.access_token}"
ADD "Content-Type" "application/json"
WITH BODY "{value.json.body}"
ADD EVENT UpdateDeviceDatastreamProperty
WITH SOURCE_TOPIC "cloud-iot/blynk/device-datastream-property/update"
WITH DESTINATION_TOPIC "cloud-iot/blynk/device-datastream-property/update/response"
WITH METHOD "POST"
WITH ENDPOINT "/api/v1/organization/device/datastream/property"
WITH HEADERS
ADD "Accept" "application/json"
ADD "Authorization" "Bearer {value.json.access_token}"
ADD "Content-Type" "application/json"
WITH BODY "{value.json.body}"
ADD EVENT GetDatastreamHistory
WITH SOURCE_TOPIC "cloud-iot/blynk/device-datastream-history/get"
WITH DESTINATION_TOPIC "cloud-iot/blynk/device-datastream-history/get/response"
WITH METHOD "GET"
WITH ENDPOINT "/api/v1/organization/device/datastream/history?deviceId={value.json.device_id}&{value.json.query}"
WITH HEADERS
ADD "Accept" "application/json"
ADD "Authorization" "Bearer {value.json.access_token}"
ADD EVENT GetDeviceHistory
WITH SOURCE_TOPIC "cloud-iot/blynk/device-history/get"
WITH DESTINATION_TOPIC "cloud-iot/blynk/device-history/get/response"
WITH METHOD "GET"
WITH ENDPOINT "/api/v1/organization/device/datastreams/history?deviceId={value.json.device_id}&{value.json.query}"
WITH HEADERS
ADD "Accept" "application/json"
ADD "Authorization" "Bearer {value.json.access_token}"
ADD EVENT GetDeviceHistoryAggregated
WITH SOURCE_TOPIC "cloud-iot/blynk/device-history-aggregated/get"
WITH DESTINATION_TOPIC "cloud-iot/blynk/device-history-aggregated/get/response"
WITH METHOD "GET"
WITH ENDPOINT "/api/v1/organization/device/datastreams/history/aggregated?deviceId={value.json.device_id}&{value.json.query}"
WITH HEADERS
ADD "Accept" "application/json"
ADD "Authorization" "Bearer {value.json.access_token}"
ADD EVENT TriggerDeviceEvent
WITH SOURCE_TOPIC "cloud-iot/blynk/device-event/trigger"
WITH DESTINATION_TOPIC "cloud-iot/blynk/device-event/trigger/response"
WITH METHOD "POST"
WITH ENDPOINT "/api/v1/organization/device/trigger-event"
WITH HEADERS
ADD "Accept" "application/json"
ADD "Authorization" "Bearer {value.json.access_token}"
ADD "Content-Type" "application/json"
WITH BODY "{value.json.body}"
ADD EVENT GetDeviceTimeline
WITH SOURCE_TOPIC "cloud-iot/blynk/device-timeline/get"
WITH DESTINATION_TOPIC "cloud-iot/blynk/device-timeline/get/response"
WITH METHOD "GET"
WITH ENDPOINT "/api/v1/organization/device/timeline?deviceId={value.json.device_id}&{value.json.query}"
WITH HEADERS
ADD "Accept" "application/json"
ADD "Authorization" "Bearer {value.json.access_token}"
ADD EVENT ResolveDeviceEvent
WITH SOURCE_TOPIC "cloud-iot/blynk/device-event/resolve"
WITH DESTINATION_TOPIC "cloud-iot/blynk/device-event/resolve/response"
WITH METHOD "POST"
WITH ENDPOINT "/api/v1/organization/device/resolve-event"
WITH HEADERS
ADD "Accept" "application/json"
ADD "Authorization" "Bearer {value.json.access_token}"
ADD "Content-Type" "application/json"
WITH BODY "{value.json.body}"
ADD EVENT ListDeviceMetafields
WITH SOURCE_TOPIC "cloud-iot/blynk/device-metafield/list"
WITH DESTINATION_TOPIC "cloud-iot/blynk/device-metafield/list/response"
WITH METHOD "GET"
WITH ENDPOINT "/api/v1/organization/device/metafield?deviceId={value.json.device_id}"
WITH HEADERS
ADD "Accept" "application/json"
ADD "Authorization" "Bearer {value.json.access_token}"
ADD EVENT UpdateDeviceMetafieldValue
WITH SOURCE_TOPIC "cloud-iot/blynk/device-metafield/update"
WITH DESTINATION_TOPIC "cloud-iot/blynk/device-metafield/update/response"
WITH METHOD "POST"
WITH ENDPOINT "/api/v1/organization/device/metafield"
WITH HEADERS
ADD "Accept" "application/json"
ADD "Authorization" "Bearer {value.json.access_token}"
ADD "Content-Type" "application/json"
WITH BODY "{value.json.body}"
ADD EVENT ListDeviceLogs
WITH SOURCE_TOPIC "cloud-iot/blynk/device-log/list"
WITH DESTINATION_TOPIC "cloud-iot/blynk/device-log/list/response"
WITH METHOD "GET"
WITH ENDPOINT "/api/v1/organization/device/logs?deviceId={value.json.device_id}&{value.json.query}"
WITH HEADERS
ADD "Accept" "application/json"
ADD "Authorization" "Bearer {value.json.access_token}"
ADD EVENT ListTemplates
WITH SOURCE_TOPIC "cloud-iot/blynk/template/list"
WITH DESTINATION_TOPIC "cloud-iot/blynk/template/list/response"
WITH METHOD "GET"
WITH ENDPOINT "/api/v1/organization/templates?{value.json.query}"
WITH HEADERS
ADD "Accept" "application/json"
ADD "Authorization" "Bearer {value.json.access_token}"
ADD EVENT ListTemplateDatastreams
WITH SOURCE_TOPIC "cloud-iot/blynk/template-datastream/list"
WITH DESTINATION_TOPIC "cloud-iot/blynk/template-datastream/list/response"
WITH METHOD "GET"
WITH ENDPOINT "/api/v1/organization/template/datastreams?templateId={value.json.template_id}"
WITH HEADERS
ADD "Accept" "application/json"
ADD "Authorization" "Bearer {value.json.access_token}"
ADD EVENT ListTags
WITH SOURCE_TOPIC "cloud-iot/blynk/tag/list"
WITH DESTINATION_TOPIC "cloud-iot/blynk/tag/list/response"
WITH METHOD "GET"
WITH ENDPOINT "/api/v1/organization/tags"
WITH HEADERS
ADD "Accept" "application/json"
ADD "Authorization" "Bearer {value.json.access_token}"
ADD EVENT ListWebhooks
WITH SOURCE_TOPIC "cloud-iot/blynk/webhook/list"
WITH DESTINATION_TOPIC "cloud-iot/blynk/webhook/list/response"
WITH METHOD "GET"
WITH ENDPOINT "/api/v1/organization/webhooks"
WITH HEADERS
ADD "Accept" "application/json"
ADD "Authorization" "Bearer {value.json.access_token}"
ADD EVENT CreateWebhook
WITH SOURCE_TOPIC "cloud-iot/blynk/webhook/create"
WITH DESTINATION_TOPIC "cloud-iot/blynk/webhook/create/response"
WITH METHOD "POST"
WITH ENDPOINT "/api/v1/organization/webhook/create"
WITH HEADERS
ADD "Accept" "application/json"
ADD "Authorization" "Bearer {value.json.access_token}"
ADD "Content-Type" "application/json"
WITH BODY "{value.json.body}"
ADD EVENT ListAutomations
WITH SOURCE_TOPIC "cloud-iot/blynk/automation/list"
WITH DESTINATION_TOPIC "cloud-iot/blynk/automation/list/response"
WITH METHOD "GET"
WITH ENDPOINT "/api/v1/organization/automations"
WITH HEADERS
ADD "Accept" "application/json"
ADD "Authorization" "Bearer {value.json.access_token}"
ADD EVENT ExecuteAutomation
WITH SOURCE_TOPIC "cloud-iot/blynk/automation/execute"
WITH DESTINATION_TOPIC "cloud-iot/blynk/automation/execute/response"
WITH METHOD "POST"
WITH ENDPOINT "/api/v1/organization/automation/execute"
WITH HEADERS
ADD "Accept" "application/json"
ADD "Authorization" "Bearer {value.json.access_token}"
ADD "Content-Type" "application/json"
WITH BODY "{value.json.body}"
-addRoute (do not include ADD METADATA).
Usage example
CallGetAccessToken by publishing a JSON payload to its request topic, and read the reply on the response topic:
mosquitto_sub -t 'cloud-iot/blynk/oauth-token/create/response' &
mosquitto_pub -t 'cloud-iot/blynk/oauth-token/create' -m '{"basic_auth": "<basic_auth>"}'

