RESTful API Interview Questions

Signal Cat
3 min readMay 9, 2018

What RESTful stands for?

  • Representational state transfer

What’s that?

  • A web standards based architecture, use HTTP protocol for data communication.
  • REST server contains resource ←access by HTTP methods←REST client get the data
  • Resource: Text/HTML files, images, videos [represented:text, JSON, XML]
  • Resource is identified by URIs/Global IDs

What is web service?

  • a collection of open protocols and standards used for exchanging data between applications or systems.

What is URI? What’s the difference between URI and URL?

  • URIs are identifiers, and that can mean name, location, or both.
  • All URNs and URLs are URIs, but the opposite is not true.
  • The part that makes something a URL is the combination of the name and an access method, such as https://, or mailto:.
  • All these bits are URIs, so saying that is always technically accurate, but if you are discussing something that’s both a full URL and a URI (which all URLs are), it’s best to call it a “URL” because it’s more specific.
  • URI: Uniform Resource Identifier
scheme:[//[userinfo@]host[:port]]path[?query][#fragment]
Example

URL: Uniform Resource Locator

Example:http://www.example.com/index.html

protocol (http) hostname (www.example.com) file name (index.html)

URN: Uniform Resource Name is a URI use urn scheme

What makes URI a URL?

  • inclusion of the “access mechanism”, or “network location”, e.g. http:// or ftp://

Name commonly used HTTP methods?

  • GET — provide read only access to resource
  • POST— create new resource
  • DELETE — remove resource
  • PUT — update/create resource
  • OPTIONS — get supported operations on a resource

What are components of HTTP request?

1.Method 2.URI 3.HTTP version

4.Request header[meta data]

5.Body

What are components of HTTP response?

1.Status line [status/respond code + HTTP version]

2.Response header

3.Response body

What is statelessness?

The server doesn’t store any state about the client session.

REST statelessness means being free on application state

What is application state?

server-side date which servers store to identify incoming client requests, their previous interaction details and current context information

What is resource state?

is the current state of a resource on server at any point of time- and it has nothing to do with the iteration between client and server. It is the API response.

What advantages of statelessness?

Helps scale the APIs to millions of concurrent users by deploying it to multiple servers. Any server can handle any request because there is no session related dependency.

Makes REST APIs less complex-by removing all server side state synchronization logic

Easy to cache. A server side software can decide whether or not to cache the result of an HTTP request just by looking at that one request. Previous request don’t affect the cache ability of this one. It improves the performance, since no need to access to database every time.

What is caching in REST APIs?

Being cacheable is one of architectural constraints of REST.

  • GET requests should be cacheable by default. Usually browsers treat all GET requests cacheable.
  • POST requests are not cacheable by default but can be made cacheable by either an Expires header, or a Cache-Control header is added to the response.
  • PUT and DELTE are not cacheable at all

To be continue

--

--