Review: REST APIs with Django

Do you know what a REST API can do? You want to create them but don’t know where to start? Don’t worry: REST APIs with Django makes it easy.

Introduction
The book
Pros and cons
Conclusion

Introduction

“API First Design” is a reality. Instead of mixing front and back-end, API First Design claims that it is better to create the backend first and then fetch the information via API. Then, you create the front end for your website, mobile app or even both.

Doesn’t matter if you need two, three or five different frameworks for the same database: One API will do the job to connect the front-end application (web app, phone, another program, etc) with the database rather than a monolithic approach.

Like it or not, APIs are here to stay and they’ll be for a long long time. And what better solution than using Python for that?

Django rest framework logo
Django rest framework logo

You may know the author’s blog or his book Django for Beginners. If you know him, you know what to expect from his book REST APIs with Django. I’ve read his book and his blog, so I bought the book. And I wasn’t disappointed doing it.

REST APIs with Django introduces you in the word of Python-based API creation and does a great job. While the framework, Django Rest Framework (from now on, DRF) is a mature framework, I find there is a lack in resources that do anything more than the basic (even less than the official tutorial). That’s the reason why William wrote this book, and I can say that he does a great job here.

The book

The book starts explaining the importance of REST APIs, how do they work, terminology and how internet connection works, you start building APIs right from the second chapter, up to a total of three.

Personally, I love this hands-on approach, instead of hours and hours of tedious theory before creating the first ‘Hello World’. Instead, William makes us work while learning, splitting 50/50% theory and practice. A new function is added, after a small (but enough) explanation makes crystal clear where, why and what are we adding to the code and why that’s the best approach.

Step by step, we build 3 APIs, each one more complex than the other, from a simple Library API with one object, Books, to a production-ready Blog app with permissions, authentication, and documentation.

Django Rest Framework
Django Rest Framework

After doing a few tutorials on the subject, both text and video-based where different instructors had a different way to do things, everything makes sense now thanks to this book. What kind of authentication methods DRF has and which one should we use, how to set project and local permissions, what Views include DRF API and when to use one or another. Everything is explained with few lines and surprisingly clear.

If you want to learn about APIs, how to set up one the same day you open the very first page of the book and enjoy while you are doing it so it is not a chore, get this book.

Pros and cons

Pros

  • Easy to read. Time just will fly by.
  • Tones for information for the size of the book. I expected less than what I bought.
  • Theory and practise go hand to hand. You will learn by doing.
  • Touches some ‘scary’ places most writers don’t want to go, such as authentication or even documentation (!)

Cons

  • Despite having more information than I expected by the size of the book, the author left some aspects out. I miss things that I already know but beginners should know such as filtering, testing or throttling. You can spend a few minutes reading the API Guide to understand it but it would be nice if it was included.
  • If you’re more than a simple beginner, this book is not for you. It is addressed to beginners and beginners only.
  • Nothing else, really.

Conclusion

Even if the book seems short (a few hours read), this is a good entry for a beginner that wants to start creating Python-based APIs. It’s no-nonsense, straight to point with no filler. Just pure, well-structured information.

I can say that I am very happy with this purchase, now waiting for his third book, Django for Professionals

Click for more book reviews