Presentation is loading. Please wait.

Presentation is loading. Please wait.

WEB API.

Similar presentations


Presentation on theme: "WEB API."— Presentation transcript:

1 WEB API

2 API

3 APPLICATION PROGRAMMING INTERFACE
API APPLICATION PROGRAMMING INTERFACE is a set of subroutine definitions, protocols, and tools for building application software. Purpose API make it easier for developers to use certain technologies in building applications.

4 API Documentation describing API: Implementations:
List of functions (endpoints) Calls (requests) Returns (responses) Implementations: Library or framework that can be imported to develop an application OS interfaces between an app and OS (POSIX, MacOS API, Windows API) Remote APIs on remote servers

5 WEB (Remote) APIs A server-side programmatic interface allows the client application to communicate with the server Based on one or more publicly exposed endpoints and a defined request–response message system. Uses the network to provide its services

6 NET Protocols IP TCP HTTP HTTPS
Address resolving and delivering packets Transmission Control between applications over IP Content container Level (application protocol) Security Level URL: Protocol + address + port + path on server (URI) _https://best.server.com:8080/API/endpoints/cars?brand=FERRARI&color=RED

7 Web Services Desktop Apps Mobile apps DB Other servers Web API Smart
zhttps://best.server.com:8080/API/endpoints/cars?brand=FERRARI&color=RED Desktop Apps INTERNET Endpoint Mobile apps WEB SERVER Requests Endpoint DB Endpoint Other servers Responses Endpoint Web API Endpoint Smart Teapot

8 SOAP vs REST Simple Object Access Protocol
REpresentational State Transfer is a protocol uses services interfaces Works on top of any communication Protocol, even asynchronously (TCP HTTP FTP SMTP) Only XML Security and authorization are part of the protocol Fully described and provide information to users (WSDL) is an architectural style URL based services HTTP/HTTPS only JSON , XML, TEXT, HTML Authorization and security must be implemented separately Easy to implement

9 Principles of REST RESOURCES expose easily understood directory structure URIs. REPRESENTATIONS transfer JSON or XML to represent data objects and attributes. MESSAGES use HTTP methods explicitly (for example, GET, POST, PUT, and DELETE). STATELESS interactions store no client context on the server between requests. The client holds session state.

10 HTTP methods GET - Retrieve information. GET requests must be safe and idempotent, meaning regardless of how many times it repeats with the same parameters, the results are the same POST - Request that the resource at the URI do something with the provided entity PUT - Store an entity at a URI. PUT can create a new entity or update an existing one. PATCH - Update only the specified fields of an entity at a URI DELETE - Request that a resource be removed; however, the resource does not have to be removed immediately. HEAD, OPTIONS, TRACE and CONNECT

11 CRUD - HTTP REQUESTS IN REST
DB operations GET POST PUT DELETE PATCH SELECT rows INSERT new row UPDATE row DELETE row UPDATE certain field

12 HTTP request status codes
indicate the result of the HTTP request. 1XX - informational 2XX – success (200 -OK, 201 – Created,204 - No Content) 3XX - redirection 4XX - client error (400-Bad Request, 401 Unauthorized, Forbidden, PNF) 5XX - server error

13 Request Structure A request line GET /images/logo.png HTTP/1.1
Request header fields Accept-Language: en Content-Type: text/html Cookie: <cookie-list> An empty line. An optional message body. JSON, TEXT, XML

14 Response Structure A status line which includes the status code and reason message HTTP/ OK Response header fields Content-Type: text/html Allow: GET, HEAD. An empty line. An optional message body JSON, TEXT, XML

15 _

16 -

17 _

18 _


Download ppt "WEB API."

Similar presentations


Ads by Google