Categorygithub.com/arduino/iot-client-go
modulepackage
1.4.4
Repository: https://github.com/arduino/iot-client-go.git
Documentation: pkg.go.dev

# README

Arduino iot-api Go client

Getting Started

The client requires a valid access token to authenticate, you can use the golang.org/x/oauth2 to easily get one with the Client Credentials OAuth2 flow:

import cc "golang.org/x/oauth2/clientcredentials"

// We need to pass the additional "audience" var to request an access token
additionalValues := url.Values{}
additionalValues.Add("audience", "https://api2.arduino.cc/iot")
// Set up OAuth2 configuration
config := cc.Config{
    ClientID:       clientID,
    ClientSecret:   clientSecret,
    TokenURL:       "https://api2.arduino.cc/iot/v1/clients/token",
    EndpointParams: additionalValues,
}
// Get the access token in exchange of client_id and client_secret
tok, err := config.Token(context.Background())
if err != nil {
    log.Fatalf("Error retrieving access token, %v", err)
}
// Confirm we got the token and print expiration time
log.Printf("Got an access token, will expire on %s", tok.Expiry)

For a working example, see the example folder in this repo.

How to get Arduino IoT Cloud Client Credentials

You can generate Arduino IoT Cloud Client Credentials in the ARDUINO API section in the IoT Cloud things section:

Step 1

IoT Cloud Site

Step 2

IoT Cloud Site

Step 3

IoT Cloud Site

# Functions

CacheExpires helper function to determine remaining time before repeating a request.
NewAPIClient creates a new API client.
NewAPIResponse returns a new APIResonse object.
NewAPIResponseWithError returns a new APIResponse object with the provided error message.
NewConfiguration returns a new Configuration object.

# Variables

ContextAccessToken takes a string oauth2 access token as authentication for the request.
ContextAPIKey takes an APIKey as authentication for the request.
ContextBasicAuth takes BasicAuth as authentication for the request.
ContextOAuth2 takes an oauth2.TokenSource as authentication for the request.

# Structs

APIClient manages communication with the Arduino IoT Cloud API API v2.0 In most cases there should be only one, shared, APIClient.
APIKey provides API key based authentication to a request passed via context using ContextAPIKey.
APIResponse stores the API response returned by the server.
ArduinoCompressedv2 compressed contains the info from which to generate the certificate (default view).
ArduinoDashboardowner ArduinoDashboardowner media type (default view).
ArduinoDashboardshare ArduinoDashboardshare media type (default view).
ArduinoDashboardv2 Dashboard is a collection of widgets (default view).
ArduinoDevicev2 ArduinoDevicev2 media type (default view).
ArduinoDevicev2Cert DeviceCertV2 describes a certificate associated to the device (default view).
ArduinoDevicev2EventProperties ArduinoDevicev2EventProperties media type (default view).
ArduinoDevicev2Pass DeviceCertV2 describes a password associated to a device (default view).
ArduinoDevicev2properties ArduinoDevicev2properties media type (default view).
ArduinoDevicev2propertyvalue ArduinoDevicev2propertyvalue media type (default view).
ArduinoDevicev2propertyvalues ArduinoDevicev2propertyvalues media type (default view).
ArduinoDevicev2propertyvaluesLastEvaluatedKey struct for ArduinoDevicev2propertyvaluesLastEvaluatedKey.
ArduinoDevicev2propertyvalueValue struct for ArduinoDevicev2propertyvalueValue.
ArduinoDevicev2propertyvalueValueStatistics struct for ArduinoDevicev2propertyvalueValueStatistics.
ArduinoDevicev2SimpleProperties ArduinoDevicev2SimpleProperties media type (default view).
ArduinoDevicev2Webhook DeviceWebhookV2 describes a webhook associated to the device (default view).
ArduinoLinkedvariable ArduinoLinkedvariable media type (default view).
ArduinoLoradevicev1 ArduinoLoradevicev1 media type (default view).
ArduinoLorafreqplansv1 ArduinoLorafreqplansv1 media type (default view).
ArduinoLorafreqplanv1 ArduinoLorafreqplanv1 media type (default view).
ArduinoProperty ArduinoProperty media type (default view).
ArduinoSeriesBatch ArduinoSeriesBatch media type (default view).
ArduinoSeriesRawBatch ArduinoSeriesRawBatch media type (default view).
ArduinoSeriesRawBatchLastvalue ArduinoSeriesRawBatchLastvalue media type (default view).
ArduinoSeriesRawLastValueResponse ArduinoSeriesRawLastValueResponse media type (default view).
ArduinoSeriesRawResponse ArduinoSeriesRawResponse media type (default view).
ArduinoSeriesResponse ArduinoSeriesResponse media type (default view).
ArduinoTags ArduinoTags media type (default view).
ArduinoThing ArduinoThing media type (default view).
ArduinoThinglayout ArduinoThinglayout media type (default view).
ArduinoTimeseriesmedia ArduinoTimeseriesmedia media type (default view).
ArduinoTimezone ArduinoTimezone media type (default view).
ArduinoVariableslinks ArduinoVariableslinks media type (default view).
ArduinoWidgetv2 Widget describes a dashboard widget (default view).
BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth.
BatchLastValueRequestsMediaV1 struct for BatchLastValueRequestsMediaV1.
BatchQueryRawLastValueRequestMediaV1 struct for BatchQueryRawLastValueRequestMediaV1.
BatchQueryRawRequestMediaV1 struct for BatchQueryRawRequestMediaV1.
BatchQueryRawRequestsMediaV1 struct for BatchQueryRawRequestsMediaV1.
BatchQueryRawResponseSeriesMediaV1 struct for BatchQueryRawResponseSeriesMediaV1.
BatchQueryRequestMediaV1 struct for BatchQueryRequestMediaV1.
BatchQueryRequestsMediaV1 struct for BatchQueryRequestsMediaV1.
No description provided by the author
CheckDevicesV2PassPayload struct for CheckDevicesV2PassPayload.
Configuration stores the configuration of the API client.
CreateDevicesV2CertsPayload struct for CreateDevicesV2CertsPayload.
CreateDevicesV2Payload DeviceV2 describes a device.
CreateLoraDevicesV1Payload struct for CreateLoraDevicesV1Payload.
CreateThingsV1Payload ThingPayload describes a thing.
CreateThingsV2Payload ThingPayload describes a thing.
Dashboardshare struct for Dashboardshare.
DashboardsV2CreateOpts Optional parameters for the method 'DashboardsV2Create'.
DashboardsV2DeleteOpts Optional parameters for the method 'DashboardsV2Delete'.
DashboardsV2DeleteShareOpts Optional parameters for the method 'DashboardsV2DeleteShare'.
DashboardsV2LinkOpts Optional parameters for the method 'DashboardsV2Link'.
DashboardsV2ListOpts Optional parameters for the method 'DashboardsV2List'.
DashboardsV2ListSharesOpts Optional parameters for the method 'DashboardsV2ListShares'.
DashboardsV2RequestAccessOpts Optional parameters for the method 'DashboardsV2RequestAccess'.
DashboardsV2ShareOpts Optional parameters for the method 'DashboardsV2Share'.
DashboardsV2ShowOpts Optional parameters for the method 'DashboardsV2Show'.
DashboardsV2UpdateOpts Optional parameters for the method 'DashboardsV2Update'.
Dashboardv2 DashboardV2Payload describes a dashboard.
DevicesV2CreateOpts Optional parameters for the method 'DevicesV2Create'.
DevicesV2DeleteOpts Optional parameters for the method 'DevicesV2Delete'.
DevicesV2GetEventsOpts Optional parameters for the method 'DevicesV2GetEvents'.
DevicesV2GetPropertiesOpts Optional parameters for the method 'DevicesV2GetProperties'.
DevicesV2ListOpts Optional parameters for the method 'DevicesV2List'.
DevicesV2OtaUploadOpts Optional parameters for the method 'DevicesV2OtaUpload'.
DevicesV2PassGetOpts Optional parameters for the method 'DevicesV2PassGet'.
DevicesV2ShowOpts Optional parameters for the method 'DevicesV2Show'.
DevicesV2TimeseriesOpts Optional parameters for the method 'DevicesV2Timeseries'.
DevicesV2UpdateOpts Optional parameters for the method 'DevicesV2Update'.
DevicesV2UpdatePropertiesOpts Optional parameters for the method 'DevicesV2UpdateProperties'.
Devicev2 DeviceV2 describes a device.
Devicev2Cert struct for Devicev2Cert.
Devicev2Otabinaryurl struct for Devicev2Otabinaryurl.
Devicev2Pass struct for Devicev2Pass.
GenericOpenAPIError Provides access to the body, error and model on returned errors.
HistoricDataRequest struct for HistoricDataRequest.
InlineObject struct for InlineObject.
LoraDevicesV1CreateOpts Optional parameters for the method 'LoraDevicesV1Create'.
ModelError Error response media type (default view).
PropertiesV1DeleteOpts Optional parameters for the method 'PropertiesV1Delete'.
PropertiesV1ListOpts Optional parameters for the method 'PropertiesV1List'.
PropertiesV1ShowOpts Optional parameters for the method 'PropertiesV1Show'.
PropertiesV2DeleteOpts Optional parameters for the method 'PropertiesV2Delete'.
PropertiesV2ListOpts Optional parameters for the method 'PropertiesV2List'.
PropertiesV2ShowOpts Optional parameters for the method 'PropertiesV2Show'.
PropertiesV2TimeseriesOpts Optional parameters for the method 'PropertiesV2Timeseries'.
PropertiesValue struct for PropertiesValue.
PropertiesValues struct for PropertiesValues.
Property PropertyPayload describes a property of a thing.
PropertyStringValue PropertyStringValuePayload describes a property value.
PropertyValue PropertyValuePayload describes a property value.
ServerConfiguration stores the information about a server.
ServerVariable stores the information about a server variable.
Sharerequest struct for Sharerequest.
Tag struct for Tag.
Thing ThingPayload describes a thing.
ThingCreate Payload to create a new thing.
ThingSketch ThingSketchPayload describes a sketch of a thing.
ThingsV1CreateOpts Optional parameters for the method 'ThingsV1Create'.
ThingsV1DeleteOpts Optional parameters for the method 'ThingsV1Delete'.
ThingsV1LayoutOpts Optional parameters for the method 'ThingsV1Layout'.
ThingsV1ListOpts Optional parameters for the method 'ThingsV1List'.
ThingsV1ShowOpts Optional parameters for the method 'ThingsV1Show'.
ThingsV1UpdateOpts Optional parameters for the method 'ThingsV1Update'.
ThingsV2CreateOpts Optional parameters for the method 'ThingsV2Create'.
ThingsV2CreateSketchOpts Optional parameters for the method 'ThingsV2CreateSketch'.
ThingsV2DeleteOpts Optional parameters for the method 'ThingsV2Delete'.
ThingsV2DeleteSketchOpts Optional parameters for the method 'ThingsV2DeleteSketch'.
ThingsV2ListOpts Optional parameters for the method 'ThingsV2List'.
ThingsV2ShowOpts Optional parameters for the method 'ThingsV2Show'.
ThingsV2UpdateOpts Optional parameters for the method 'ThingsV2Update'.
ThingsV2UpdateSketchOpts Optional parameters for the method 'ThingsV2UpdateSketch'.
ThingUpdate Payload to update an existing thing.
TimeseriesDataPoint struct for TimeseriesDataPoint.
UpdateSketch struct for UpdateSketch.
Widget Widget describes a dashboard widget.
Widgetlink struct for Widgetlink.

# Type aliases

DashboardsV2ApiService DashboardsV2Api service.
DevicesV2ApiService DevicesV2Api service.
DevicesV2CertsApiService DevicesV2CertsApi service.
DevicesV2OtaApiService DevicesV2OtaApi service.
DevicesV2PassApiService DevicesV2PassApi service.
DevicesV2TagsApiService DevicesV2TagsApi service.
LoraDevicesV1ApiService LoraDevicesV1Api service.
LoraFreqPlanV1ApiService LoraFreqPlanV1Api service.
PropertiesV1ApiService PropertiesV1Api service.
PropertiesV2ApiService PropertiesV2Api service.
SeriesV1ApiService SeriesV1Api service.
SeriesV2ApiService SeriesV2Api service.
ThingsV1ApiService ThingsV1Api service.
ThingsV2ApiService ThingsV2Api service.
ThingsV2TagsApiService ThingsV2TagsApi service.