Fork me on GitHub

API Creation

Creating and exposing APIs allows your web application to interact with other applications through machine-to-machine communication.

API creation frameworks

  • Django REST framework and Tastypie are the two most widely used API frameworks to use with Django. The edge currently goes to Django REST framework based on rough community sentiment.

  • Flask-RESTful and Flask API are popular libraries for exposing APIs from Flask web applications.

  • Restless is a lightweight API framework that aims to be framework agnostic. The general concept is that you can use the same API code for Django, Flask, Bottle, Pyramid or any other WSGI framework with minimal porting effort.

API creation resources

API creation learning checklist

Pick an API framework appropriate for your web framework. For Django I recommend Django REST framework and for Flask I recommend Flask-RESTful.

Begin by building out a simple use case for the API. Generally the use case will either involve data that users want in a machine-readable format or a backend for alternative clients such as an iOS or Android mobile app.

Add an authentication mechanism through OAuth or a token scheme.

Add rate limiting to the API if data usage volume could be a performance issue. Also add basic metrics so you can determine how often the API is being accessed and whether it is performing properly.

Provide ample documentation and a walkthrough for how the API can be accessed and used.

Figure out other use cases and expand based on what you learned with the initial API use case.

What's next after building an API for your web app?

What are application programming interfaces?

How do I integrate external APIs into my application?

How can I learn about web application security?

Where should I host static content such as JavaScript files?


对Full Stack Python这本书很感兴趣?想要一本包含代码、详细教程的完整版吗?那么用邮箱订阅吧。一旦完成了我就会发给你的,别担心除了订阅确认邮件,我是不会给你发乱七八糟的邮件的。