### View All App Installations Source: https://github.com/microsoftdocs/xandr-docs/blob/main/xandr-docs/digital-platform-api/app-installation-service.md This example shows how to retrieve a list of all app installations using the App Installation service. Ensure you have the necessary cookies for authentication. ```bash $ curl -b cookies -c cookies 'https://api.appnexus.com/app-installation' { "response":{ "status":"OK", "count":1, "start_element":0, "num_elements":100, "app-installations":[ { "id":9, "plugin_id":47, "addendum":"This is test text to demonstrate the addendum functionality.", "subscriber_entity_type":"member", "subscriber_entity_id":3754, "accepted_permission":false, "installed_on":"2013-05-01 20:58:28", "installer_user_id":5447, "permissions":null, "has_payment_access":false "log_level_data_fee":5500, "subscriber_phone":"", "subscriber_email":"zivester@appnexus.com", "subscriber_name":"Zach Ivester" } ], "dbg_info":{ ... } } } ``` -------------------------------- ### Example Install Tracking Vendor Click URL Source: https://github.com/microsoftdocs/xandr-docs/blob/main/xandr-docs/invest/set-up-third-party-mobile-app-install-tracking.md This is an example of a click URL provided by a third-party install tracking vendor. Ensure the URL includes the `${SSP_DATA}` macro for click ID, which is crucial for server-side conversion calls. ```url https://wetrackinstalls.com/serve?action=click&publisher_id=[publisher_id]&site_id=[site_id]&offer_id=[offer_id] &odin=${DEVICE_ODIN}&open_udid=${DEVICE_OPENUDID}&ios_ifa=${DEVICE_APPLE_IDA}&ref_id=${SSP_DATA} ``` -------------------------------- ### Install Tracking Vendor Post-Back URL Example Source: https://github.com/microsoftdocs/xandr-docs/blob/main/xandr-docs/invest/set-up-third-party-mobile-app-install-tracking.md This is an example of a post-back URL that an install tracking vendor will use to report a conversion back to Microsoft Advertising. It includes placeholders for the app nexus conversion pixel ID and the click ID. ```url https://sspx-router.adnxs.com/sspx?id=[appnexus conversion pixel ID]&sspdata=[click id passed in ${SSP_DATA} on click] ``` -------------------------------- ### Initialize SDK with setup() Method Source: https://github.com/microsoftdocs/xandr-docs/blob/main/xandr-docs/ott-ctv/appletv-sdk-integration-guide.md Invoke the setup() method to initialize the SDK and request an ad. This method requires various parameters including content video player details and a delegate. ```swift // VMAP URL adController.setup(vmapURL:String, contentVideoPlayerViewController: AVPlayerViewController, contentVideoPlayer: AVPlayer, contentUIViewController: UIViewController, delegate: AdControllerProtocol) // Xandr Placement Set Id adController.setup(appNexusPsetId: Int, contentVideoPlayerViewController: AVPlayerViewController?, contentVideoPlayer: AVPlayer?, contentUIViewController: UIViewController?, delegate: AdControllerProtocol) // VAST URL adController.setup(vastUrl: String, contentVideoPlayerViewController: AVPlayerViewController?, contentVideoPlayer: AVPlayer?, contentUIViewController: UIViewController?,delegate: AdControllerProtocol) // Xandr VAST Placement ID adController.setup(appNexusMemberId: Int, appNexusPlacementId: Int, contentVideoPlayerViewController: AVPlayerViewController?, contentVideoPlayer: AVPlayer?, contentUIViewController: UIViewController?,delegate: AdControllerProtocol ``` -------------------------------- ### Example GET call with pagination parameters Source: https://github.com/microsoftdocs/xandr-docs/blob/main/xandr-docs/digital-platform-api/config-service.md Use `num_elements` to limit the number of responses and `start_element` to specify the starting index for paginated results. This example retrieves fifteen results starting from the tenth element. ```http GET https://api.appnexus.com/prebid/config?num_element=15&start_element=10 ``` -------------------------------- ### Get an existing mobile app instance example Source: https://github.com/microsoftdocs/xandr-docs/blob/main/xandr-docs/digital-platform-api/mobile-app-instance-service.md Example of how to retrieve an existing mobile app instance using a GET request. ```APIDOC ## GET /mobile-app-instance?id=108 ### Request Example ```json { "response": { "status": "OK", "count": 1, "start_element": 0, "num_elements": 100, "mobile-app-instance": { "id": 108, "last_modified": "2014-01-16 17:08:50", "created_on": "2014-01-16 17:08:50", "mobile_app_store": "", "instance-bundle": [ { "bundle_id": "3223423", "os_family_id": 3, "instance_priority_id": 1, "last_modified": "2014-01-23 20:42:57", "created_on": "2014-01-16 17:07:24" } ] } } } ``` ``` -------------------------------- ### SDK Initialization with setup() Source: https://github.com/microsoftdocs/xandr-docs/blob/main/xandr-docs/ott-ctv/appletv-sdk-integration-guide.md Invoke the `setup()` method to initialize the SDK and request an ad. This method supports various initialization methods including VMAP URL, Xandr placement set, VAST URL, and Xandr VAST placement. ```APIDOC ## Call setup() Invoke the `setup()` method to initialize the SDK and request an ad. When the SDK is ready, it will invoke the `adPlaybackControllerDidSetup` delegate method. Passing `contentVideoPlayerViewController`, `contentVideoPlayer,` and `contentUIViewController` allows the SDK to stop content video playback when it is time to show an ad break, as well as to show ad break marks on the content video timeline. > [!NOTE] > To initialize the Apple TV SDK, `contentVideoPlayer` needs to have video assets at the time when `setup()` is called. The following examples show how to invoke setup for VMAP, for a Xandr placement set, for a VAST URL, and for Xandr VAST placement. ```swift // VMAP URL adController.setup(vmapURL: String, contentVideoPlayerViewController: AVPlayerViewController, contentVideoPlayer: AVPlayer, contentUIViewController: UIViewController, delegate: AdControllerProtocol) // Xandr Placement Set Id adController.setup(appNexusPsetId: Int, contentVideoPlayerViewController: AVPlayerViewController?, contentVideoPlayer: AVPlayer?, contentUIViewController: UIViewController?, delegate: AdControllerProtocol) // VAST URL adController.setup(vastUrl: String, contentVideoPlayerViewController: AVPlayerViewController?, contentVideoPlayer: AVPlayer?, contentUIViewController: UIViewController?, delegate: AdControllerProtocol) // Xandr VAST Placement ID adController.setup(appNexusMemberId: Int, appNexusPlacementId: Int, contentVideoPlayerViewController: AVPlayerViewController?, contentVideoPlayer: AVPlayer?, contentUIViewController: UIViewController?, delegate: AdControllerProtocol) ``` ``` -------------------------------- ### GET Response Example for Bidder Profile Targeting Source: https://github.com/microsoftdocs/xandr-docs/blob/main/xandr-docs/bidders/hierarchy-and-ad-type-targeting-for-enhanced-bidder-profiles.md This is an example of a GET response showing the structure of bidder profile targeting, including ad types and their actions (include/exclude) and banner sizes. ```APIDOC ## GET Response ### Description Retrieves the current configuration of a bidder profile, including targeting settings for different ad types. ### Response Example ```json { "bidder_profile": { "id": 2, "bidder_id": 129, "code": "test_1", "description": "Test Profile", "targeting": { "ad_types": { "native": { "action": "exclude" }, "banner": { "action": "include", "sizes": [ { "width": 200, "height": 100 } ] }, "video": { "action": "exclude" }, "audio": { "action": "exclude" } } } } } ``` ### Notes The `sizes` object must be included within the `banner` ad type. No other banner sizes will pass through this profile. ``` -------------------------------- ### Full Page Setup with AST SDK Source: https://context7.com/microsoftdocs/xandr-docs/llms.txt This snippet demonstrates the complete setup for the AST SDK on a web page. It includes asynchronous loading of the library, setting global page options, defining two ad slots with different configurations, and initiating a consolidated ad request. Finally, it shows how to render each slot. ```html
``` -------------------------------- ### Example GET Request to Data Provider Source: https://github.com/microsoftdocs/xandr-docs/blob/main/xandr-docs/data-providers/real-time-integrations-contextual-data-providers.md This is an example of an HTTP GET request sent to a data provider to retrieve category information based on a URL. The 'url' parameter should contain the referrer URL. ```http GET /data_provider/get_categories?url=http://www.mikeonads.com/2009/10/18/rtb-serving-speed/ ``` -------------------------------- ### SDK Initialization Example Source: https://github.com/microsoftdocs/xandr-docs/blob/main/xandr-docs/mobile-sdk/initialize-sdk-settings-in-android.md Examples demonstrating the usage of the regular init() method and the overloaded init() method with optional parameters to control fetching of User Agent, AAID, WarmUpAdCall, and Prefetch WebView. ```APIDOC // Regular Init method SDKSettings.init(this, new SDKSettings.InitListener() { @Override public void onInitFinished() { // Initialisation finished } }); // Overloaded Init method with flexibility to enable / disable fetching of User Agent, AAID, WarmUpAdCall and Prefetch WebView SDKSettings.init(this, new SDKSettings.InitListener() { @Override public void onInitFinished() { // Initialisation finished } }, false, true, false, false); //Boolean values false/true are optional and as per usage ``` -------------------------------- ### Initialization Example Source: https://github.com/microsoftdocs/xandr-docs/blob/main/xandr-docs/mobile-sdk/android-sdk-initialization-v8-0.md An example demonstrating how to call the `XandrAd.init()` method with a member ID, context, and enabling pre-caching. ```APIDOC ## Initialization Example ### Description This example shows a typical implementation of the `XandrAd.init()` method within an Android application. ### Code Example ```java XandrAd.init(1234, mContext, true, new InitListener() { @Override public void onInitFinished(boolean success) { Toast.makeText(getActivity(), "Init Finished with " + success, Toast.LENGTH_SHORT).show(); } }); ``` ### Parameters in Example * **1234**: Represents the `memberId`. * **mContext**: Represents the `Context`. * **true**: Represents `preCacheContent` set to enabled. * **new InitListener()**: An anonymous inner class implementing the `InitListener` interface to handle the initialization completion callback. ``` -------------------------------- ### Install an App to a Client Source: https://github.com/microsoftdocs/xandr-docs/blob/main/xandr-docs/digital-platform-api/app-installation-service.md Use this endpoint to install an app to a client. You need to provide the `plugin_id`, `subscriber_entity_type`, and `subscriber_entity_id` in the request body. The response includes the newly created app installation details. ```json { "app-installation": { "plugin_id": "20", "subscriber_entity_type": "member", "subscriber_entity_id": "238" } } ``` ```bash $ curl -b cookies -c cookies -X POST -d @add-app-installation.json 's://api.appnexus.com/app-installation' | json-pp { "response":{ "status":"OK", "count":1, "id":18716, "start_element":0, "num_elements":100, "app-installation":{ "id":18716, "plugin_id":20, "addendum":null, "subscriber_entity_type":"member", "subscriber_entity_id":238, "accepted_permission":true, "installed_on":"2013-05-13 12:54:50", "installer_user_id":3052, "permissions":null, "has_payment_access":false "log_level_data_fee":null, "subscriber_phone":null, "subscriber_email":null, "subscriber_name":"Netseer - member 238" }, "dbg_info":{ ... } } } ``` -------------------------------- ### Example Usage Source: https://github.com/microsoftdocs/xandr-docs/blob/main/xandr-docs/mobile-sdk/background-threading-on-android.md Demonstrates how to enable background threading and initialize the Mobile SDK with a listener. ```APIDOC ## Example Usage ### Description This example shows how to enable the background threading feature and then initialize the Mobile SDK, providing a callback for when the initialization is complete. ### Code ```java // Enable the Background threading SDKSettings.enableBackgroundThreading(true); // Call init before requesting the Ad SDKSettings.init(context, new SDKSettings.InitListener() { @Override public void onInitFinished() { // Init has finished. Perform subsequent actions here. } } ); ``` ``` -------------------------------- ### Examples of Limiting GET Records Source: https://github.com/microsoftdocs/xandr-docs/blob/main/xandr-docs/bidders/api-semantics.md These examples demonstrate how to use the `start_element` and `num_elements` parameters to paginate results for different API services. ```bash segment/1?start_element=0&num_elements=1000 ``` ```bash member?start_element=0&num_elements=100 ``` ```bash creative/1?start_element=0&num_elements=200 ``` -------------------------------- ### Initialize SDK Settings with Optional Features Source: https://github.com/microsoftdocs/xandr-docs/blob/main/xandr-docs/mobile-sdk/initialize-sdk-settings-in-android.md This example demonstrates initializing the SDK with optional control over fetching User Agent, AAID, WarmUpAdCall, and prefetching WebView. Set boolean values to true or false as needed. ```java // Overloaded Init method with flexibility to enable / disable fetching of User Agent, AAID, WarmUpAdCall and Prefetch WebView SDKSettings.init(this, new SDKSettings.InitListener() { @Override public void onInitFinished() { // Initialisation finished } }, false, true, false, false); //Boolean values false/true are optional and as per usage ``` -------------------------------- ### Privileges Example Source: https://github.com/microsoftdocs/xandr-docs/blob/main/xandr-docs/digital-platform-api/app-installation-service.md This is an example of the structure for defining privileges within the permissions array for an app installation. It specifies the allowed API method and fields. ```json { "method": "get", "fields": null } ``` -------------------------------- ### Full Native Ad Integration Example Source: https://github.com/microsoftdocs/xandr-docs/blob/main/xandr-docs/mobile-sdk/show-native-ads-on-android.md This example demonstrates the complete workflow for loading and displaying native ads, including setting up the request, registering listeners for ad events and load status, and handling the ad response to populate views. ```java public class MyActivity extends Activity { Context activityContext; NativeAdResponse nativeAdResponse; LinearLayout container; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); activityContext = this; // Create a NativeAdRequest object NativeAdRequest adRequest = new NativeAdRequest(activityContext, "123456"); // Placement ID // Optionally set the renderer_id //adRequest.setRendererId(123); // Create a listener for ad events NativeAdEventListener adEventListener = new NativeAdEventListener() { @Override public void onAdWasClicked() { // Do something when the view is clicked } @Override public void onAdWillLeaveApplication() { // Do something when the ad is taking user away from current app } @Override public void onAdWasClicked(String clickUrl, String fallbackURL) { // Handle Click URL } }; // Whether to pre-load the native ad's icon and main image adRequest.shouldLoadIcon(true); adRequest.shouldLoadImage(true); adRequest.setListener(new NativeAdRequestListener() { @Override public void onAdLoaded(NativeAdResponse response) { nativeAdResponse = response; // Cover image ImageView imageView = new ImageView(activityContext); imageView.setImageBitmap(response.getImage()); // Icon image ImageView iconView = new ImageView(activityContext); iconView.setImageBitmap(response.getIcon()); // Title TextView title = new TextView(activityContext); title.setText(response.getTitle()); ``` -------------------------------- ### Batch Query HTTP Request Example Source: https://github.com/microsoftdocs/xandr-docs/blob/main/xandr-docs/yield-analytics-api/query-engine-service.md This is an example of an HTTP GET request for the batch query endpoint. It includes necessary headers and the request body. ```http GET /api/v1/rest/queryengine/batch/select%20consumption_date,%20sum(consumed)%20from%20OLPCS(network_products(),%0A'2010-07-01','2010-07-31')%20group%20by%20consumption_date%20order%20by%20consumption_date%20ascconsumptionFilter;%0AINVENTORY_CLASS=GUARANTEED;CONSUMPTION_TYPE=DIRECT;CONSUMPTION_TYPE=CONTAINED;PRIORITY%3E=5/select%20consumption_date,%20sum(consumed)%20from%20OLPCS(network_products(),'2010-07-01','2010-07-31')%20group%20by%20consumption_date%0A%20order%20by%20consumption_date%20asc HTTP/1.1%0AContent-Type: application/json;charset=UTF-8%0AHost: https://{{client_url}}/api/v1/rest%0AContent-Length: 55%0A%0A"{\"relativeDate\":\"2020-03-19\", \"title\":\"test\"}" ``` -------------------------------- ### Example: Set and Get AAID Usage Status Source: https://github.com/microsoftdocs/xandr-docs/blob/main/xandr-docs/mobile-sdk/set-aaid-usage-for-android.md This example demonstrates how to set the AAID usage preference and then retrieve its current status using the SDK settings. ```java // To Set the disableAAIDUsage SDKSettings.disableAAIDUsage(false); // To Get the disableAAIDUsage status SDKSettings.isAAIDUsageDisabled() ``` -------------------------------- ### City Targets Example Source: https://github.com/microsoftdocs/xandr-docs/blob/main/xandr-docs/bidders/legacy-bidder-profile-service.md Example JSON structure for defining city targeting within a bidder profile. Use the City Service to get city IDs. ```json { "profile": { "city_action": "include", "city_targets": [ { "id": 123, "name": "Queens", "region_name": "New York", "region_code": "NY", "country_code": "US", "country_name": "United States" } ] } } ``` -------------------------------- ### Example of a Complete Audio Placement Tag Source: https://github.com/microsoftdocs/xandr-docs/blob/main/xandr-docs/monetize/onboarding-audio-supply.md This example demonstrates a fully appended placement tag URL, including recommended parameters such as appid, idfa, ip, and loc. Appending these parameters is crucial for complying with platform policies and maximizing revenue opportunities. ```url https://ib.adnxs.com/ptv?id=10928372&appid=919288199&idfa=939828182082837&ip=100.10.102.19.&loc=-79.1209911,-10.9900099 ``` -------------------------------- ### Region Targets Example Source: https://github.com/microsoftdocs/xandr-docs/blob/main/xandr-docs/bidders/legacy-bidder-profile-service.md Example JSON structure for defining region targeting within a bidder profile. Use the Region Service to get region IDs. ```json { "profile": { "region_action": "include", "region_targets": [ { "id": 1, "name": "New York", "code": "NY", "country_name": "United States", "country_code": "US" } ] } } ``` -------------------------------- ### Seller Tag (AST) — Full Page Setup Source: https://context7.com/microsoftdocs/xandr-docs/llms.txt Example of a full page setup using the AST JavaScript SDK, demonstrating asynchronous loading, setting global page options, defining multiple ad slots, and loading/showing tags. ```APIDOC ## Seller Tag (AST) — Full Page Setup AST is a lightweight JavaScript SDK for web publishers. Load the library asynchronously from the Microsoft CDN, set global page options, define ad slots with `defineTag`, call `loadTags` to fire a single consolidated ad request, then render each slot in the body with `showTag`. ```html
``` ``` -------------------------------- ### Country Targets Example Source: https://github.com/microsoftdocs/xandr-docs/blob/main/xandr-docs/bidders/legacy-bidder-profile-service.md Example JSON structure for defining country targeting within a bidder profile. Use the Country Service to get country IDs. ```json { "profile": { "country_action": "include", "country_targets": [ { "id": 233, "name": "United States", "code": "US" } ] } } ``` -------------------------------- ### Swift Initialization Example Source: https://github.com/microsoftdocs/xandr-docs/blob/main/xandr-docs/mobile-sdk/ios-sdk-initialization-v8-0.md This example shows how to initialize the Xandr SDK within the `AppDelegate` in a Swift application. The initialization is performed before any other SDK methods are called. ```APIDOC ## Swift Initialization Example ### Description This example demonstrates how to initialize the Xandr SDK in a Swift application, typically within the `AppDelegate`'s `application(_:didFinishLaunchingWithOptions:)` method. ### Code ```swift class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { // ideally initialize Xandr SDK inside AppDelegate before calling any other SDK methods XandrAd.sharedInstance().initWithMemberID(1234, preCacheRequestObjects: true) { initComplete in if(initComplete){ print("XandrAd init Complete") } } return true } } ``` ``` -------------------------------- ### Example Video Tag with Query String Parameters Source: https://github.com/microsoftdocs/xandr-docs/blob/main/xandr-docs/monetize/target-video-attributes-via-query-string-parameters.md This example demonstrates how to construct a video tag URL with various query string parameters to target specific video attributes. Ensure correct parameter usage for different inventory types. ```url https://ib.adnxs.com/ptv?id=5523324&vmaxduration=30&vskippable=0&vplaybackmethod=5&vwidth=480&vcontext=1&vframeworks=1,2&schain= ``` -------------------------------- ### Get Bidder Profiles by Exchanges Source: https://github.com/microsoftdocs/xandr-docs/blob/main/xandr-docs/bidders/enhanced-bidder-profiles.md Example of a GET call response for bidder profiles targeting specific exchanges. This includes 'include' actions and 'excluded_members' and 'included_members'. ```json { "response": { "status": "OK", "count": 1, "start_element": 0, "num_elements": 100, "bidder_profiles": [{"id": 00, "bidder_id": 00, "code": null, "description": null, "targeting": { "exchanges": { "action": "include", "targets": [{"id": 1, "name": "Direct" }], "excluded_members": [{"id": 5, "billing_name": "Supply_source" }], "included_members": [{"id": 7, "billing_name": "Supply_source_two" }] } }, "last_activity": "2018-07-24 17:05:00", "created_on": "2018-07-20 18:16:19", "active": true }] } } ``` -------------------------------- ### Execute Statement HTTP Request Example Source: https://github.com/microsoftdocs/xandr-docs/blob/main/xandr-docs/yield-analytics-api/query-engine-service.md An example of an HTTP GET request to execute a single SQL statement. It includes required headers for authentication and content type. ```http GET /api/v1/rest/queryengine/execute/select%20*%20from%20list_aliases()%20where%20data_source_type%20=%20'ORDER_LINE'%0AHTTP/1.1%0AContent-Type: application/json%0AAccept: application/json%0Ausername: {{username}}%0Apassword: {{password}}%0AHost: https://{{client_url}}/api/v1/rest ``` -------------------------------- ### Enable AST Toolkit with URL Parameters Source: https://github.com/microsoftdocs/xandr-docs/blob/main/xandr-docs/seller-tag/ast-api-reference.md Append `?ast_toolkit=true&ast_dongle=ABC` to your page URL to enable the AST Toolkit. Replace `ABC` with your dongle. ```url http://www.site.com/page.html?ast_toolkit=true&ast_dongle=ABC ``` -------------------------------- ### Install Xandr Android SDK via Gradle Source: https://github.com/microsoftdocs/xandr-docs/blob/main/xandr-docs/mobile-sdk/android-sdk-integration-instructions.md Add this configuration to your app's build.gradle file to install the SDK. The `[9,10)` notation ensures you get the latest 9.x version. ```gradle repositories { mavenCentral() } dependencies { implementation 'com.appnexus.opensdk:appnexus-sdk:[9,10)' } ``` -------------------------------- ### Set Keywords Examples Source: https://github.com/microsoftdocs/xandr-docs/blob/main/xandr-docs/seller-tag/set-keywords.md Examples demonstrating how to set keywords for different ad slots. Keywords can be simple key-value pairs or arrays of values. The `options` object can be used to control how keywords are merged. ```javascript apntag.setKeywords('apn_ad_slot_1', { genre : ['rock','pop'] } ); ``` ```javascript apntag.setKeywords('apn_ad_slot_2', { 'hello' : 'world' } ); ``` ```javascript apntag.setKeywords('apn_ad_slot_3', { 'genre' : ['hiphop','classical'] }, { overrideKeyValue: true} ); ```