📚

Common REST API Interview Questions

Jun 27, 2024

Common REST API Interview Questions

Introduction

  • Presenter: Kevin Way, Product Manager
  • Objective: To help prepare for REST API interview questions

Importance of REST APIs

  • Prominent in web services
  • Critical for software engineering interviews

Question 1: How are REST APIs Stateless?

  • Stateful: Server stores client data (e.g., usernames, passwords)
  • Stateless: Each client request must contain all necessary data
  • REST requires client state not to be stored on the server

Question 2: Explain the HTTP Methods

  • GET: Fetch a resource
  • POST: Create a resource
  • PUT: Update a resource
  • DELETE: Delete a resource
  • Correspond to CRUD operations (Create, Read, Update, Delete)

Question 3: Explain the HTTP Status Codes

  • 200 codes: Successful requests
  • 400 codes: Client-side errors
  • 500 codes: Server-side errors

Question 4: What is a URI?

  • URI: Uniform Resource Identifier
  • Types:
    • URN: Unique, persistent (e.g., ISBN)
    • URL: Web address, common in REST APIs

Question 5: Best Practices for Designing URIs

  • Standardize URIs
  • Use forward slashes for hierarchy
  • Use plural nouns for branches
  • Use hyphens for multiple words
  • Use lowercase
  • Avoid file extensions

Question 6: Differences Between REST and SOAP

  • REST: Architecture for web services
  • SOAP: Protocol for exchanging structured data
  • REST: Flexible standards, supports JSON, XML
  • SOAP: Strict standards, only supports XML
  • SOAP is more niche, used for regulated data

Question 7: Differences Between REST and AJAX

  • REST API: Handles HTTP requests, architecture
  • AJAX: Collection of web technologies for asynchronous requests
  • AJAX can be used to send RESTful requests
  • REST API cannot be replaced by AJAX

Question 8: Tools for Developing and Testing REST APIs

  • Language-dependent (e.g., Java, Node.js, Python)
  • Framework Example: Express for Node.js
  • Testing Tools: Postman for ensuring resource delivery

Question 9: Real-world Examples of REST APIs

  • Example: GET requests for HTML from a server
  • Used for database manipulation, file data retrieval, and hosting websites

Advantages and Disadvantages of REST APIs

  • Advantages:

    • Easy to learn
    • Supports multiple data formats (JSON, XML)
    • Statelessness simplifies client experience
    • Scalability due to client-server independence
  • Disadvantages:

    • Cannot maintain sessions due to statelessness
    • Lacks built-in security
    • Requires versioning for backward compatibility
    • URI consistency can be difficult for complex projects

Conclusion

  • Refresh on REST APIs
  • Common interview questions reviewed
  • Resources for further preparation: tryexponent.com