Book Image

RESTful Web API Design with Node.js

By : Valentin Bojinov
Book Image

RESTful Web API Design with Node.js

By: Valentin Bojinov

Overview of this book

<p>In this era of cloud computing, every data provisioning solution is built in a scalable and fail-safe way. Thus, when building RESTful services, the right choice of the underlying platform is vital. Node.js, with its asynchronous, event-driven architecture, is just the right choice to build RESTful APIs.</p> <p>This book will be your step-by-step guide in the RESTful world of Node.js. It starts with the implementation of a simple HTTP handler application and follows its evolution to a completed RESTful service solution, which introduces you to the best practices in developing RESTful services.</p>
Table of Contents (13 chapters)
RESTful Web API Design with Node.js
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Chapter 3. Building a Typical Web API

Now that you know what RESTful services are and you feel more comfortable with Node.js and its modules, it is time to start with your first RESTful web API implementation. It will be an application that provides mobile phone contacts, represented in a JSON format. The application will support different queries based on search criteria passed as GET parameters. For the purpose of this chapter, the contacts data will be read from a static JSON file.

Our first API will not support creating or updating contacts at this point, as is done in a real-world application—using file storage for data exposed to millions of users is definitely not an option. We will provide inserting and updating capabilities for the service later in the book, when we will have looked at modern NoSQL database solutions.

We will also cover the topic of content negotiation, a mechanism that allows consumers to specify the expected format of the data being queried. Then we will take a...