With the API how can I periodically pull data to monitor campaigns?

There are a range of methods available to you to pull data related to campaigns and users to whom you have sent campaigns. Some common use cases are outlined below.

 The simplest method related to campaigns is the campaign info method. This is commonly used to check that campaign templates are live and validate content before executing them:

url = "https://external-api.xtremepush.com/api/external/info/campaign"
POST data = {"apptoken":"YOUR_APP_TOKEN", "id":"CAMPAIGN_ID" }

You can use it with select options if you only need to check certain params:

POST data = {"apptoken":"YOUR_APP_TOKEN","id":CAMPAIGN_ID,
"select": ["active", "messages", "push_text" ]}

Here's an example response for an active campaign template with iOS and Android push content:

{
    "code": 200, 
    "model": {
        "active": 1, 
        "messages": {
            "1": {
                "push_text": "Hi {{fname}}, {{amount}} has been debited from your account tap here if you did not approve this."
            }, 
            "2": {
                "push_text": "Hi {{fname}}, {{amount}} has been debited from your account tap here if you did not approve this."
            }, 
            "4": [], 
            "6": {
                "push_text": null
            }, 
            "7": [], 
            "8": []
        }
    }, 
    "success": true
}


If you want to periodically check on delivery of push notifications to individual devices for a campaign you can use the push to device list method. Here's an example that will give you any error messages for notifications that failed to deliver referenced by the xtremepush device id:

url = https://external-api.xtremepush.com/api/external/list/push-device
POST data = {"apptoken":"YOUR_APPTOKEN", "condition":[["campaign_id", "=" , YOUR_CAMPAIGN_ID], ["error", "=" , 1]], "order": ["id DESC", "create_time" ], "limit":50, "offset":0, "select": ["campaign_id","action_id", "message","create_time","device_id","error_message"]}

This will give you feedback if a message failed to deliver and can help you grab information like the application being uninstalled on a users device. This is the most common reason for an individual push failure example response with an Application Uninstall error below:

{ 
"code": 200, "data": [ { "action_id": 759147, "campaign_id": 245624, "create_time": 1464355910, "device_id": 459923, "error_message": "Application is Uninstalled" } ], "success": true
}

You can get info on delivered messages only by changing the error condition to  ["error", "=" , 0]  and removing the select would give all info for recent successful messages. If you want data on opened messages then you can use an ["open", "=" , 1] condition to filter for data in opened messages for example. 

data = {"apptoken":"YOUR_APP_TOKEN", 
"condition":[ ["campaign_id", "=" , YOUR_CAMPAIGN_ID],["open", "=" , 1] ],
"order": ["id DESC", "create_time" ], "limit":50, "offset":0,
"select": ["campaign_id","message","create_time", "open_time","device_id"]
}

 

Sample response below:

{
    "code": 200, 
    "data": [
        {
            "campaign_id": 245624, 
            "create_time": 1484579808, 
            "device_id": 17186391, 
            "open_time": 1484676736
        }, 
        {
            "campaign_id": 245624, 
            "create_time": 1475753780, 
            "device_id": 7322591, 
            "open_time": 1475753791
        }, 
        {
            "campaign_id": 245624, 
            "create_time": 1466168738, 
            "device_id": 4599293, 
            "open_time": 1466169534
        }, 
        {
            "campaign_id": 245624, 
            "create_time": 1465291708, 
            "device_id": 3941948, 
            "open_time": 1465307520
        }, 
    ], 
    "success": true
}

 

The device id in the above examples is the xtremepush device id if you need to get your external id for these messages you can query the device info or list methods. These are also useful for checking if devices are still addressable for push notifications. To check a specific xtremepush device id you can use:

url = "https://external-api.xtremepush.com/api/external/info/device"
data = {"apptoken":"EBm47bjIpEW8hjUyeP4Jkz0h0iRh_ZKm", "id": 3941948}

And you will get useful information on the device such as: if it is currently addressable for push notifications (active & addressable == 1 ), when the app was last opened on this device (open_time), other available ids like IDFA or Android Ad Id, device info etc. Sample Response below:

{
    "code": 200, 
    "model": {
        "active": 0, 
        "addressable": 1, 
        "app_version": "1.0.1", 
        "carrier_name": "vodafone IE", 
        "country": "IE", 
        "create_time": 1454931441, 
        "deactivate_time": 1473605010, 
        "device_adid": null, 
        "device_id": "61EC6701-6536-4F8E-8848-B3939A5F7585", 
        "device_idfa": "", 
        "device_idfv": "6FB021D5-4804-450F-B118-789AB56476B0", 
        "device_model": "iPhone7,2", 
        "device_model_name": "iPhone 6", 
        "device_os": "9.1", 
        "device_type": "iPhone", 
        "email": null, 
        "email_addressable": 0, 
        "email_subscription": 1, 
        "environment": "production", 
        "external_id": "AN_ID_FROM_YOUR_SYSTEM", 
        "geo": 0, 
        "id": 3941948,
        "language": "en", 
        "language_app": "", 
        "lib_version": "i-14062016", 
        "name": null, 
        "open_time": 1470131515, 
        "project_id": 785, 
        "subscription": 1, 
        "timezone": "Europe/Dublin", 
        "token": "947d5e6a093d7f87e00669912e6e6bf640271c05afc3d9c7e6863202297e10ab", 
        "type": "ios", 
        "user_agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Mobile/13B143"
    }, 
    "success": true
}

 

If you want to periodically check all devices to maintain data on addressable users then you can list devices with pagination and the fields you need:

url = "https://external-api.xtremepush.com/api/external/list/device"
data = {"apptoken":"YOUR_APPTOKEN",
"order": ["id DESC", "create_time" ], "limit":50, "offset":0,
"select": ["active","addressable","external_id", "id","open_time", "type"]

Sample Response Below:

{
    "code": 200, 
    "data": [
        {
            "active": 1, 
            "addressable": 0, 
            "external_id": "", 
            "id": 30227538, 
            "open_time": 1486133188, 
            "type": "ios"
        }, 
        {
            "active": 1, 
            "addressable": 0, 
            "external_id": "", 
            "id": 30226177, 
            "open_time": 1486132226, 
            "type": "ios"
        }, 
        {
            "active": 1, 
            "addressable": 1, 
            "external_id": "", 
            "id": 25243742, 
            "open_time": 1486317298, 
            "type": "ios"
        }, 
        {
            "active": 0, 
            "addressable": 1, 
            "external_id": null, 
            "id": 24112366, 
            "open_time": 1484150661, 
            "type": "android"
        }, 
        {
            "active": 1, 
            "addressable": 1, 
            "external_id": "", 
            "id": 24109675, 
            "open_time": 1481279835, 
            "type": "android"
        }
    ], 
    "success": true
}

 

Docs with more info on methods above:

 

 

Have more questions? Submit a request

0 Comments

Article is closed for comments.