Restful API Tutorial

REST API Concepts:

           REST (REpresentational State Transfer) is an architectural style, and an approach to communications that is often used in the development of Web services.

What is Web Services:

           "Exposed to internet, that are programmatic access"

API:


          The APIs that are executed in single machine ie Each jar files executed inside a client application. In case of web-services, other developer call them code and write code to consume these services.
           For Example, The twitter.com it would produce output as HTML/CSS format, that are human readable web application. As same as api.twitter.com, that would produce data like xml/json format.


Web-service Characteristics: 

     1. Exchange of data, that are HTTP methods.
     2. Protocol - HTTP.
     3. It should access all resources from server only one URI
     4. It doesn't have session.
     5. It should be stateless.
     6. For performing CRUD operation, it should use HTTP verbs such as get,post,put,delete.
     7. It should return the result only in the form of JSON/XML light weight data.
     8. It doesn't have inbuilt encryption.


Resource Based URI:


  •  In weather web- application URL;
                                  /weatherapp.com.do?zipcode=12345
                     From the url it would do weather result for the particular zipcode  12345..
  •  In Resource Based URI Like;
                                 /weatherapp/zipcode/12345
                      From This URI, instead of the do the particular zipcode 12345, it is just lookup the under the zipcode 12345.

HTTP Methods:

  1. GET            - Provide read only access to resources.
  2. POST          - Used to create new resources.
  3. PUT            - Used to update new resources.
  4. DELETE    - Used to delete resources.
  5. OPTIONS  - Used to get supported operations on a resources.

For Creating Restful Web-services;


                                    Take it sample facebook as a example.

1. GET     /{profile_name}/{messages}/                       GET list of message           ReadONLY
2. GET     /{Profile_name}/{messages}/{message_id} Get the particular message ReadONLY
3. POST    /{Profile_name}/{messages}/{new_msg}    POST the new messages           N/A
4. PUT      /{Profile_name}/{messages/{message_id}  Update the particular msg  Idempotent
5. DEL     /{profile_name}/{messages/{message_id}   Delete the particular msg    Idempotent


            





            
           

Comments

Post a Comment

Popular posts from this blog

HDP 2.5 Add Port

Hue Installation