Book Image

Web Development with MongoDB and NodeJS Second edition

Book Image

Web Development with MongoDB and NodeJS Second edition

Overview of this book

Table of Contents (19 chapters)
Web Development with MongoDB and NodeJS Second Edition
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
12
Popular Node.js Web Frameworks
Index

Chapter 8. Creating a RESTful API

Now that your application is complete and ready for the world to see, you could start thinking of ways to make it more popular. What if you wanted to allow external systems with access rights to your data in a way that they could mass produce inserts to your website without the need for users to visit the actual website? One example that comes to mind almost immediately is how users of another website, say www.facebook.com, can upload an image to Facebook and have it automatically uploaded to your website as well.

The only way to make a scenario like this possible is by providing an API to your data and the code that gives external developers access to a suite of tools that will allow them to perform actions without the need to interact with the actual web pages.

In this chapter, we will review the following topics:

  • Introducing RESTful APIs

  • Installing a few basic tools

  • Creating a basic API server and sample JSON data

  • Responding to GET requests

  • Updating data with...