REST Background

REST Background
Application Programming Interfaces (APIs) provide a communication-oriented cross-platform mechanism to connect computers inside your company, mobile phones, or partner computers to access your data by way of method or subroutine calls, regardless of language. An API is the definition of a method call. The API identifies what parameters you supply and what you get in return. More recently, APIs are presumed to happen over a network, rather than locally. Most often, if a network is involved, the API is of the REST variety.
The Hypertext Transfer Protocol (HTTP) and Representational State Transfer (REST) underlying technologies are core to connecting otherwise disconnected computers.
This article explains HTTP, APIs, REST, and how your API's URLs are constructed.
Hypertext is text with links and comprises the bulk of the content on the Internet. A protocol is a set of rules that frame interactions in telecommunications. When you submit a URL to your browser, you are making an HTTP GET request. This request is asking for a representation of the data at the URL location to be displayed on your own screen. The view of a web page that you see in your browser is the response to the GET request. This request is contained in the URL.
You can make other forms of request in HTTP, including the CRUD functions. All languages understand HTTP. An HTTP call is made up of the following elements:
  • Resource identifier. 
    Most commonly a URL, Uniform Resource Locator, or web address. The URL specifies the location of the desired resource.
  • Verb.
     For example, GET (retrieve data), PUT (alter an existing resource), POST (create a resource), and DELETE.
  • Request/Response. 
    The request is data sent to the server (the data for update). The response is data that is returned (the query result).
  • Header.
     Comprised of name-value pairs, commonly used for the auth token.
  • Arguments.
     The values the caller supplies, passed in the URL.
REST is an architectural pattern, a reusable solution to a common occurrence, that uses HTTP. REST is language-independent and builds upon the foundations laid by HTTP. REST focuses on resources. A resource is analogous to a table, having a type, data, and relationships to other resources. The resource is identified in the last node of the URL. REST encodes the request response in either XML or JavaScript Object Notation (JSON). JSON is an attractive choice. JSON is a kind of JavaScript data and Java Script is a commonly used languages. Better still, JSON is simple enough to be human readable and supports nesting. You can send a request that will return, in one batch, all the subsets of data required by your request, reducing the effects of latency.
Use the REST Lab in API Creator to get familiar with these concepts. Use it to experiment with your own REST server without first writing a program. The following image illustrates the anatomy of a REST call in the REST Lab: