Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/noelportugal/AmazonEchoApi
This is a simple way to login to Amazon and retrieve the unnoficial Echo API
https://github.com/noelportugal/AmazonEchoApi
Last synced: about 2 months ago
JSON representation
This is a simple way to login to Amazon and retrieve the unnoficial Echo API
- Host: GitHub
- URL: https://github.com/noelportugal/AmazonEchoApi
- Owner: noelportugal
- Created: 2014-12-24T21:10:24.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2014-12-29T14:37:33.000Z (over 9 years ago)
- Last Synced: 2024-06-08T13:33:30.236Z (4 months ago)
- Language: Java
- Homepage:
- Size: 1.24 MB
- Stars: 80
- Watchers: 22
- Forks: 13
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
AmazonEchoApi
=============UPDATE: Check out an implementation https://github.com/noelportugal/AmazonEchoHomeAutomation
This is a simple way to login to Amazon and retrieve the unnoficial Echo API. I purposely didn't use Amazon SDKs so anyone can see how to simulate a login and implement with any language. The endoint investigation was done by Owen Piettes and can be found here http://www.piettes.com/the-amazon-echo-api/.
Here is a list of some the endpoints that are of particular interest to observe:
- TODOs: https://pitangui.amazon.com/api/todos?type=TASK&size=1
- Cards: https://pitangui.amazon.com/api/cards?limit=3
- Notifications: https://pitangui.amazon.com/api/notificationsBasic Usage
=============
```
AmazonEchoApi amazonEchoApi = new AmazonEchoApi("https://pitangui.amazon.com","username", "password");
if (amazonEchoApi.httpLogin()){
String output = amazonEchoApi.httpGet("/api/todos?type=TASK&size=1");
}
```
After getting output you can parse the JSON and do whatever you want. If you look at my AmazonEchoApi.java main, you will see that I check the TODO list every 15 seconds and store the itemId. If there is a new one then I go ahead and trigger whatever I want.This example was build with Netbeans and runs in a Raspberry Pi. I included the following libs:
* HttpClient
* Simple-JSON
* JSoupFull Example
=============
```
public static void main(String[] args) throws InterruptedException, IOException {
AmazonEchoApi amazonEchoApi = new AmazonEchoApi("https://pitangui.amazon.com","username", "password");
if (amazonEchoApi.httpLogin()){
while (true) {
String output = amazonEchoApi.httpGet("/api/todos?type=TASK&size=1");// Parse JSON
Object obj = JSONValue.parse(output);
JSONObject jsonObject = (JSONObject) obj;
JSONArray values = (JSONArray) jsonObject.get("values");
JSONObject item = (JSONObject)values.get(0);
// Get text and itemId
String text = item.get("text").toString();
String itemId = item.get("itemId").toString();
if (!checkItemId(itemId)){
addItemId(itemId);
System.out.println(text);
// Do something. ie Hue Lights, etc
}else{
System.out.println("No new commands");
}
// Sleep for 15 seconds
Thread.sleep(15000);
}}
}
```