Stats API

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

What is this about?

The Empathy Stats API is the service provided to access data stored in Empathy servers. This data can be retrieved and shaped into 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 an API token

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

    The credentials are the same that are used to access any Empathy Service (Dashboard, Insights.. ). If you don’t have this username and password , please ask the 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

    Eight hours after logging in, a fresh new user_token will be needed. To get it, the request shown here should be performed 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 reports. You only have to choose reports that cover your business requirements.

    To obtain more detail about them, just follow the links to each report’s specific section:

  • Step 4: Get your data

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