Book Image

PhoneGap By Example

Book Image

PhoneGap By Example

Overview of this book

Table of Contents (17 chapters)
PhoneGap By Example
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Discovering the REST API


Very often, we need to get data from a publicly available Internet service, send it over the Internet, and delete or modify it. We can do it all with REST APIs. We can have different URIs for different business models. Let's imagine that we need to make our products available in an Internet shop. To retrieve information about a specific product, we will perform a GET request to the /product/1 address, where 1 is the ID of the product. We can delete a product by making the DELETE request to the same resource. Similarly, we can use the PUT request to update the product and the POST request to create the product. The GET, POST, PUT, and DELETE methods are very often called verbs. In brief, the REST API consists of:

  • HTTP methods:

    • GET: This is mainly used to retrieve data. It sends parameters in headers

    • PUT: This is used mainly to update a remote resource

    • DELETE: This is used to delete a resource

    • PATCH: This is used to update partial resources

    • POST: This submits data to...