Difference between revisions of "Starling API"
m (sub category changes) |
|||
Line 16: | Line 16: | ||
|} | |} | ||
− | ===Example with CURL=== | + | ==='''Example with CURL'''=== |
* Request | * Request | ||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript"> | ||
Line 28: | Line 28: | ||
iwiZXhwIjoiMTQsdfeaeSEFEA0NiIsIm5iZiI6IjE0NTE1NjMwNDYiLCJqdGkiOiI4asdfew} | iwiZXhwIjoiMTQsdfeaeSEFEA0NiIsIm5iZiI6IjE0NTE1NjMwNDYiLCJqdGkiOiI4asdfew} | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | + | ==='''Using Postman Client'''=== | |
[[File:Obtain token.PNG|x400px|example with postman]] | [[File:Obtain token.PNG|x400px|example with postman]] | ||
Revision as of 18:43, 27 January 2016
Contents
Authentication
Starling API works on javascript web-tokens. The default validity for the tokens is 1 year. It will be changed to shorter duration soon.
If you own a starling, create an account here.
Base URL for all requests: http://starling.exploreembedded.com
Obtaining the token
http verb | Request | Response | Description |
---|---|---|---|
POST | /api/authenticate | token | Pass email and password as body parameter to obtain a web token |
Example with CURL
- Request
curl -X POST -F "email=your@email.com" -F "password=password" \ 'http://starling.exploreembedded.com/api/authenticate'
- Response
{"token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXUyJ9.eyJzdWIiOiIyIiwiaXNzIjoiaHR0c DpcL1wvc3RhcmxpbmcuZXhwbG9yZWVtYmVkasdfdsfNvbVwvYXBpXC9hdXRoZW50. iwiZXhwIjoiMTQsdfeaeSEFEA0NiIsIm5iZiI6IjE0NTE1NjMwNDYiLCJqdGkiOiI4asdfew}
Using Postman Client
Starling device Registration and access
Every API request should include the token obtained above as a parameter in url or header.
http verb | Request | Response | Description |
---|---|---|---|
GET | /api/starlings | returns all the starlings registered for the given user | validates the user and returns any starlings registered in JSON |
GET | /api/starling/{id} | returns a particular starling | validates the user and returns the given starling data as JSON |
PUT | /api/starling/{id} | edits a particular starling | the parameter need to send as form or url encoded data |
DEL | /api/starling/{id} | deletes the starling with the given ID | use with caution |
POST | /api/starling | pass the parameters in the form body | Creates a new starling after validating the data |
Messaging
Every API request should include the token obtained above as a parameter in url or header.
http verb | Request | Response | Description |
---|---|---|---|
POST | api/message/queue | success or failure | Adds a message to the queue. 50 messages are stored for every starling. This is handy to queue and display twitter feed. A message is picked from the queue every 2 minutes, displayed and deleted. The post data should contain the following
|
GET | api/messages/{starling_id} | json array | Gets all messages stored for a particular starling |