The Internet of Things for Everyone The Adafruit IO HTTP API provides access to your Adafruit IO data from any programming language or hardware environment that can speak HTTP. The easiest way to get started is with an Adafruit IO learn guide and a simple Internet of Things capable device like the Feather Huzzah. This API documentation is hosted on GitHub Pages and is available at https://github.com/adafruit/io-api. For questions or comments visit the Adafruit IO Forums or the adafruit-io channel on the Adafruit Discord server.
###Authentication Authentication for every API request happens through the X-AIO-Key
header or query parameter and your IO API key. A simple cURL request to get all available feeds for a user with the username "io_username" and the key "io_key_12345" could look like this:
$ curl -H \"X-AIO-Key: io_key_12345\" https://io.adafruit.com/api/v2/io_username/feeds
Or like this:
$ curl \"https://io.adafruit.com/api/v2/io_username/feeds?X-AIO-Key=io_key_12345
Using the node.js request library, IO HTTP requests are as easy as:
var request = require('request'); var options = { url: 'https://io.adafruit.com/api/v2/io_username/feeds', headers: { 'X-AIO-Key': 'io_key_12345', 'Content-Type': 'application/json' } }; function callback(error, response, body) { if (!error && response.statusCode == 200) { var feeds = JSON.parse(body); console.log(feeds.length + \" FEEDS AVAILABLE\"); feeds.forEach(function (feed) { console.log(feed.name, feed.key); }) } } request(options, callback);
Using the ESP8266 Arduino HTTPClient library, an HTTPS GET request would look like this (replacing ---
with your own values in the appropriate locations):
/// based on /// https://github.com/esp8266/Arduino/blob/master/libraries/ESP8266HTTPClient/examples/Authorization/Authorization.ino #include <Arduino.h> #include <ESP8266WiFi.h> #include <ESP8266WiFiMulti.h> #include <ESP8266HTTPClient.h> ESP8266WiFiMulti WiFiMulti; const char* ssid = \"---\"; const char* password = \"---\"; const char* host = \"io.adafruit.com\"; const char* io_key = \"---\"; const char* path_with_username = \"/api/v2/---/dashboards\"; // Use web browser to view and copy // SHA1 fingerprint of the certificate const char* fingerprint = \"77 00 54 2D DA E7 D8 03 27 31 23 99 EB 27 DB CB A5 4C 57 18\"; void setup() { Serial.begin(115200); for(uint8_t t = 4; t > 0; t--) { Serial.printf(\"[SETUP] WAIT %d...\\n\", t); Serial.flush(); delay(1000); } WiFi.mode(WIFI_STA); WiFiMulti.addAP(ssid, password); // wait for WiFi connection while(WiFiMulti.run() != WL_CONNECTED) { Serial.print('.'); delay(1000); } Serial.println(\"[WIFI] connected!\"); HTTPClient http; // start request with URL and TLS cert fingerprint for verification http.begin(\"https://\" + String(host) + String(path_with_username), fingerprint); // IO API authentication http.addHeader(\"X-AIO-Key\", io_key); // start connection and send HTTP header int httpCode = http.GET(); // httpCode will be negative on error if(httpCode > 0) { // HTTP header has been send and Server response header has been handled Serial.printf(\"[HTTP] GET response: %d\\n\", httpCode); // HTTP 200 OK if(httpCode == HTTP_CODE_OK) { String payload = http.getString(); Serial.println(payload); } http.end(); } } void loop() {}
Client Libraries We have client libraries to help you get started with your project: Python, Ruby, Arduino C++, Javascript, and Go are available. They're all open source, so if they don't already do what you want, you can fork and add any feature you'd like.
This API client was generated by the swagger-codegen project. By using the swagger-spec from a remote server, you can easily generate an API client.
- API version: 2.0.0
- Package version: 1.0.0
- Build package: io.swagger.codegen.languages.GoClientCodegen
Put the package under your project folder and add the following in import:
import "./swagger"
All URIs are relative to https://io.adafruit.com/api/v2
Class | Method | HTTP request | Description |
---|---|---|---|
ActivitiesApi | AllActivities | Get /{username}/activities | All activities for current user |
ActivitiesApi | DestroyActivities | Delete /{username}/activities | All activities for current user |
ActivitiesApi | GetActivity | Get /{username}/activities/{type} | Get activities by type for current user |
BlocksApi | AllBlocks | Get /{username}/dashboards/{dashboard_id}/blocks | All blocks for current user |
BlocksApi | CreateBlock | Post /{username}/dashboards/{dashboard_id}/blocks | Create a new Block |
BlocksApi | DestroyBlock | Delete /{username}/dashboards/{dashboard_id}/blocks/{id} | Delete an existing Block |
BlocksApi | GetBlock | Get /{username}/dashboards/{dashboard_id}/blocks/{id} | Returns Block based on ID |
BlocksApi | ReplaceBlock | Put /{username}/dashboards/{dashboard_id}/blocks/{id} | Replace an existing Block |
BlocksApi | UpdateBlock | Patch /{username}/dashboards/{dashboard_id}/blocks/{id} | Update properties of an existing Block |
DashboardsApi | AllDashboards | Get /{username}/dashboards | All dashboards for current user |
DashboardsApi | CreateDashboard | Post /{username}/dashboards | Create a new Dashboard |
DashboardsApi | DestroyDashboard | Delete /{username}/dashboards/{id} | Delete an existing Dashboard |
DashboardsApi | GetDashboard | Get /{username}/dashboards/{id} | Returns Dashboard based on ID |
DashboardsApi | ReplaceDashboard | Put /{username}/dashboards/{id} | Replace an existing Dashboard |
DashboardsApi | UpdateDashboard | Patch /{username}/dashboards/{id} | Update properties of an existing Dashboard |
DataApi | AllData | Get /{username}/feeds/{feed_key}/data | Get all data for the given feed |
DataApi | AllGroupFeedData | Get /{username}/groups/{group_key}/feeds/{feed_key}/data | All data for current feed in a specific group |
DataApi | BatchCreateData | Post /{username}/feeds/{feed_key}/data/batch | Create multiple new Data records |
DataApi | BatchCreateGroupFeedData | Post /{username}/groups/{group_key}/feeds/{feed_key}/data/batch | Create multiple new Data records in a feed belonging to a particular group |
DataApi | ChartData | Get /{username}/feeds/{feed_key}/data/chart | Chart data for current feed |
DataApi | CreateData | Post /{username}/feeds/{feed_key}/data | Create new Data |
DataApi | CreateGroupData | Post /{username}/groups/{group_key}/data | Create new data for multiple feeds in a group |
DataApi | CreateGroupFeedData | Post /{username}/groups/{group_key}/feeds/{feed_key}/data | Create new Data in a feed belonging to a particular group |
DataApi | CreateRawWebhookFeedData | Post /webhooks/feed/:token/raw | Send arbitrary data to a feed via webhook URL. |
DataApi | CreateWebhookFeedData | Post /webhooks/feed/:token | Send data to a feed via webhook URL. |
DataApi | DestroyData | Delete /{username}/feeds/{feed_key}/data/{id} | Delete existing Data |
DataApi | FirstData | Get /{username}/feeds/{feed_key}/data/first | First Data in Queue |
DataApi | GetData | Get /{username}/feeds/{feed_key}/data/{id} | Returns data based on feed key |
DataApi | LastData | Get /{username}/feeds/{feed_key}/data/last | Last Data in Queue |
DataApi | NextData | Get /{username}/feeds/{feed_key}/data/next | Next Data in Queue |
DataApi | PreviousData | Get /{username}/feeds/{feed_key}/data/previous | Previous Data in Queue |
DataApi | ReplaceData | Put /{username}/feeds/{feed_key}/data/{id} | Replace existing Data |
DataApi | RetainData | Get /{username}/feeds/{feed_key}/data/retain | Last Data in MQTT CSV format |
DataApi | UpdateData | Patch /{username}/feeds/{feed_key}/data/{id} | Update properties of existing Data |
FeedsApi | AddFeedToGroup | Post /{username}/groups/{group_key}/add | Add an existing Feed to a Group |
FeedsApi | AllFeeds | Get /{username}/feeds | All feeds for current user |
FeedsApi | AllGroupFeeds | Get /{username}/groups/{group_key}/feeds | All feeds for current user in a given group |
FeedsApi | CreateFeed | Post /{username}/feeds | Create a new Feed |
FeedsApi | CreateGroupFeed | Post /{username}/groups/{group_key}/feeds | Create a new Feed in a Group |
FeedsApi | DestroyFeed | Delete /{username}/feeds/{feed_key} | Delete an existing Feed |
FeedsApi | GetFeed | Get /{username}/feeds/{feed_key} | Get feed by feed key |
FeedsApi | GetFeedDetails | Get /{username}/feeds/{feed_key}/details | Get detailed feed by feed key |
FeedsApi | RemoveFeedFromGroup | Post /{username}/groups/{group_key}/remove | Remove a Feed from a Group |
FeedsApi | ReplaceFeed | Put /{username}/feeds/{feed_key} | Replace an existing Feed |
FeedsApi | UpdateFeed | Patch /{username}/feeds/{feed_key} | Update properties of an existing Feed |
GroupsApi | AddFeedToGroup | Post /{username}/groups/{group_key}/add | Add an existing Feed to a Group |
GroupsApi | AllGroupFeeds | Get /{username}/groups/{group_key}/feeds | All feeds for current user in a given group |
GroupsApi | AllGroups | Get /{username}/groups | All groups for current user |
GroupsApi | CreateGroup | Post /{username}/groups | Create a new Group |
GroupsApi | DestroyGroup | Delete /{username}/groups/{group_key} | Delete an existing Group |
GroupsApi | GetGroup | Get /{username}/groups/{group_key} | Returns Group based on ID |
GroupsApi | RemoveFeedFromGroup | Post /{username}/groups/{group_key}/remove | Remove a Feed from a Group |
GroupsApi | ReplaceGroup | Put /{username}/groups/{group_key} | Replace an existing Group |
GroupsApi | UpdateGroup | Patch /{username}/groups/{group_key} | Update properties of an existing Group |
PermissionsApi | AllPermissions | Get /{username}/{type}/{type_id}/acl | All permissions for current user and type |
PermissionsApi | CreatePermission | Post /{username}/{type}/{type_id}/acl | Create a new Permission |
PermissionsApi | DestroyPermission | Delete /{username}/{type}/{type_id}/acl/{id} | Delete an existing Permission |
PermissionsApi | GetPermission | Get /{username}/{type}/{type_id}/acl/{id} | Returns Permission based on ID |
PermissionsApi | ReplacePermission | Put /{username}/{type}/{type_id}/acl/{id} | Replace an existing Permission |
PermissionsApi | UpdatePermission | Patch /{username}/{type}/{type_id}/acl/{id} | Update properties of an existing Permission |
TokensApi | AllTokens | Get /{username}/tokens | All tokens for current user |
TokensApi | CreateToken | Post /{username}/tokens | Create a new Token |
TokensApi | DestroyToken | Delete /{username}/tokens/{id} | Delete an existing Token |
TokensApi | GetToken | Get /{username}/tokens/{id} | Returns Token based on ID |
TokensApi | ReplaceToken | Put /{username}/tokens/{id} | Replace an existing Token |
TokensApi | UpdateToken | Patch /{username}/tokens/{id} | Update properties of an existing Token |
TriggersApi | AllTriggers | Get /{username}/triggers | All triggers for current user |
TriggersApi | CreateTrigger | Post /{username}/triggers | Create a new Trigger |
TriggersApi | DestroyTrigger | Delete /{username}/triggers/{id} | Delete an existing Trigger |
TriggersApi | GetTrigger | Get /{username}/triggers/{id} | Returns Trigger based on ID |
TriggersApi | ReplaceTrigger | Put /{username}/triggers/{id} | Replace an existing Trigger |
TriggersApi | UpdateTrigger | Patch /{username}/triggers/{id} | Update properties of an existing Trigger |
UsersApi | CurrentUser | Get /user | Get information about the current user |
UsersApi | GetCurrentUserThrottle | Get /{username}/throttle | Get the user's data rate limit and current activity level. |
WebhooksApi | CreateRawWebhookFeedData | Post /webhooks/feed/:token/raw | Send arbitrary data to a feed via webhook URL. |
WebhooksApi | CreateWebhookFeedData | Post /webhooks/feed/:token | Send data to a feed via webhook URL. |
- Activity
- Block
- BlockFeed
- Dashboard
- Data
- DataResponse
- Datum
- Feed
- FeedDetails
- FeedDetailsData
- Group
- GroupFeedData
- InlineResponse200
- InlineResponse2001
- InlineResponse2001Feed
- ModelError
- Payload
- Permission
- ShallowGroup
- Token
- Trigger
- User
- UsernamedashboardsdashboardIdblocksBlockFeeds
- UsernamegroupsgroupKeydataFeeds
- UsernamegroupsgroupKeydataLocation
- Type: API key
Example
auth := context.WithValue(context.Background(), sw.ContextAPIKey, sw.APIKey{
Key: "APIKEY",
Prefix: "Bearer", // Omit if not necessary.
})
r, err := client.Service.Operation(auth, args)
- Type: API key
Example
auth := context.WithValue(context.Background(), sw.ContextAPIKey, sw.APIKey{
Key: "APIKEY",
Prefix: "Bearer", // Omit if not necessary.
})
r, err := client.Service.Operation(auth, args)
- Type: API key
Example
auth := context.WithValue(context.Background(), sw.ContextAPIKey, sw.APIKey{
Key: "APIKEY",
Prefix: "Bearer", // Omit if not necessary.
})
r, err := client.Service.Operation(auth, args)