Skip to content

Instantly share code, notes, and snippets.

@shaharmor
Created August 2, 2015 12:29
Show Gist options
  • Select an option

  • Save shaharmor/c5259ff36a4b79ebd3b0 to your computer and use it in GitHub Desktop.

Select an option

Save shaharmor/c5259ff36a4b79ebd3b0 to your computer and use it in GitHub Desktop.

Revisions

  1. shaharmor created this gist Aug 2, 2015.
    100 changes: 100 additions & 0 deletions plantie.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,100 @@
    plantie-api
    -----------

    ## Authentication

    - **Signup:**

    Route: `POST: /api/signup`

    Body:
    ```javascript
    {
    email: '[email protected]',
    password: "yourpassword'
    }
    ```
    Response:
    ```javascript
    {
    error: false, // or true if failed
    msg: 'Signup succeeded',
    data: {
    access_token: 'YOUR_ACCESS_TOKEN'
    }
    }
    ```
    - **Login:**
    Route: `POST: /api/login`
    Body:
    ```javascript
    {
    email: '[email protected]',
    password: 'yourpassword'
    }
    ```
    Response:
    ```javascript
    {
    error: false, // or true if failed
    msg: 'Login succeeded',
    data: {
    access_token: 'YOUR_ACCESS_TOKEN'
    }
    }
    ```
    ## Device management
    - **Claim**
    Route: `POST: /api/device/claim?access_token=YOUR_ACCESS_TOKEN`
    Body:
    ```javascript
    {
    id: 'YOUR_SPARK_DEVICE_ID'
    }
    ```
    Response:
    ```javascript
    {
    error: false, // or true if failed
    msg: 'Device claim succeeded'
    }
    ```
    - **List**
    Route: `GET: /api/device?access_token=YOUR_ACCESS_TOKEN`
    Response:
    ```javascript
    {
    error: false, // or true if failed
    msg: 'Devices listed',
    data: {
    devices: [{
    id: 'device1',
    metrics: {
    light: 100,
    moisture: 100,
    temperature: 30
    }
    }, {
    id: 'device2',
    metrics: {
    light: 200,
    moisture: 200,
    temperature: 25
    }
    }]
    }
    }
    ```