Freigeben über


Native Layout service

This service allows the seller to specify the layout for a native creative. Once the layout is in our database, it can be retrieved using the renderer_id, and subsequently the layout_id.

REST API

HTTP Method Endpoint Description
POST https://api.appnexus.com/native-layout?member_id=456 Create a new layout.
PUT https://api.appnexus.com/native-layout?id=16&member_id=456 Edit an existing layout.
DELETE https://api.appnexus.com/native-layout?id=123&member_id=456 Delete a layout.

JSON fields

Field Type Description
data_assets array of objects Attributes of the native creative. See Data Assets below for more details.
image_assets array of objects Specify the required attributes of each individual image. See Image Assets for more details.
renderer object The renderer ID of the seller. Enter the id in this array. Example:
"renderer":{"id":1}

Image assets

The image_assets object includes the following fields:

Field Type Description
aspect_ratios array of objects Define the aspect ratios required for the icon image type. Required values are min_width, ratio_width and ratio_height. See Example.
image_type string The format of the image. Possible values include:
- main_image
- icon_image
required int Specify if the image is required.
Possible values: 1 - Required
sizes array of objects The size of the image. Specify both width and height. See Example.

Example for aspect_ratios

"aspect_ratios": [
{
"min_width" : 100,
"ratio_width": 1,
"ratio_height": 2
}
]

Example for sizes

Example:
"sizes": [
{
"width": 300,
"height": 500
}
]

Data assets

The data_assets object includes the following fields:

Field Type Description
data_type string The asset type for the native creative. Possible values:
- sponsored_by
- title
- description
- rating
- call_to_action
- display_url
- likes
- downloads
- price
- sale_price
- phone
- address
- additional_description
required int If required then the value should be 1.
maximum_length int The maximum length of the data asset.

Examples

Create a new native layout protocol

$ cat native_layout

{
    "native-layout": {
        "renderer": {
            "id": 1
        },
        "image_assets":[
            {
                "image_type": "main_image", //depends on api.native_asset_image_type.name
                "required": 1,
                "sizes": [
                    {
                        "width": 300,
                        "height": 500
                    }
                ]
            },
            {
                "image_type": "icon_image",
                "aspect_ratios": [
                    {
                        "minimum_width" : 100,
                        "ratio_width": 1,
                        "ratio_height": 2
                    }
                ]
            }
        ],
        "data_assets": [
            {
                "data_type": "title", //depends on api.native_asset_data_type.name
                "required": 1,
                "maximum_length": 100
            }
        ]
    }
} 

$ curl -b cookies -c cookies -X POST -d @native_layout 'https://api.appnexus.com/native-layout?member_id=456'

{
    "response": {
        "status": "OK",
        "start_element": 0,
        "num_elements": 100,
        "native-layout": {
            "id": 2,
            "member_id": 7,
            "renderer": {
                "id": 1
            },
            "data_assets": [
                {
                    "required": true,
                    "data_type": "title",
                    "maximum_length": 100
                }
            ],
            "image_assets": [
                {
                    "required": true,
                    "image_type": "main_image",
                    "sizes": [
                        {
                            "width": 300,
                            "height": 500
                        }
                    ],
                    "aspect_ratios": null
                },
                {
                    "required": false,
                    "image_type": "icon_image",
                    "sizes": null,
                    "aspect_ratios": [
                        {
                            "minimum_width": 100,
                            "ratio_width": 1,
                            "ratio_height": 2
                        }
                    ]
                }
            ]
        },
        ...
    }
}