Skip to main content

Mutable Ideas

How-To: Accessing Socialmetrix Quantum API to Create custom Social Dashboards

This is the first post of a series on how to use Socialmetrix Quantum as datasource, which enables you to create custom dashboards or ingest social data into your internal systems empowering your big data initiatives.

To get started, we will login into your Quantum account and get the API authentication token. Don’t have an account yet? Get a free trial!

## API Authentication

All methods in the API need to be authenticated with Json Web Token (JWT), in order to obtain your JWT you need to:

  • Get your API Secret
  • Submit a request to /login with your API Secret
  • Read the response and store your JWT for less than 20 days

## Getting your API Secret

1- Login at Socialmetrix Quantum using Facebook or Twitter.

Quantum Login Screen

2- After logging-in, go to My Account:

Quantum My Account menu

3- Click on My Account:

Quantum My Account

4- Select option API and copy your API Secret:

Quantum API Secret

IMPORTANT: Please do not expose your API Secret - if an attacker have control of your API Secret, he/she will be able to delete all your accounts. Keep it safe!

## Getting your Json Web Token

You need POST a json containing the method (“API-SECRET”) and your secret. As show below:

curl -XPOST 'https://api.quantum.socialmetrix.com/login' \
-H "Content-Type: application/json" \
-d '{
  "method":"API-SECRET",
  "secret":"0220a22d27be69e4.........54aa9840e5c4136e"
}'

If everything is OK, the response contains two important fields that will be used on subsequent requests jwt and accountId.

{
  "jwt": "eyJhbGciOiJIUzI1NiJ9.eyJpc3M.........Xl294h4pM7FSLkpq2nUE5_VSgt5KoYIo",
  "user": {
    "id": "806d642b4a6.........7d8f9d1b234f",
    "firstName": "Gustavo",
    "lastName": "Arjones",
    "email": "api socialmetrix.com",
    "timezone": "Etc/UTC",
    "role": "OWNER",
    "facebookAuth": {
      "userId": "557905121",
      "token": "CAAGZBqihd9k8BAPp0zgN7qCP0Eohh8R4jLrrvBzKy.........zNAO3E1iztEDYqdkZD"
    },
    "twitterAuth": {
      "userId": "15092087",
      "token": "15092087-jSYCamwrKt.........2vXQLE6I40KqtuDg",
      "secret": "WVaOHI1R0ivc.........0rjHzygJdbROxzeiCmbN"
    },
    "accountId": 790,
    "projectIds": [],
    "createdAt": "2015-07-23T19:53:13Z",
    "lastLogin": "2015-10-13T18:42:03Z"
  }
}

IMPORTANT: API Secret has an expire of 20 days, you MUST re-authorize at least one time within this period

## Requesting your current projects

One of the first requests you probably will do is get a list of all your active projects.

The endpoint to access is: GET https://api.quantum.socialmetrix.com/v1/accounts/YOUR_ACCOUNT_ID/projects

A sample request is:

curl -XGET 'https://api.quantum.socialmetrix.com/v1/accounts/790/projects' \
  -H "Content-Type: application/json" \
  -H "X-Auth-Token: eyJhbGciOiJIUzI1NiJ9.eyJpc3M.........Xl294h4pM7FSLkpq2nUE5_VSgt5KoYIo"

That’s all! Next time, we will get more information to understand specific aspects from the social profiles.

.