Skip to content

Statistics

Overview

The statistics API endpoint provides capability to retrieve near real time metrics and campaign budget cap-out time on the day of request.

Usage: To retrieve near-real time metrics and campaign cap-out insights

To understand details about ‘Request Header' or 'Authorization’, please refer to the Authorization Guide

Retrieve today’s near-real time metrics and campaign cap-out insights

Description: You can retrieve following metrics at advertiser/campaign level in near real-time for the time elapsed on the day of request: "Ad Spend", "Clicks", "Impressions", "Daily Remaining Budget", "Daily Out of budget Date Time"

End Point: /api/v1/stats

HTTP Method: GET

Note:

  • We recommend that you do not request near real-time statistics more than once per thirty minutes as the refreshed metrics may not reflect before that
  • The Ads exposed attribution is not part of near real-time metrics. Only the Ads performance metrics (Ad Spend, Clicks, Impressions) are provided in near real-time metrics.
  • Campaign budget type vs Daily remaining budget values:
    • For Campaigns that have only daily budget defined – then Daily Remaining Budget
    • For Campaigns that have both total and daily budget defined – then Daily Remaining Budget
    • For Campaigns that have only total budget defined – then Daily Remaining Budget is NULL

Query Parameters

Parameter Description Type Required Possible Values
advertiserId The ID of the advertiser for whom the ad group(s) should be returned Integer Y Unique numeric identifier
campaignId The ID of the campaign for which the performance metrics for today need to be retrieved Integer Y Unique numeric identifier

Sample Request

1
2
3
4
5
6
7
8
curl --location
'https://developer.api.us.stg.walmart.com/api-proxy/service/sp/api-sams/v1/api/v1/stats?advertiserId={advertiserId}&campaignId={campaignId}'
--header 'Authorization: Bearer ***********' 
--header 'wm_consumer.id: ****************' 
--header 'wm_sec.key_version: 2' 
--header 'wm_sec.auth_signature: *****************' 
--header 'wm_qos.correlation_id: 12345' 
--header 'wm_consumer.intimestamp: 1700221256000' 
OkHttpClient client = new OkHttpClient().newBuilder().build(); 
MediaType mediaType = MediaType.parse("text/plain"); 
RequestBody body = RequestBody.create(mediaType, ""); 
Request request = new Request.Builder() 
.url("https://developer.api.us.stg.walmart.com/api-proxy/service/sp/api-sams/v1/api/v1/stats?advertiserId={advertiserId}&campaignId={campaignId}") 
.method("GET", body) 
.addHeader("Authorization", "Bearer *********************")
.addHeader("wm_consumer.id", "***********************") 
.addHeader("wm_sec.key_version", "2") 
.addHeader("wm_sec.auth_signature", "***********************") 
.addHeader("wm_qos.correlation_id", "12345") 
.addHeader("wm_consumer.intimestamp", "1700221256000")
.build(); 
Response response = client.newCall(request).execute(); 
const axios = require('axios'); 
let config = { 
method: 'get', 
maxBodyLength: Infinity, 

url: 'https://developer.api.us.stg.walmart.com/api-proxy/service/sp/api-sams/v1/api/v1/stats?advertiserId={advertiserId}&campaignId={campaignId}', 

headers: {  
    'wm_consumer.id': '******************',  
    'wm_sec.key_version': '2',  
    'wm_sec.auth_signature': '******************',  
    'wm_qos.correlation_id': '12345',  
    'wm_consumer.intimestamp': '******************',  
    'Authorization': 'Bearer ****************' 
} 
}; 
axios.request(config) 
.then((response) => { 
console.log(JSON.stringify(response.data)); 
}) 
.catch((error) => { 
console.log(error); 
});  
import requests 

url = "https://developer.api.us.stg.walmart.com/api-proxy/service/sp/api-sams/v1/api/v1/stats?advertiserId={advertiserId}&campaignId={campaignId}" 
payload = {} 
headers = { 
    'Authorization': 'Bearer *********************************',
    'wm_consumer.id': '*********', 
    'wm_sec.key_version': '2', 
    'wm_sec.auth_signature': '***********', 
    'wm_qos.correlation_id': '12345', 
    'wm_consumer.intimestamp': '1706769796000'
} 
response = requests.request("GET", url, headers=headers, data=payload) 
print(response.text) 

Response

Element Description Type
campaignId Id of the advertising campaign whose ad spend is being retrieved Integer
todayAdSpend The amount of budget spent for current date Double
asOf Date and time for which the statistics (ad spend, impressions, clicks, daily remaining budget) is requested.
Note: The time zone is in PST and time stamp format is 24-hour format
String
adGroupId Id of the ad group
Note: Please ignore this parameter because we now provide stats at campaign level only, and eventually adGroupId will be removed from the response. For now, we will return ‘-1’ for this field.
Integer
dailyOutOfBudgetDatetime An indicator of whether a campaign has yet run out of its assigned daily budget or not. It returns following values:
  • Actual Date and Time: It returns the date and timestamp of when the campaign exhausted its daily budget and stopped serving ads
  • Empty: It returns a blank if the daily budget is not yet exhausted
Note:
  • Since it measures the spending of the daily budget, it only provides a date and time stamp for the current day. Also, since it refreshes every day, it will return a blank the subsequent day if the daily budget is not exhausted
  • The time zone is in PST and time stamp format is 24-hour format
String
dailyRemainingBudget The amount of daily budget left after today’s ad spend is consumed Double
todayImpressions Total number of impressions counted for today Integer
todayClicks Total number of clicks counted for today Integer

Sample Response 1

[
  {

    "campaignId": 500001,
    "todayAdSpend":777.0,
    "asOf":  "2021-07-29 18:44",
    "adGroupId": -1,
    "dailyOutOfBudgetDatetime": "2021-07-29 15:41",
    "dailyRemainingBudget": 17.2,
    "todayImpressions": 32421,
    "todayClicks": 14

  }
]

Sample Response 2

Following campaigns’ daily budget is 500 and todayAdSpend is also 500, so dailyRemainingBudget is 0:

[
    {
        "campaignId": 1694255,
        "adgroupId": -1,
        "todayAdSpend": 500.0,
        "asOf": "2022-04-12 20:14",
        "dailyOutOfBudgetDatetime": "2022-04-12 09:08",
        "dailyRemainingBudget": 0.0,
        "todayImpressions": 495627,
        "todayClicks": 1214
    }
]

Sample Response 3

Following campaign has Total Budget defined and Daily Budget is undefined (i.e., Campaign Budget Type: Total). Hence the the Daily Remaining Budget is NULL.

[
  { 
        "campaignId": 531760,
        "adgroupId": -1,
        "todayAdSpend": 52.0,
        "asOf": "2022-04-14 15:18",
        "dailyOutOfBudgetDatetime": null,
        "dailyRemainingBudget": null,
        "todayImpressions": 220,
        "todayClicks": 52
  }
]

HTTP Status Code

Status Code Description Possible Error Messages
400 Bad Request <advertiserId> not found in request
403 Forbidden
  • User not Authenticated
  • AdOps role does not access to any campaigns
  • You do not have access to view this advertiser
404 Not Found Advertiser not found
429 Too Many Requests <Exception Message>
500 Internal Server Error There was an error processing the request