Search code examples
jawbone

Can we receive step data in the pub sub payload?


I can see in the payload JSON that the pubsub notification includes the events but is it also capable of sending the activity or sleep amounts (e.g steps or sleep minutes)?


Solution

  • No, the pubsub notification will only include the user and the list of events that took place. You can then use this information to query the APIs that pertain to those specific types of events.

    For example, suppose you receive the following pubsub notification:

    {
        "notification_timestamp": "1372787949",
        "events": [
            {
                "user_xid": "RGaCBFg9CsB83FsEcMY44A",
                "event_xid": "EJpCkyAtwoO0XTdkYyuTNw",
                "type": "move",
                "action": "creation" , 
                "timestamp": "1372787849"
            },
            {
                "user_xid": "RGaCBFg9CsB83FsEcMY44A",
                "event_xid": "blaHyAtwoO0XTdkYyuTNw",
                "type": "sleep",
                "action": "updation" , 
                "timestamp": "1372787859"
            }
        ],
        "secret_hash": "e570b3071a0964f9e2e69d13nd9ba19535392aaa",
    }
    

    Then you know that a move event was created and that a sleep event was updated for the user specified by user_xid: RGaCBFg9CsB83FsEcMY44A

    Use this user's xid to determine which previously saved access_token to send with your next API requests.

    You can get the details for the move event by sending a request to the moves endpoint with the event_xid: EJpCkyAtwoO0XTdkYyuTNw:

    GET https://jawbone.com/nudge/api/v.1.1/moves/EJpCkyAtwoO0XTdkYyuTNw
    

    And yo ucan get the details for the sleep event by querying the sleeps endpoint with the event_xid: blaHyAtwoO0XTdkYyuTN:

    GET https://jawbone.com/nudge/api/v.1.1/sleeps/blaHyAtwoO0XTdkYyuTN