O'Reilly logo

Lumen Programming Guide: Writing PHP Microservices, REST and Web Service APIs by Paul Redmond

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

© Paul Redmond 2016

Paul Redmond, Lumen Programming Guide, 10.1007/978-1-4842-2187-7_7

7. Leveling Up Responses

Paul Redmond

(1)Phoenix, Arizona, USA

Your API responses work fine, but at the moment they don’t scale very well. You need to make them more consistent across all endpoints by using conventions, as well as anticipate adding things like pagination to your response. If you’ve consumed a few APIs, you have probably noticed that response data formats vary between each API. Understanding each API format can be challenging enough, but add inconsistencies between endpoints within the same API and it can be a frustrating user experience.

Your current API response for all books looks something like Listing 7-1.

Listing 7-1. The GET /books JSON Response ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required