Optimizing API calls for performance
Minimizing return fields
Each object returned by a REST call returns a number of fields describing the object. If your application does not need all fields in the response, then you can tell us what fields you want returned. The less fields returned, the faster the request is executed. This behavior is controlled by passing a comma-separated list into the fields parameter.
For instance, all events have an id, name and description (which may be empty). If these are all the fields you need, then add fields=id,name,description to your request. Note that this will also remove all venue information from the response, which is not desired in many cases, so add fields=id,name,description,venue to your request to retrieve just the id, name and descrition fields for all events and venues in the response.
Sample Request
- http://www.zvents.com/rest/event?id=154927&fields=id,name,description,venue&key=YOUR_API_KEY
Example Response
<rsp status="ok">
<stream_count>1</stream_count>
<event id="154927">
<name>Sunday Jazz Series at the Improv: Aaron Lington Quintet</name>
<description>Dr. Lington has quickly become a mainstay of the local jazz scene.</description>
</event>
<venue id="4553">
<name>Improv Comedy Club San Jose</name>
<description>It's where many of today's stars were born and continue to shine.</description>
</venue>
</rsp>
By default, the fields requested applied to all objects in the response. In the example above, there are two objects returned (an event and a venue) and the id, name and description fields were returned for both.
Assuming that you only need the description for the event in your application, the request can be optimized further by namespacing the requested fields. For instance, pass in field=id,name,event.description if you want the id and names fields returned for all objects, but you only need the description field returns for events.
Sample Request
- http://www.zvents.com/rest/event?id=154927&fields=id,name,event.description,venue&key=YOUR_API_KEY
Example Response
<rsp status="ok">
<stream_count>1</stream_count>
<event id="154927">
<name>Sunday Jazz Series at the Improv: Aaron Lington Quintet</name>
<description>Dr. Lington has quickly become a mainstay of the local jazz scene.</description>
</event>
<venue id="4553">
<name>Improv Comedy Club San Jose</name>
</venue>
</rsp>