Skip to content

06 HTTP and REST

Jagdeep Singh edited this page May 21, 2019 · 1 revision

What is a REST API?

What is an API?

  • Application Program Interface
  • Contract provided by one piece of software to another
  • Structured request and response

What is REST?

  • Representational State Transfer
  • Architecture style for designing networking applications
  • Relies on a stateless, client-server protocol, almost always HTTP
  • Treats server object as resources that can be created or destroyed

HTTP Methods

  • GET: Retrieve data from a specified resource

  • POST: Submit data to be processed to a specificed resource

  • PUT: Update a specified resource

  • DELETE: Delete a specified resource

  • HEAD: Same as get but does not return a body

  • TRACE: Used to retrieve the hops that a request takes to round trip from the server. Each intermediate proxy or gateway would inject its IP or DNS name into the Via header field. This can be used for diagnostic purposes.

  • OPTIONS: Used to retrieve the server capabilities. On the client-side, it can be used to modify the request based on what the server can support. Returns the supported HTTP methods

  • PATCH: Update partial resources

Endpoints

The uri/url where api/service can be accessed by a client application

Authentication

Some API's require authentication to use their service. This could be free or paid.

OAuth

Gets access token and passed that along with each request to API.

Status Codes

1xx: Informational Messages

2xx: Successful

3xx: Redirection

4xx: Client Error

5xx: Server Error

Clone this wiki locally