If it's desired to limit the number of round trips to the server this can be achieved by attaching child entities using the fetch query parameter

Querying using the "fetch" query parameter

A standard query for e.g. a client looks like the following:

GET /api/v1/media_agency/86b35325-794c-11e4-8425-daf437376f87/client/86b35326-794c-11e4-8425-daf437376f87?apikey=secret123

The response will look like this:

{
  "id": "86b35326-794c-11e4-8425-daf437376f87",
  "name": "Example Client",
  "country": "SE"
}

By providing the fetch parameter to the query, it's possible to expand the result to also include e.g. the campaigns and their activities;

GET /api/v1/media_agency/86b35325-794c-11e4-8425-daf437376f87/client/86b35326-794c-11e4-8425-daf437376f87?fetch=campaigns.activities&apikey=secret123

The response will look like this (note that campaigns and activities are now attached to the response):

{
  "id": "86b35326-794c-11e4-8425-daf437376f87",
  "name": "Example Client",
  "country": "SE",
  "campaigns": [
    {
      "id": "0",
      "name": "default",
      "activities": [
        {
          "id": "86b35327-794c-11e4-8425-daf437376f87",
          "name": "Example Activity",
          "flightStart": "2014-04-20T22:00:00.000+0000",
          "flightStop": "2014-05-04T21:59:59.000+0000",
          "enabled": false
        },
        {
          "id": "86b35327-794c-11e4-8425-daf437376f88",
          "name": "Example Activity",
          "flightStart": "2014-08-31T22:00:00.000+0000",
          "flightStop": "2014-11-02T22:59:59.000+0000",
          "enabled": true
        },
        {
          "id": "86b35327-794c-11e4-8425-daf437376f89",
          "name": "Example Activity",
          "flightStart": "2014-05-15T22:00:00.000+0000",
          "flightStop": "2014-05-18T21:59:59.000+0000",
          "enabled": false
        }
      ]
    }
  ]
}

Examples

To get the complete object graph for a client, the request would look like the following (NOTE! this is probably not a good idea since the graph quickly grows large and can take a long time to load):

GET /api/v1/media_agency/86b35325-794c-11e4-8425-daf437376f87/client/86b35326-794c-11e4-8425-daf437376f87?fetch=campaigns.activities.biddingPlans.creatives&apikey=secret123

To get the complete object graph for an activity, the request would look like the following:

GET /api/v1/media_agency/86b35325-794c-11e4-8425-daf437376f87/client/86b35326-794c-11e4-8425