Have a question?

API Introduction

Woopra API is mostly RESTful. API calls should be made with HTTP POST/GET to https://www.woopra.com/rest/[path].
A valid response has a 200 status code and a valid JSON in the body.

Authentication

Generate a new Access Key in your members area, plug App Id and Secret Key in your API http request headers:

X-Access-Id: appId
X-Access-Secret: secretKey

Versionning

Adding the http header for API version 2.0 (required)

X-Api-Version: 2.0

Error handling

The http request should contain:

  • valid X-Api-Version, otherwise it will return a 400 Bad Request
  • valid X-Access-Id and X-Access-Secret, otherwise it will return a 403 Forbidden
  • valid URI, otherwise it will return a 404 Not Found
  • valid ‘request’ POST parameter, containing the JSON request object. Otherwise it could result in 50x Server Error

Example jQuery Snippet

var params = {
    "request": JSON.stringify({
        website: "my-business.com",
        report: {
            "group_by": [{
                "key": "day",
                "scope": "visits"
            }],
            "render": "'Rendered value for '+ group_by(0) ",
            "order_by": "Total Actions",
            "columns": [{
                "name": "Unique Visitors",
                "method": "count",
                "scope": "visitors",
                "render": " Math.round(cell('Unique Visitors')) "
            }]
        },
        date_format: "MM-dd-yyyy",
        start_day: "02-12-2013",
        end_day: "02-19-2013",
        limit: 100,
        offset: 0
    })
};

$.ajax({
    type: 'POST',
    url: 'http://www.woopra.com/rest/report',
    crossDomain: true,
    dataType: "json",
    jsonp: false,
    cache: false,
    beforeSend: function (xhr) {
        xhr.setRequestHeader('X-Api-Version', '2.0');
        xhr.setRequestHeader('X-Access-Id', 'RONWDCCFEOHVQ4U30ESHSYNTW4W9VVZ7');
        xhr.setRequestHeader('X-Access-Secret', 'JhYxou0LOHgEasdGD4z3CufdhgtjwFrw2WdOAtQFG56265gGYggqbAMuYEOirVo');
    },
    data: params,
    success: function (text) {
        alert(text);
    }
});

Example raw HTTP frame:

POST /rest/report HTTP/1.1
Host: www.woopra.com
X-Api-Version: 2.0
X-Access-Id: QSBEUTTEZ8J5CEUVIUECQK99PWVH7TLE
X-Access-Secret: wmaH6Oqk9THl7gW3nouRBSsIHyM8d9YJjIhwRgTLbUI1Spnnqb4bqMEP7CuBJQ7C

request=%7B%22report%22%3A%7B%22group_by%22%3A%5B%7B%22key%22%3A%22day%22%2C%22scope%22%3A%22visits%22%7D%5D%2C%22render%22%3A%22%27Rendered%20value%20for%20%27+%20group_by%280%29%20%22%2C%22order_by%22%3A%22Total%20Actions%22%2C%22columns%22%3A%5B%7B%22name%22%3A%22Unique%20Visitors%22%2C%22method%22%3A%22count%22%2C%22scope%22%3A%22visitors%22%2C%22render%22%3A%22%20Math.round%28cell%28%27Unique%20Visitors%27%29%29%20%22%7D%2C%7B%22name%22%3A%22Page%20Views%22%2C%22method%22%3A%22count%22%2C%22scope%22%3A%22actions%22%2C%22render%22%3A%22%20Math.round%28cell%28%27Page%20Views%27%29%29%20%22%7D%2C%7B%22name%22%3A%22Page%20Views%20per%20Visitor%22%2C%22method%22%3A%22formula%22%2C%22calc%22%3A%22%20%20cell%28%27Page%20Views%27%29%20/%20cell%28%27Unique%20Visitors%27%29%20%22%7D%5D%7D%2C%22website%22%3A%22woopra.com%22%2C%22date_format%22%3A%22MM-dd-yyyy%22%2C%22start_day%22%3A%2202-12-2013%22%2C%22end_day%22%3A%2202-19-2013%22%2C%22limit%22%3A100%2C%22offset%22%3A0%7D

Using curl


curl https://www.woopra.com/rest/report \
  -H "X-Api-Version: 2.0" -H "X-Access-Id: ..." -H "X-Access-Secret: ..." -X POST -d \
  '
        {
        "website:"my-business.com",
        "report": {
            "group_by": [{
                "key": "day",
                "scope": "visits"
            }],
            "render": "'Rendered value for '+ group_by(0) ",
            "order_by": "Total Actions",
            "columns": [{
                "name": "Unique Visitors",
                "method": "count",
                "scope": "visitors",
                "render": " Math.round(cell('Unique Visitors')) "
            }]
        },
        date_format: "MM-dd-yyyy",
        start_day: "02-12-2013",
        end_day: "02-19-2013",
        limit: 100,
        offset: 0
    }
    }'

Need any help? Contact our Data Jedis