WrapAPI
  • Proxy
  • Docs
  • Pricing
  • Extension
  • Register or sign in

Case study: Getting a year of authenticated CJ ad network data with a single API call

Screenshot of CJ report with data the company wanted
Screenshot of CJ report with data the company wanted

As a part of the onboarding process, an ad-tech company needed to know how much their new signups earned on various ad networks. This helps them verify the customers' size and tailor their tutorial to features that would be most relevant.

They were able to use WrapAPI to create a single-API-call integration in just one hour.


CJ (formerly Commission Junction) is one of the world's largest affiliate advertising networks, and as a result, many of the ad-tech company's clients were also publishers with CJ. However, CJ's APIs didn't have the needed functionality: it only provides a single endpoint to get past commissions, which only returns up to 30 days of data at a time.

Using WrapAPI, the company's engineers created a single API call would authenticate a user, get account information, and retrieve commissions data that they then called from their application. This took less than an hour of engineering time, and boosted the number of their users who chose to connect their CJ account and their long-term retention/engagement.

Technical details

The composite endpoint that chains together all the endpoints (cj/login, cj/user, cj/performanceReport

The endpoint that the company ends up calling from their application code is the chained-together cj/performanceReportComposite endpoint. This API endpoint uses WrapAPI's composition functionality to glue together multiple requests, so that cookies and data from previous requests are passed on to later ones.

Behind the scenes, this endpoint 1) logs the user in, 2) gets their company ID, and then 3) gets the company's commissions (performance report).

Individual API endpoints

cj/login

(Click to view)
Backing URLhttps://members.cj.com/member/login/foundation/memberlogin.do
DescriptionSigns in for a publisher to CJ. It also returns the cookies in the form of a "state token" that represents the signed-in user. This state token can then be passed to any other WrapAPI API endpoint.
Sample input
{
  "username": "your@email.com",
  "password": "YOUR_PASSWORD_HERE"
}
Sample output
{
  "success": true,
  "outputScenario": "success",
  "data": {
    "publisherId": "3827697"
  },
  "stateToken": "eyJqYXIiOnsidmVyc2lvbiI6InRvdWdoLWNv...="
}

cj/user

(Click to view)
Backing URLhttps://members.cj.com/member/{{publisherId}}/user.json
DescriptionIn order to get a commissions report, we need to know the company ID, not just the user ID. This API call returns the company ID from a CJ API endpoint that requires authentication.
Sample input
{
  // Both from cj/login
  stateToken: 'eyJqYXIi...=',
  publisherId: '1234567'
}
Sample output
{
  "success": true,
  "outputScenario": "success",
  "data": {
    "data": {
      "userCompanyId": 1234568,
      "companyName": "Blah Inc.",
      ...
    }
  },
  "stateToken": "eyJqYXIiOnsidmVyc2lv...",
}

cj/performanceReport

(Click to view)
Backing URLhttps://members.cj.com/member/publisher/{{companyId}}/performanceReport/website.json
DescriptionGets the performance (commissions) report for a given company's websites. This is the data the company was looking for, and the other chained API endpoints just get the cookies and company ID needed for this.
Sample input
{
  "companyId": 1234568,
  "startDate": "2016-12-25",
  "endDate": "2017-01-25",
  "stateToken": "eyJqYXIiOnsidmVyc2lv...",
}
Sample output
{
  "success": true,
  "outputScenario": "success",
  "data": {
    "data": [
      {
        "period": "01/25/2017 00:00:00 UTC-0800",
        "website": "A Website",
        "websiteId": 1424397,
        "publisherCommission": "61.950",
        "saleAmount": "8462.290",
        ...
      }
    ]
  }
}

© Myrtlelime Inc.About usContact us   Terms of servicePrivacy policy