Introduction to
RESTful Web
Services
Sanjay Nepali , Pradip Dhungana
Introduction
 What is a Web Service?
 - A method of communication between two electronic
devices over a network.
 - Allows for interoperability between different software
applications.
What is REST?
Definition
 - An architectural style for designing networked applications.
 - REST stands for Representational State Transfer.
Principles
 - Statelessness
 - Client-Server Architecture
 - Cacheable
 - Layered System
 - Code on Demand (optional)
 - Uniform Interface
Principles of REST
 Statelessness
 Client-Server Architecture
 Cacheable
REST Constraints
 Layered System
 Code on Demand (optional)
Uniform Interface
 Key Concepts
 Resource Identification
 Resource Manipulation:
 Self-descriptive Messages:
 Hypermedia as the Engine of
Application State (HATEOAS):
RESTful Web Services
 What are RESTful Web Services??
- Web services that adhere to the REST architectural
constraints.
 Key Features
 - Use of HTTP methods: GET, POST, PUT, DELETE.
 - Stateless operations.
 - Resource-based URL structure.
HTTP Methods in REST
 GET
 - Retrieve information from the server.
 - Idempotent and safe.
 POST
 - Submit data to be processed to a specified resource.
 - Can create a new resource or update an existing one.
 PUT
 - Update a specified resource with the request payload.
 - Idempotent.
 DELETE
RESTful Service Example
 Scenario: Managing a Bookstore
 Resource URL: /books
 Operations:
 - GET /books: Retrieve a list of books.
 - GET /books/{id}: Retrieve details of a specific book.
 - POST /books: Add a new book.
 - PUT /books/{id}: Update an existing book.
 - DELETE /books/{id}: Delete a specific book.
Best Practices
 Use Nouns for URIs
 Statelessness
 HTTP Status Codes
 Versioning
Advantages of REST
 Scalability
 Performance
 Flexibility
Tools and Technologies
 Tools for Developing RESTful Services
- Postman: For testing APIs.
- Spring boot, Express JS, Laravel, Django
 Technologies
- JSON and XML for data interchange.
Conclusion
- REST is a powerful architectural
style for web services.
- Provides a scalable, flexible, and
easy-to-use way to interact with web
services.

RESTful_Web_Services_Presentation (1).pptx

  • 1.
  • 2.
    Introduction  What isa Web Service?  - A method of communication between two electronic devices over a network.  - Allows for interoperability between different software applications.
  • 3.
    What is REST? Definition - An architectural style for designing networked applications.  - REST stands for Representational State Transfer. Principles  - Statelessness  - Client-Server Architecture  - Cacheable  - Layered System  - Code on Demand (optional)  - Uniform Interface
  • 4.
    Principles of REST Statelessness  Client-Server Architecture  Cacheable
  • 5.
    REST Constraints  LayeredSystem  Code on Demand (optional)
  • 6.
    Uniform Interface  KeyConcepts  Resource Identification  Resource Manipulation:  Self-descriptive Messages:  Hypermedia as the Engine of Application State (HATEOAS):
  • 7.
    RESTful Web Services What are RESTful Web Services?? - Web services that adhere to the REST architectural constraints.  Key Features  - Use of HTTP methods: GET, POST, PUT, DELETE.  - Stateless operations.  - Resource-based URL structure.
  • 9.
    HTTP Methods inREST  GET  - Retrieve information from the server.  - Idempotent and safe.  POST  - Submit data to be processed to a specified resource.  - Can create a new resource or update an existing one.  PUT  - Update a specified resource with the request payload.  - Idempotent.  DELETE
  • 10.
    RESTful Service Example Scenario: Managing a Bookstore  Resource URL: /books  Operations:  - GET /books: Retrieve a list of books.  - GET /books/{id}: Retrieve details of a specific book.  - POST /books: Add a new book.  - PUT /books/{id}: Update an existing book.  - DELETE /books/{id}: Delete a specific book.
  • 11.
    Best Practices  UseNouns for URIs  Statelessness  HTTP Status Codes  Versioning
  • 12.
    Advantages of REST Scalability  Performance  Flexibility
  • 14.
    Tools and Technologies Tools for Developing RESTful Services - Postman: For testing APIs. - Spring boot, Express JS, Laravel, Django  Technologies - JSON and XML for data interchange.
  • 15.
    Conclusion - REST isa powerful architectural style for web services. - Provides a scalable, flexible, and easy-to-use way to interact with web services.

Editor's Notes

  • #5 1. - Each request from client to server must contain all the information needed to understand and process the request. - No client context is stored on the server between requests. 2. Separation of concerns between client and server. - Improves scalability and simplifies the server components. 3. - Responses must explicitly define themselves as cacheable or non-cacheable. - Improves efficiency and performance.
  • #6 4. - Architecture composed of hierarchical layers. - Each layer cannot see beyond the immediate layer they are interacting with. 5. - Servers can temporarily extend or customize the functionality of a client by transferring executable code. - All API response can include code snippet if required. ( code snippet are templates that make it easier to enter repeating code patterns such as loops or conditional statements.)
  • #7 Uniform resource returns data in a standard format that is complete and fully reuseable. Resources are identified in requests using URIs. Representations should contain enough information to modify or delete the resource. Each message includes enough information to describe how to process the message. Clients interact with a network application entirely through hypermedia provided dynamically by application servers.
  • #8 1.
  • #12 - Resources should be identified by nouns, not verbs. 2. - Ensure that each request is self-contained. 3. - Use appropriate HTTP status codes to indicate the outcome of the operations (e.g., 200 OK, 201 Created, 404 Not Found, 500 Internal Server Error). 4. - Maintain API versioning to manage changes over time.
  • #13 1. - Lightweight and stateless nature makes it highly scalable. 2. - Caching can be leveraged to improve performance. 3. - Can handle multiple types of calls, return different data formats, and change structure with the right hypermedia links.
  • #15 For testing APIs. Framework for building RESTful services in Java, Node JS, PHP, Python.