Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
APARNA MUDALIAR
C op yr i g h t 2 0 1 5 , S A S I n s t i t u t e I n c . A l l r i g h t s r es er v e d .
AGENDA TOPICS
C op yr i g h t 2 0 1 5 , S A S I n s t i t u t e I n c . A l l r i g h t s r es er v e d .
REST API HOW DOES IT WORK?
Full Forms
Representational State Transfer
Application Programming Interface
Client-server interaction
Exchange of data
Request data
Desktop
Smart Phone
Response data
Server
C op yr i g h t 2 0 1 5 , S A S I n s t i t u t e I n c . A l l r i g h t s r es er v e d .
REST API WHY IS REFERENCE DOCUMENTATION IMPORTANT?
C op yr i g h t 2 0 1 5 , S A S I n s t i t u t e I n c . A l l r i g h t s r es er v e d .
REFERENCE
STANDARD STEPS
DOCUMENTATION
Sample
Template
JSON
Anatomy
Terminology
C op yr i g h t 2 0 1 5 , S A S I n s t i t u t e I n c . A l l r i g h t s r es er v e d .
REST API TERMINOLOGY
HTTP Method
CRUD (Create-Retrieve-Update-Delete) methodology
POST-GET-PUT-DELETE methods
Base URL
URL of the server that receives the request and sends the response
Resources
Real-world domain objects on which the REST API acts upon
Query Parameters
Filter response data
Request URL
HTTP method + Base URL + Resource representation + Query
parameters
C op yr i g h t 2 0 1 5 , S A S I n s t i t u t e I n c . A l l r i g h t s r es er v e d .
REST API TERMINOLOGY
Header
Defines the data format of requests and responses
Access token
Request body
Request data sent to the server
Format JSON, XML, Media
Response body
Response data received from the server
Format JSON, XML, Media
Response codes
Indicate the success or failure of requests
Success codes
Failure codes
C op yr i g h t 2 0 1 5 , S A S I n s t i t u t e I n c . A l l r i g h t s r es er v e d .
REST API ANATOMY Example: Retrieving information of photos
GET https://flickr.api.com/user/{userId}/photo?dateUploaded=2015-04-20
height: 2234,
width: 1873
}
}
C op yr i g h t 2 0 1 5 , S A S I n s t i t u t e I n c . A l l r i g h t s r es er v e d .
JSON INTRODUCTION
C op yr i g h t 2 0 1 5 , S A S I n s t i t u t e I n c . A l l r i g h t s r es er v e d .
JSON DATA TYPES
Collections
Arrays
Values
List of values
Number (Positive, Negative,
Comma separated
Integers, Decimals)
Enclosed in [ ]
String (Enclosed in single or double
Objects
Key-value pairs quotes)
Key and value are colon (:) Boolean (true or false)
]
}
C op yr i g h t 2 0 1 5 , S A S I n s t i t u t e I n c . A l l r i g h t s r es er v e d .
XML XML VS. JSON
<students> {students:
<data> [
<name>Amy Underwood</name> {name: Amy Underwood,
<major>Physics</major> major: Physics,
<marks>39</marks> marks: 39,
<result>false</result> result: false},
{name: Kathy Wolfe,
</data>
major: Chemistry,
<data> marks: 86,
<name>Kathy Wolfe</name> result: true}
<major>Chemistry</major> ]
<marks>86</marks> }
<result>true</result>
</data>
</students>
C op yr i g h t 2 0 1 5 , S A S I n s t i t u t e I n c . A l l r i g h t s r es er v e d .
EXAMPLE INPUTS FROM THE DEVELOPER FOR THE REST API
Adds a comment to a photo as the currently authenticated
user
Uses the HTTP POST method
URL is https://flickr.api.com/user/<userID>/photo/comment
REST API for Header contains three elements: Bearer, Content-Type, and
Accept (For more information, see the sample Header.)
Adding a Comment
Request body contains two mandatory elements: photoID and
to a Photo
commentText. (For more information, see the sample request)
Response contains three elements for the comment object:
id, authorName, and dateCreated. Additional status element.
(For more information, see the sample response.
Error messages: 400: Blank comment, 401: User not logged
in, 404: Photo not found
C op yr i g h t 2 0 1 5 , S A S I n s t i t u t e I n c . A l l r i g h t s r es er v e d .
EXAMPLE ADDING A COMMENT TO A PHOTO
C op yr i g h t 2 0 1 5 , S A S I n s t i t u t e I n c . A l l r i g h t s r es er v e d .
TABLE
ADVANTAGES AND DISADVANTAGES
DOCUMENTATION
Disadvantages
Advantages
Formatting is difficult if nesting is too
Simplistic approach
deep
No special tools required
Static documentation
Way ahead:
Explore tools for interactive documentation
Swagger (Example: http://petstore.swagger.io/)
C op yr i g h t 2 0 1 5 , S A S I n s t i t u t e I n c . A l l r i g h t s r es er v e d .
REFERENCES AND
REFERENCES USEFUL RESOURCES
ACKNOWLEDGEMENTS
C op yr i g h t 2 0 1 5 , S A S I n s t i t u t e I n c . A l l r i g h t s r es er v e d .
THANK YOU!
C op yr i g h t 2 0 1 5 , S A S I n s t i t u t e I n c . A l l r i g h t s r es er v e d .