Stats API

Created by Lara Menéndez · last update May 21, 2019

What is about?

The Empathy Stats API is the service provided to access data stored in Empathy servers. This data can be retrieved shaped as different reports each one containing different data.

To get data from these reports, just follow the step-by-step guide below.

Step by step guide

  • Step 1: Getting your user and API token

    To retrieve data from any report a user token is needed. To get it, the user has to log in Stats API through the POST request detailed. This request will return the user_token.

    These credentials are the same used to access to any Empathy Service (Dashboard, Insights.. ). If you don’t have your username and password, please ask Support Team

    POST https://api.empathybroker.com/user/v1/user/login

    Query parameters No needed.

    Body

    1
    2
    3
    4
    
    {
      "email": "myusername@myemaildomain.com",
      "password": "myPassword_123"
    }
    

    Bearer Token No needed.

    Response

    1
    2
    3
    4
    
    {
        "expiration_date": "2019-07-25T16:54:13Z",
        "user_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NiJ9.eyJlYjo6aWQiOiI1Y2ExZDQxYzkyODZkZTAwMTVjMzNjMmEiLCJlYjo6cm9sZXMiOnsiU0VBUkNIX0FOQUxZU1QiOlsiKiJdLCJFQl9VU0VSUyI6WyIqIl0sIkVCX1NFUlZJQ0VTIjpbIioiXSwiRUJfSU5GTyI6WyIqIl0sIkVCX0ZFRURTIjpbIioiXSwiRUJfQURNSU4iOlsiKiJdfSwiZXhwIjoxNTY0MDczNjUzLCJpYXQiOjE1NjQwNDQ4NTMsImlzcyI6IlVzZXJTZXJ2aWNlIiwianRpIjoieGRaeGRSZEZrMFkvc2Q0KyIsInN1YiI6ImxhcmFtQGVtcGF0aHkuY28ifQ.yY2MtO_wGk03u902onbhEWV6Oa_zBD8WQr9r8_oIZ3pmvqT4KEaT-jBGmpJZ0FJsz5rZ4SPBeRyGQxwa_NT7Mg"
    }
    

  • Step 2: Refreshing the token

    After 8 hours after logging in, a fresh new user_token will be needed. To get it, the request detailed should be perform using the old token as a token for this request.

    POST https://api.empathybroker.com/user/v1/user/refresh

    Query parameters No needed.

    Body No needed

    Bearer Token No needed.

    Response

    1
    2
    3
    4
    5
    
    {
        "expiration_date": "2019-07-25T16:54:13Z",
        "user_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NiJ9.eyJlYjo6aWQiOiI1Y2ExZDQxYzkyODZkZTAwMTVjMzNjMmEiLCJlYjo6cm9sZXMiOnsiU0VBUkNIX0FOQUxZU1QiOlsiKiJdLCJFQl9VU0VSUyI6WyIqIl0sIkVCX1NFUlZJQ0VTIjpbIioiXSwiRUJfSU5GTyI6WyIqIl0sIkVCX0ZFRURTIjpbIioiXSwiRUJfQURNSU4iOlsiKiJdfSwiZXhwIjoxNTY0MDczNjUzLCJpYXQiOjE1NjQwNDQ4NTMsImlzcyI6IlVzZXJTZXJ2aWNlIiwianRpIjoieGRaeGRSZEZrMFkvc2Q0KyIsInN1YiI6ImxhcmFtQGVtcGF0aHkuY28ifQ.yY2MtO_wGk03u902onbhEWV6Oa_zBD8WQr9r8_oIZ3pmvqT4KEaT-jBGmpJZ0FJsz5rZ4SPBeRyGQxwa_NT7Mg"
    }
    
    

  • Step 3: Choose the most suitable report

    Once user_token is obtained, you are ready to retrieve any of the following available reports. You only have to choose reports that cover your business requirements.

    To have more detail about them just follow links to its specific section:

  • Step 4: Get your data

    Now you’re ready to get your data. It will be returned shaped into JSON or csv format. Below a quick video explaining the whole process