API:API Network Stats(Legacy)

From HasOffers

Contents

Definition

Returns stats for a specified date range.

  • Formats: json, xml, csv
  • HTTP Method: GET
  • Authentication: This API requires user authentication. Your API key should be passed with the request to provide authentication.


Required Parameters

  • api_key The API Key used as authentication.
  • start_date The start date of the stats to return.
  • end_date The end date of the stats to return.


Optional Parameters

1. field[] - The field(s) to be returned. Must be passed in as an array. If none are provided, default fields will be returned.

List of Fields:

        1. Stat.impressions: The number of impressions generated.
        2. Stat.clicks: The number of clicks generated.
        2. Stat.gross_clicks: The number of total clicks generated.
        2. Stat.unique_clicks: The number of unique clicks generated.
        3. Stat.ctr: The ratio of clicks per impression.
        4. Stat.conversions: The number of conversions generated.
        5. Stat.ltr: The number of conversions per clicks.
        6. Stat.payout: The total payout you generated.
        7. Stat.cpm: The estimated revenue per 1000 impressions.
        7. Stat.cpc: The estimated revenue per click.
        7. Stat.cpa: The estimated revenue per conversion.
        8. Stat.revenue: The total revenue generated from advertisers.
        9. Stat.rpm: The average revenue per click.
        9. Stat.rpc: The average revenue per 1000 impressions.
        9. Stat.rpa: The average revenue per conversion.
        10. Stat.profit: Network's profit.

Examples:

Return one field, total conversions <pre>http://demo.hasoffers.com/admin/api/v1/stats.json?api_key=NEThSQ1Ah92G8f7JYqQuO5hnsULkia&start_date=2010-05-01&end_date=2010-05-28&field[]=Stat.conversions</pre>

Return multiple fields, total conversions and total payout <pre>http://demo.hasoffers.com/admin/api/v1/stats.json?api_key=NEThSQ1Ah92G8f7JYqQuO5hnsULkia&start_date=2010-05-01&end_date=2010-05-28&field[]=Stat.conversions&field[]=Stat.payout</pre>


2. group[] - The field(s) the returned stats should be grouped by. Should be passed in as an array.

Possible Groups:

        1. Stat.date The date.
        2. Stat.hour The hour of day.
        3. Stat.month The month.
        4. Stat.week The week.
        5. Stat.year The year.
        6. Affiliate.company Name of affiliate.
        7. Offer.name The name of the offer.
        8. OfferUrl.name The name of the Creative URL.
        9. Stat.source The source info.
       10. Country.name The name of the country.
       11. Browser.display_name The browser type.

Examples:

Group by one field, date <pre>http://demo.hasoffers.com/admin/api/v1/stats.json?api_key=NEThSQ1Ah92G8f7JYqQuO5hnsULkia&start_date=2010-05-01&end_date=2010-05-28&group[]=Stat.date</pre>

Group by multiple fields, date and offer <pre>http://demo.hasoffers.com/admin/api/v1/stats.json?api_key=NEThSQ1Ah92G8f7JYqQuO5hnsULkia&start_date=2010-05-01&end_date=2010-05-28&group[]=Stat.date&group[]=Offer.name</pre>


3. filter[] - The field(s) the returned stats should be filtered by. Should be passed in as an array with the field as the array key and the list of offer IDs seperated by a comma for the value. Possible fields:

        1. Stat.offer_id The offer.

Example:

Return stats only for Offer IDs 1 and 2 <pre>http://demo.hasoffers.com/admin/api/v1/stats.json?api_key=NEThSQ1Ah92G8f7JYqQuO5hnsULkia&start_date=2010-05-01&end_date=2010-05-28&filter[Stat.offer_id]=1,2</pre>


4. limit - The maximum number of results that should be returned. 0 is unlimited results. Default is 0.

Example: <pre>http://demo.hasoffers.com/admin/api/v1/stats.json?api_key=NEThSQ1Ah92G8f7JYqQuO5hnsULkia&start_date=2010-05-01&end_date=2010-05-28&limit=50</pre>


5. offset - The number of rows to offset from the beginning of the query. Default is 0. (offset requires limit to work well)

Example: <pre>http://demo.hasoffers.com/admin/api/v1/stats.json?api_key=NEThSQ1Ah92G8f7JYqQuO5hnsULkia&start_date=2010-05-01&end_date=2010-05-28&limit=10&offset=10</pre>


Example queries:

1. Stats for today, grouped by date and source:

Example: <pre>http://demo.hasoffers.com/admin/api/v1/stats.json?api_key=NEThSQ1Ah92G8f7JYqQuO5hnsULkia&group[]=Stat.date&group[]=Stat.source&start_date=2010-05-28&end_date=2010-05-28</pre>


2. Last seven days, grouped by date, showing clicks, leads, and payout:

Example: <pre>http://demo.hasoffers.com/admin/api/v1/stats.json?api_key=NEThSQ1Ah92G8f7JYqQuO5hnsULkia&start_date=2010-05-22&end_date=2010-05-28&group[]=Stat.date&field[]=Stat.clicks&field[]=Stat.conversions&field[]=Stat.payout</pre>


Response

JSON Examples:


1. Success

      {
          "success":true,
          "rows":2,
          "total_rows":"2",
          "data":[
          {
              "date":"2009-02-03",
              "impressions":"101",
              "clicks":"1",
              "conversions":"0",
              "cost":"$0.00",
              "cpc":"$0.00",
              "revenue":"$0.00",
              "rpc":"$0.00",
              "profit":"$0.00"
          },
          {
              "date":"2009-02-04",
              "clicks":"2",
              "conversions":"0",
              "cost":"$0.00",
              "cpc":"$0.00",
              "revenue":"$0.00",
              "rpc":"$0.00",
              "profit":"$0.00"
          }
          ]
      }


2. Failure

      {
          "success":false,
          "message":"We could not complete your request. Please make sure your request matches our documentation.",
          "code":0
      }
                 
      XML Examples:
         1. Success

            <rsp stat="ok">
                <stats type="array">
                    <stat type="struct">
                        <date>2009-02-03</date>
                        <clicks>1</clicks>
                        <conversions>0</conversions>
                        <cost>$0.00</cost>
                        <cpc>$0.00</cpc>
                        <revenue>$0.00</revenue>
                        <rpc>$0.00</rpc>
                        <profit>$0.00</profit>
                    </stat>
                    <stat type="struct">
                        <date>2009-02-04</date>
                        <clicks>2</clicks>
                        <conversions>0</conversions>
                        <cost>$0.00</cost>
                        <cpc>$0.00</cpc>
                        <revenue>$0.00</revenue>
                        <rpc>$0.00</rpc>
                        <profit>$0.00</profit>
                    </stat>
                </stats>
            </rsp>


2. Failure

            <rsp stat="fail">
                <error>
                    <message>We could not complete your request. Please make sure your request matches our documentation.</message>
                    <code>0</code>
                </error>
            </rsp>

 
Email this page to a friend or co-worker