Sonicu's Blog

The improved Sonicu API for advanced data sharing and communication

Written by Bryan Mitchell | Jul 8, 2022 7:15:00 PM

 

 

Sonicu OAuth2.0 API: Improving Communication and Interoperability 

Sonicu provides customers with an OAuth2.0 JSON API based on a standard password grant client. 

Sonicu by default provides customers with a limited set of endpoints in order to obtain the sensor readings via API. 

Sonicu engineering can support customers if they require additional API access, including connecting categories like: 

  • Alarms and alerts 
  • Calibration 
  • Users 
  • Groups 

Sonicu’s API is documented via the SoniCloud API Swagger documentation.

To enable the API, a customer will make a POST request to https://www.sonicumonitoring.com/oauth/token with an application/json header with the following information:

[

    'grant_type' => 'password',

    'client_id' => "<to be provided by sonicu>",

    'client_secret' => "<to be provided by sonicu>",

    'username' => "<email goes here>",

    'password' => "<password goes here>",

    'scope' => '*',

];

This will return you a bearer response with expires_in, access_token, and refresh_token parameters. 

Customers will want to store the refresh_token as tokens expire in a year. 

From there, customers will want to make their API calls with the following headers:

[

    'Authorization' => "Bearer {$token}",

    'Accept' => 'application/javascript',

]

Sonicu SQL API Integration

Some customers prefer accessing their SoniCloud data via an SQL interface and Sonicu is happy to help by providing users with access to an SQL read replica. 

The SQL Read Replica, based on MySQL 8, will provide SQL read-only access to a customer’s database via a unique service account. 

The read replica will be IP limited to only the customer’s datacenter to ensure only the customer can access the read replica. 

The read replica will allow full access to all sensor reading data, alarms, alarm comments, scaling profiles, alarm thresholds, and more. 

This enhanced integration requires a thorough agreement upon scope and Sonicu Engineering support. For more information, contact Sonicu Engineering.