CityGrid Advertising APIs
AdGroupCriterion API
Introduction
The CityGrid AdGroupCriterion API is part of the Advertising API suite and allows users to add and remove categories (criteria) to and from ad groups. The ad group's place may already have associated categories; this API allows you to add additional category associations.
The terms category and criterion are used interchangeably in the Advertiser APIs. The categoryId
returned from the Category API should be passed as the adGroupCriterionId
to this API.
Contents
AdGroupCriterion Get Endpoint
The adgroupcriterion/get
endpoint retrieves information about the adgroup-category associations. The operation is invoked via HTTPS GET to:
|
Request Parameters
Parameter | Description | Required | Type | Default | Example | Limit |
---|---|---|---|---|---|---|
| The ad group whose associated categories are to be retrieved | Yes | Long | N/A |
| 10 digits |
| The category name | No | String | N/A | Hotels & Motels | 60 chars |
| The category ID (returned from the Category API) | No | Long | N/A |
| 12 digits |
| Page number of results to return (zero-based) | No | Integer | 0 | 5 | |
| Number of results per page | No | Integer | 10 | 25 |
If both keyword
and adgroupCriterionId
are specified, the keyword parameter will be ignored.
A keyword
search requires an exact match on the keyword parameter.
Request Header Values
Header | Description | Required | Valid Values |
---|---|---|---|
| Requested format for the response | Yes |
|
| Authentication token from the Authentication API | Yes | Valid token |
| The token received during registration | Yes | Valid token |
Request Examples
Example 1: Request associations for ad group 286 for the category Birds
curl -X GET \ -H 'Accept:application/json' \ -H 'authToken:mytoken' \ -H 'developerToken:myDevToken' \ 'https://api.citygrid.com/advertising/adgroupcriterion/v2/get?adGroupId=286&keyword=Birds'
Example 2: Request associations for category 3627 for ad group 286
curl -X GET \ -H 'Accept:application/json' \ -H 'authToken:mytoken' \ -H 'developerToken:myDevToken' \ 'https://api.citygrid.com/advertising/adgroupcriterion/v2/get?adGroupId=286&adGroupCriterionId=3627'
Example 3: Request up to 20 associations category 3627 for ad group 286
curl -X GET \ -H 'Accept:application/json' \ -H 'authToken:mytoken' \ -H 'developerToken:myDevToken' \ 'https://api.citygrid.com/advertising/adgroupcriterion/v2/get?adGroupId=286&adGroupCriterionId=3627&numberResults=20'
Response Properties
Property | Type | Description |
---|---|---|
| Response Metadata | |
| Integer | Total number of results |
| AdGroupCriterion list | List of results |
| AdGroupCriterion | Information about an AdGroup Criterion containing the following fields |
| Long | The ID of the ad group. |
| Long | The category ID (returned from the Category API) |
| String | The category name |
| {PRIMARY, SECONDARY} | Association type |
Response Examples
Example 1: A JSON success response
{ "totalNumEntries":3, "adGroupCriterions":[ { "type":"PRIMARY", "response":{ "field":"", "message":"Success", "code":"SUCCESS" }, "adGroupId":"30021512", "keyword":"Self Storage", "adGroupCriterionId":"6246" }, { "type":"PRIMARY", "response":{ "field":"", "message":"Success", "code":"SUCCESS" }, "adGroupId":"30021512", "keyword":"Household Storage", "adGroupCriterionId":"4242" }, { "type":"PRIMARY", "response":{ "field":"", "message":"Success", "code":"SUCCESS" }, "adGroupId":"30021512", "keyword":"Storage", "adGroupCriterionId":"4233" } ] }
Example 2: An XML success response
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <results> <totalNumEntries>1</totalNumEntries> <adGroupCriterions> <adGroupCriterion> <adGroupCriterionId>4295</adGroupCriterionId> <adGroupId>286</adGroupId> <keyword>Hotels & Motels</keyword> <response> <field/> <code>SUCCESS</code> <message>Success</message> </response> <type>PRIMARY</type> </adGroupCriterion> </adGroupCriterions> </results>
Example 3: A JSON missing parameter response
A request to api.citygrid.com/advertising/adgroupcriterion/v2/get?keyword=Birds
returns a response such as:
{ "totalNumEntries":1, "adGroupCriterions":[ { "type":"", "response":{ "field":"adGroupId", "message":"The parameter adGroupId is required but has not been supplied", "code":"PARAMETER_REQUIRED" }, "adGroupId":"", "keyword":"", "adGroupCriterionId":"" } ] }
Example 4: No criterion found (XML response)
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <results> <totalNumEntries>1</totalNumEntries> <adGroupCriterions> <adGroupCriterion> <adGroupCriterionId></adGroupCriterionId> <adGroupId></adGroupId> <keyword></keyword> <response> <code>ENTITY_NOT_FOUND</code> <field></field> <message>The AdGroupCriterion could not be found</message> </response> <type></type> </adGroupCriterion> </adGroupCriterions> </results>
AdGroupCriterion Mutate Endpoint
The adgroupcriterion/mutate
endpoint allows adgroup-category associations to be created and removed using the ADD and REMOVE operation keywords, respectively.
These operations are invoked via HTTPS POST to:
|
Input data such as request parameters are subject to field size limits.
Request Parameters
Every adgroupcriterion/mutate
request requires the following two parameters:
Property | Type | Description | Required |
---|---|---|---|
| {ADD, REMOVE} | Type of operation to perform (case sensitive) | Yes |
| AdGroupCriterion(s) | The association(s) to operate on | Yes |
The properties of an adgroupcriterion object in a request are:
Parameter | Description | Required | Type | Default | Example | Limit |
---|---|---|---|---|---|---|
| ID of the ad group | Yes | Long | N/A | 1722 | 10 digits |
| Association type, 1=PRIMARY, 2=SECONDARY | No | Integer | 1 | 1 | 1 digit |
| The category ID (returned from the Category API) | Yes | Long | N/A |
| 12 digits |
Request Header Values
Header | Description | Required | Valid Values | |
---|---|---|---|---|
| Media type of the request body, if any | Yes |
| |
| Requested format for the response | Yes |
| |
| Authentication token from the Authentication API | Yes | Valid token | |
| The token received during registration | Yes | Valid token |
|
Request Examples
Example 1: Add categories 883 and 1722 and remove category 14 from ad group 998
{ "mutateOperationListResource":[ { "operator":"ADD", "operand":{ "adGroupId":"998", "adGroupCriterionId":"883" } }, { "operator":"REMOVE", "operand":{ "adGroupId":"998", "adGroupCriterionId":"14" } }, { "operator":"ADD", "operand":{ "adGroupId":"998", "adGroupCriterionId":"1722" } } ] }
Example 2: Remove category 1722 from ad group 17 and add category 808 to ad group 5581
<mutateOperationListResource> <mutateOperation> <operand> <adGroupId>17</adGroupId> <adGroupCriterionId>1722</adGroupCriterionId> </operand> <operator>REMOVE</operator> </mutateOperation> <mutateOperation> <operand> <adGroupId>17</adGroupId> <adGroupCriterionId>808</adGroupCriterionId> </operand> <operator>ADD</operator> </mutateOperation> </mutateOperationListResource>
Response Properties
Property | Type | Description | Limit |
---|---|---|---|
| Response Metadata | 10 digits | |
| Integer | Total number of associations returned | 60 chars |
| AdGroupCriterion list | The returned associations | 12 digits |
| AdGroupCriterion | An association affected by the operation | |
| String | The category linked to the ad group | |
| {PRIMARY, SECONDARY} | Association type |
Response Examples
Example 1: A JSON success response
{ "totalNumEntries":1, "adGroupCriterions":[ { "type":"PRIMARY", "response":{ "field":"", "message":"Success", "code":"SUCCESS" }, "adGroupId":"286", "keyword":"Hotels & Motels", "adGroupCriterionId":"4295" } ] }
Example 2: An XML success response
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <results> <totalNumEntries>3</totalNumEntries> <adGroupCriterions> <adGroupCriterion> <adGroupCriterionId>1722</adGroupCriterionId> <adGroupId>2</adGroupId> <keyword>Restaurants</keyword> <response> <field/> <code>SUCCESS</code> <message>Success</message> </response> <type>PRIMARY</type> </adGroupCriterion> <adGroupCriterion> <adGroupCriterionId>1722</adGroupCriterionId> <adGroupId>2</adGroupId> <keyword>Restaurants</keyword> <response> <field/> <code>SUCCESS</code> <message>Success</message> </response> <type>PRIMARY</type> </adGroupCriterion> <adGroupCriterion> <adGroupCriterionId>1722</adGroupCriterionId> <adGroupId>2</adGroupId> <keyword>Restaurants</keyword> <response> <field/> <code>SUCCESS</code> <message>Success</message> </response> <type>SECONDARY</type> </adGroupCriterion> </adGroupCriterions> </results>
Example 3: A JSON error response (missing required parameter)
{ "totalNumEntries":1, "adGroupCriterions":[ { "type":"", "response":{ "field":"AdGroupId", "message":"The parameter, AdGroupId, is required but has not been supplied.", "code":"PARAMETER_REQUIRED" }, "adGroupId":"", "keyword":"", "adGroupCriterionId":"" } ] }
Example 4: An XML error response (missing required parameter)
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <results> <totalNumEntries>1</totalNumEntries> <adGroupCriterions> <adGroupCriterion> <adGroupCriterionId/> <adGroupId/> <keyword/> <response> <field>AdGroupId</field> <code>PARAMETER_REQUIRED</code> <message>The parameter adGroupId is required but has not been supplied</message> </response> <type/> </adGroupCriterion> </adGroupCriterions> </results>