Overview

The Adrapid REST API can be used to create image, video or html5 banners on demand.

Authentication

The Adrapid API uses authentication tokens to authenticate requests. You can view and rotate your token in your account details in the API section. This token is used in the Headers section of your HTTP requests:

curl -H "Authorization: Bearer [YOUR_TOKEN]"

Documentation

The full API docs are presented in swagger format and be accessed here.

Create a banner using the API

Before you create a banner you need to select the template you want to use a base for your banner. There is a list of pre-made templates ready to be used, you can access to them by navigating to library->templates.

When you have decided what template you want to use you need to copy its template id, it can be find in the top part of the sidebar.

Once you have your template id you are ready to create your first banner!

curl -H "Authorization: Bearer [YOUR_TOKEN]" -d '{"templateId": "[YOUR_TEMPLATE_ID]", "modes":{"png":true}}' -H "Content-Type: application/json" -X POST https://api.adrapid.com/banners

Response will be a banner object with no files.

{
    "id": "[BANNER_ID]",
    "status": "exporting",
    "files": null,
    ...
}

Getting the resulting banner file

Creation of a banner is an async operation, so you need to do polling to the banner endpoint until its status is ready, this can take between some milliseconds up to a few seconds depending on the amount of banners created in the petition and the current load of the system.

curl -H "Authorization: Bearer [YOUR_TOKEN]" https://api.adrapid.com/banners/[YOUR_BANNER_ID]

When the banner is ready the field files will be populated with all the formats requested. The direct url to download or preview the resulting banner file will be under url field inside files.

{
    "id": "[BANNER_ID]",
    "status": "ready",
    "files": [
        {
            "id": "[BANNER_FILE_ID]",
            "url": "https://banners.adrapid.com/57fa1ddf-67ca-4959-935d-d0a2ef961e4c/banners/ebd63334-64a6-4858-9ec6-82e146f0456b/base.png",
            "status": "ready",
            ...
        }
    ],
    ...
}

Overrides

We have created a banner in the format that we need, but that banner have the same content than the original template. In order to change the template content in the resulting banner we need to use the parameter overrides when we create the banner. With overrides we can change texts, images and and a lot of properties that can be set using css.

{
    ...
    "overrides": {
        "Text_item_1": {
            "text":"Hello world!",
            "css": {
              "color":"red"
            }
        },
        "logo": {
            "url": "[IMAGE_URL]"
        }
    }
    ...
}

Item name

To override an element we need the item name, the item name can be found in the editor->sidebar->item item names can be edited.

Modes

Banners can be created in different formats through the modes parameter, you can set multiple modes in one banner creation and you will get a different file for each mode.

html5

Will create an html5 banner with animations and optimised to be used on most ad servers out of the box.

png, webp, jpeg

Image formats supported.

video

Video format, video format support some extra properties to set the quality of the video. fps sets the fps of the resulting video and crf (Constant Rate Factor) sets the quality.

{
    ...
    "modes": {
        "video": {
            "fps":  15,
            "crf": 28
        }
    ...    
}

Last updated