Unlike a classical RPC API, a REST API does not have a fixed set of end points.
Once your account is set up for API access as per the Introduction, you will be able to:
- Use this document to understand the general structure and patterns of the AdGear API end points
- Query the API, retrieving both entity data, as well as further API metadata useful for further queries
- Check the technical documentation for the input and output fields expected for each end point
Formats
Throughout the examples in this documentation we will be requesting output in the XML format, however you may choose JSON instead. The structure of both formats is exactly the same, both in terms of input and output fields.
The API's XML format has the following characteristics:
- Extensive schemas (XSD) for the input and output entities, used both as the basis of the API documentation as well as entity validation
- Wide adoption and client library availability
- No notion of data types without the aid of a third-party definition
The API's JSON format has the following characteristics:
- Lack of a standardized schema/documentation mechanism. When inputting and outputting JSON, please refer to the entity's XML documentation. The structure of the entities is exactly the same.
- Less widely used compared to XML
- Full set of native data types
Your preference for the input and output formats will be dictated by the language you're consuming your API with, and your level of comfort dealing with the XML and/or JSON facilities of said language. Your need for strict element validation may require XML, while a need for more dynamic data types and a more native mapping between your objects and the API's objects may lead you towards JSON.
Testing
You may find the UNIX "curl" command very helpful in interacting with the AdGear API before writing any code. An example of its usage is as follows:
To test an end point that requires POSTed data, you need to save the data in a file first (for example: input.xml), as well as indicate the content type of the input with the Content-Type HTTP header:
First Call
The first call to make, both when testing as well as from your code, is to retrieve the directory. This is done via an HTTP GET call to the base url directly, and it outputs something like so:
Inspecting the directory, you can see it's essentially a list of URLs that your API can follow at will. Each URL has a unique name that your code can look for when looping, as well as:
- The URL to contact if you wish to reach this end point
- The HTTP method required when contacting the URL
- The root element expected to be supplied by you when contacting the end point
- The root element expected to be returned by AdGear upon a successful response
Depending on the user accessing the API, the facilities available to them will be different than the ones shown above. It is important that you do not hard-code any URLs related to the AdGear API except the initial base URL.
Once you follow one of the URLs in the directory to invoke an end point, the returned element will, almost always, contain a child "_urls" element. This will contain a further set of URLs that you may consume further, and so on.
The finder
The AdGear API offers a finder end point (found in the directory under name "find_entity"). You may use this service if you know AdGear's internal type and AdGear's internal ID of an entity, and wish to jump directly to it without making a series of API calls going through its parents first.
To use the finder, call the finder end point supplying the query parameters "entity_type" and "entity_id". Example:
The output is another "directory" entity, containing the single "read" end point of the entity it found. Example:
Errors
If AdGear encounters an error with your request, the following will happen:
- The HTTP code will be in the error range of codes (4xx, 5xx)
- The root element returned will be the "errors" element, no matter what the expected (successful) root element was for the end point



