Talk Review: Building a RESTfull API Using Django
Pablo Vallejo
Software Engineer
Some days ago I gave a talk on how to create REST APIs using
Django Rest Framework, the idea was to share some of the things we've learned and our experiences developing API's.
I'd like to share some of the insights of the talk, the slides and other useful resources to get started developing API's.
What's an API
The first part of the talk was dedicated to explaining what an API is, and why it would be useful for us to create one.
Its use may vary, but most likely they're used to allow third party apps to use our content and embed it in widgets.
What is REST
REST is an API architecture that popular for being simple and flexible, it's also the way we communicate with APIs like Facebook, Twitter, Google Plus among others.
Django Rest Framework
This toolkit bootstraps
Django with Generic views, Serializers and an API Browseable Documentation, which make it easy for us to start our API.
Demo
After explaining all these topics, we showed a
Todo's Demo that uses TodoMVC in front-end and Django Rest Framework in back-end.
Questions
After we finished, it was time for questions, one of the featured questions was:
Q: Should we build our web apps as an API and have somethings in frontend to communicate with it like Backbone?
A: In general, we should have in our apps functions and shortcuts that allow us to get and return JSON data very easy and on the other hand, it is important to abstract functionalities that we are repeating in several parts.
So my recommendation in
Django is to have regular views, and start building our API as we add more and more AJAX calls, also, to have in mind that if we're repeating something more than two times, we should probably convert it to a function, or abstract it some way.
In this was, we won't have worry about building a whole API at the beginning of the project, but rather we'll be building it on the go.
Nevertheless, this technique may not work if you want to create a public API in which case it's better to architecture it before building it.
More Images
Generic Views Overview
Todo's App Demo
Networking And Food
Wrapping up
In conclusions, having an understanding of what an API is can come in handy and when developing and can prevent us from repeating ourselves. Following, there are some resources that might be useful to get you started with API design.
Written by Pablo Vallejo
Pablo develops and optimizes software solutions, focusing on functionality and user experience. His expertise in coding and problem-solving ensures the creation of efficient and reliable applications.