Support
Blues.io
Notehub.io
Shop
Support
Blues.io
Notehub.io
Shop
×
HomeReference
Glossary
Notecard Walkthrough
Overview
Notecard Requests & Responses
JSON Fundamentals
Notecard Interfaces
Essential Requests
Time & Location Requests
Inbound Requests & Shared Data
Web Transactions
Low Power Design
Low Bandwidth Design
Host Firmware Update Requests
Advanced Notecard Configuration
Complete API Reference
Introduction
card Requests
dfu Requests
env Requests
file Requests
hub Requests
note Requests
web Requests

Web Transactions

If your host needs to perform web requests to a 3rd party API or service, the Notecard can facilitate these requests with the web.get, web.put, and web.post requests. Use of these requests in the Notecard API requires the following:

  1. The Notecard must be in continuous mode (via a hub.set request) and connected to Notehub. If any of the web.* requests are issued to a Notecard not in continuous mode or not connected, an error will be returned.
{"err":"web operations require being online (hub.set)"}
  1. The endpoint to the 3rd party API or service must be configured as a proxy Route in Notehub as a "Proxy for Device Web Requests" type. This allows the host to avoid hardcoded URLs, keys, and certificates, while relying on Notehub secure authentication mechanisms for performing requests.

Once the device is in continuous mode and proxy Route is created, use web.get, web.put or web.post in accordance with the requirements of the final endpoint.

For example, the Route shown above creates a proxy to a GET request to weather endpoint of the OpenWeatherMap API. To call this Route, a web.get request should be used. The route argument corresponds to the Route Alias specified when the proxy Route is created.

{
  "req":   "web.get",
  "route": "GetWeather"
}

For all web requests, the Notecard returns the HTTP Status Code in the result field. If the response also contains a body, that body is provided in the body field.

warning

The Notecard can only accept valid JSON in response to a web.get request. Full HTML and other types of responses will result in a parse error on the Notecard.

{
  "result": 200,
  "body":{
    "base":   "stations",
    "clouds": {"all":75},
    "coord":  {"lat":42.577600,"lon":-70.871340},
    "name":   "Beverly",
    "weather":[
      {"description":"broken clouds","icon":"04d","id":803,"main":"Clouds"}
    ],
    "wind":{"deg":240,"speed":5.1}
  }
}
note

Data returned by a proxy Route is delivered to the Notecard unmodified. To preserve power and data, make sure the APIs you're working with return only the data needed by your host, if possible.

For web.put and web.post requests, a JSON body can be provided using the body argument.

{
  "req":   "web.post",
  "route": "ProvisonDevice"
  "body":  {"device":"dev123455"}
}

After performing a web request, don't forget to set your Notecard back into a non-continuous mode, if needed, using hub.set.

Inbound Requests & Shared DataLow Power Design
Can we improve this page? Send us feedbackRate this page
  • ★
    ★
  • ★
    ★
  • ★
    ★
  • ★
    ★
  • ★
    ★
© 2021 Blues Inc.Terms & ConditionsPrivacy
blues.ioTwitterLinkedInGitHubHackster.io
Disconnected
Disconnected
Having trouble connecting?

Try changing your Micro USB cable as some cables do not support transferring data. If that does not solve your problem, contact us at support@blues.com and we will get you set up with another tool to communicate with the Notecard.

Connect a NotecardClick 'Connect' and select a USB-connected Notecard to start issuing commands from the browser.