Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Reverted back to previous geo details scope.

...

Code Block
languagejs
linenumberstrue
{
    "geoId": 5,
    "name": "Afghanistan",
    "countryCode": "AF",
    "dmaCode": 0,
    "geoLevel": "COUNTRY"
}‍‍‍‍‍‍‍‍‍‍‍‍‍

Filtering and sorting the response

The Geo API provides filtering and sorting parameters to narrow results when you are looking for a very specific or set of specific geo details. The response has the following header, along with the response body parameters.

...

Response Header Name

...

Type

...

Description

...

Response Body Parameter

...

Type

...

Description

...

countryCode

...

geoLevelId

...

Integer code for the geoLevel scope you defined in the request (country or city). May be one of the following:

  • 1 = Country
  • 3 = City

...

region

...

uri

...

The PubMatic internal URI that generated the response; for example, http://api-mgmt.sfo.pubmatic.local/v1/common/geo/275439. Note that this may not match the URI of your original API call.

...

Filters

The following table details the available Geo filter parameters:

...

Use to set the response scope to one of the following:

  • COUNTRY
  • CITY

...

Use to limit the search to a specific country code (ISO 2 characters); for example, filters=countryCode%20eq%20ES.

Sorting

In addition to filtering query results, you can also use the sort parameter in your request to sort the response on fields that make send for you; for example, sort=geoLevel,name. See the sample call with JSON response below.

Example call with filtered and sorted response

Code Block
languagejs
linenumberstrue
/*
*  CURL call that sorts the response with: sort=geoLevel,name. Note that <API_KEY> at the thend of the call represents your generated PubToken used to authenticate your call with PubMatic; see Getting Started with PubMatic APIs.
*/
curl 'https://api.pubmatic.com/v1/common/geo?filters=name%20like%20*celona*&sort=geoLevel,name&hideInvalid=true&pageNumber=1&pageSize=100&filters=geoLevel%20eq%203&filters=countryCode%20eq%20ES' -H 'Authorization:Bearer <API_KEY>' 

// JSON payload response
{
    "items": [
        {
            "city": "Barcelona",
            "country": "Spain",
            "countryCode": "ES",
            "geoLevel": "CITY",
            "geoLevelId": 3,
            "id": 275439,
            "name": "Barcelona",
            "region": "Barcelona",
            "regionCode": "B",
            "uri": "http://api-mgmt.sfo.pubmatic.local/v1/common/geo/275439"
        }
    ],
    "metaData": {
        "endIndex": 1,
        "startIndex": 1,
        "totalRecords": 1
    }
}

Error codes

Error codes specific to this API method.           

...