Motivation

This page showcases the ease of use of the n_2 API by providing a hands-on example of how to list all campaigns on supported platforms. It demos the use of the GET /campaigns endpoint to retrieve a list of all your campaigns of one or multiple platforms. It also shows how the a unified campaign model is used to represent campaigns across different platforms.

API Reference

The following is an introduction to the generic campaigns endpoint of n_2. It provides a high-level overview of the endpoint and its capabilities. Please refer to the API reference for campaigns for more detailed information.

Supported Platforms

The generic /campaigns endpoint is currently supported for the following platforms:

FacebookGoogleAdsActiveAgent

The following platforms are currently being integrated:

LinkedInPinterestTikTok

Interactive/campaigns

A first example

List all campaigns

The following example demonstrates how to list all campaigns on a given platform. Type in Facebook or GoogleAds to see a list of all your campaigns on the respective platform. Be aware that you need to have the respective platform connected. Check the Connections page to see which platforms are connected.

Try it

Enter a valid platform name such as 'Facebook'. Then click on 'Send' to make the API call.

fetch('https://api.n2api.io/campaigns?platforms=<Platform>', { method: 'GET' })

So... what are Campaigns?

Campaigns are the top level element of an advertising campaign. They serve as a container for groups of ads, the so called Ad Sets.

The Campaign Model

The Campaign model of n_2 describes an advertising campaign independently of the platform it is running on. A campaign from Facebook, Google Ads or any other platform is represented in the same way, using the same properties.

Properties

  • Name
    id
    Type
    string
    Description

    Unique identifier for the campaign. This is the platform specific id.

  • Name
    name
    Type
    string
    Description

    Name of the campaign.

  • Name
    platform
    Type
    string
    Description

    The platform the campaign is running on. See the Platforms section for a list of supported platforms.

  • Name
    status
    Type
    string
    Description

    Status of the campaign, such as Running, Active ot Paused. See the API reference for a full list of possible values.

  • Name
    channelKind
    Type
    string
    Description

    The kind of channel the campaign is running on, for example Social or Search. Refer to the API reference for a full list of possible values.

  • Name
    settings
    Type
    list<Setting>
    Description

    A list of settings for the campaign. Settings are used to represent the configuration of a campaign. Settings include things like runtimes, budgets and objectives. Refer to the API reference for more information.

  • Name
    adSets
    Type
    list<AdSet>
    Description

    A list of ad sets that belong to the campaign. See the Ad Set Model for more information.

  • Name
    targetings
    Type
    list<Targeting>
    Description

    A list of targetings that belong to the campaign. Refer to the API reference for more information.

Example Object

    {
      "id": "1234567",
      "adAccount": "876543",
      "name": "My Campaign",
      "status": "Active",
      "platform": "GoogleAds",
      "channelKind": "Search",
      "settings": [
        {
          "kind": "TotalBudget",
          "budget": 1000,
          "currency": "EUR",
        },
      ],
      "targetings": [
        {
          "targetingKind": "PostalCodeGeoTargeting",
          "zipcodes": [
            {
              "country": "US",
              "zipcode": "90210"
            }
          ]
        }
      ],
      "adSets": [
        {...}
      ],
    }

Interactive/campaigns

Possibilities

The unified campaigns endpoint along with the unified campaign model allows you to manage campaigns across different platforms in a consistent way.

Request campaigns for multiple platforms

You can request campaigns for multiple platforms at once by providing platforms query parameters for each platform.

n_2 will make optimized requests to the respective platforms and return a unified list of campaigns. Different platforms are queried in parallel to speed up the process.

Request

GET
/campaigns?platforms=Facebook&platforms=GoogleAds
curl -G https://api.n2api.io/campaigns \
  -H "Authorization: Bearer {token}" \
  -d platforms=Facebook \
  -d platforms=GoogleAds
Try it

Retrieve campaigns for Facebook and Google Ads in one call

fetch('https://api.n2api.io/campaigns?platforms=Facebook&platforms=GoogleAds', { method: 'GET' })

Filter campaigns by status

You can filter the campaigns by their status by providing the status query parameter.

Request

GET
/campaigns?platforms=Facebook&status=ACTIVE
curl -G https://api.n2api.io/campaigns \
  -H "Authorization: Bearer {token}" \
  -d platforms=Facebook \
  -d status=ACTIVE
Try it

Retrieve only active campaigns for Facebook

fetch('https://api.n2api.io/campaigns?platforms=Facebook&status=ACTIVE', { method: 'GET' })

Get campaigns for specific customer

Given you are an AdTech company, you can request campaigns for a specific customer by providing the customer query parameter.

Request

GET
/campaigns?customer=<customer_id>
curl -G https://api.n2api.io/campaigns \
  -H "Authorization: Bearer {token}" \
  -d customer=YOUR_CUSTOMER_ID
Try it

Enter a valid customer ID

fetch('https://api.n2api.io/campaigns?customer=<customer_id>', { method: 'GET' })

Was this page helpful?