Chapter 10

First Module Conclusion

This first module focused on the basics required to build great web APIs. We’ve seen various ways to implement specific features and learned how web technologies were defined in RFCs which contain more than one would expect.

10.1. What Did You Learn?

It is now time for a retrospective to see what you remember from this first module. The following questions are there to ensure that you absorbed the most important notions from each chapter. If you don’t know the answer to one question, take another look through the chapter and the solution should reveal itself.

Chapter 2: Sinatra & Resources

  • What is Sinatra?
  • How do you create a Sinatra application?
  • What’s a route in Sinatra?
  • What is a resource?
  • What’s the difference between URL, URI and URN?

Chapter 3: curl

  • What is curl?
  • How do you write a simple POST request that creates a document with the data below and returns the entire list of HTTP headers and the body of the response? URL: http://example.com/documents.

{"name":"A Great Document", "author": "John Doe"}
  • What’s the option in curl to add a header field?
  • How are HTTP requests and responses formatted?
  • Why is there an empty line in every HTTP requests and responses?
  • What is the purpose of the header fields in an HTTP request/response?

Chapter 4: Media Types

  • What are the two main advantages of picking JSON over XML?
  • What’s wrong with using a query parameter (?format=json) to specify a media type?
  • What’s the difference between the Accept and Content-Type headers?
  • What is the quality factor used in the Accept header?
  • What’s the name of the process happening between client and server when using headers like Accept, Accept-Encoding or Accept-Language?

Chapter 5: HTTP Methods

  • What is an HTTP method?
  • Why can some methods be considered safe?
  • What is an idempotent method?
  • Can you remember what each one of the methods below should be used for?
    • GET
    • POST
    • PUT
    • PATCH
    • DELETE
  • Why is the OPTIONS method useful for JavaScript applications?

Chapter 6: HTTP Status Codes

  • What are HTTP status codes?
  • Why is it important to use these codes instead of just saying “something went wrong” with a 500 status code?
  • What are status codes starting with the number 3 reserved for?
  • Do you remember what each of the following status code stands for?
    • 200
    • 201
    • 204
    • 400
    • 404
    • 406
    • 409
    • 410
    • 415
    • 500

Chapter 7: Versioning

  • Why is versioning needed for web APIs?
  • Cite 3 ways to version a web API.
  • How can the media type be used for versioning?

Chapter 8: Caching

  • What are the only two hard things in Computer Science?
  • What is caching?
  • How does HTTP make it possible for clients to cache responses?
  • What are conditional HTTP requests?
  • How are caching keys generated for HTTP responses?

Chapter 9: Authentication

  • What is authentication?
  • What’s the difference between authentication and authorization?
  • What are the two built-in authentication schemes HTTP?

10.2. Conclusion

I hope this first module gave you all the basics you will need to build better web APIs. We will be re-using everything we’ve learned here in the second module, where we will build a complete Rails 5 API.