axiacore

Blog

Talk Review: Building a RESTfull API Using Django

Pablo Vallejo

Pablo Vallejo

Published

2 min read.


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.

Get updates from our CEO every other week about axiacore:

Learn about how we think:

How to use GenericForeignKey in Django

Sometimes, when the solution of the problem is associated with certain... uhm... difficulties, especially when you are still ...

Vera Mazhuga

Vera Mazhuga

Published Apr 10, 2014

Why you should use django-extensions

Working with Django is so cool, for example if you are dealing with repetitive and common tasks between projects you will be ...

Camilo Nova

Camilo Nova

Published Apr 07, 2014

Beginners Introduction To Sublime Text Code Snippets

One the things we as developers expend most of our time on is our text editor and the more comfortable we feel using it, the ...

Pablo Vallejo

Pablo Vallejo

Published Apr 04, 2014

We build software solutions from idea to market.

Let's Talk