Building beautiful APIs with Foodgawker

Published on by Steve Mathias

Crowd Favorite has been working with the Gawkerverse on their Foodgawker site for several years. Along with its sibling sites (Craftgawker, Stylegawker, Dwellinggawker, and Weddinggawker), Foodgawker tremendous collections of curated content and highly-technical features to improve performance and ability to navigate content. As a part of this, the site features a fully-responsive design, and provides an API with an iOS and forthcoming Android app mobile app.

We work closely with Gawkerverse and a 3rd-party developer to support a robust API that provides secure access to data and site interactions, and also allows use within the native mobile applications.

Designing the API

As with any software project, our first step was deciding what the API should support, and what the data structures being sent back and forth should look like. This is a collaborative effort between our team and the API consumers (third-party mobile application developers).

While it's possible for us to make all interactions for the entire site available in the API, this isn't always the right answer. For example, with Gawkerverse there's no need for site administration functions to be available through the API. Keeping these on the website improves security by having fewer avenues into administration and reduces the risk of mistakes being made when trying to administer the site through a mobile device.

Considering Performance

When we’re working with APIs, we give equal or sometimes greater consideration to performance than we may when developing a server-side site. Particularly when working with a content management system (CMS) like WordPress, it may be unnecessarily heavy to load the entire framework into memory to run a simple query, or even a set of simple queries.

With Gawkerverse, while the API does share utilization of server-side software and databases, the interface is built outside the CMS to allow us to run very fast queries without interference from additional code. This allows the responses to be quick, light, and simpler to debug. This can be particularly important when we’re responding to a user who is bypassing the cache state for one reason or another.