API Resources for Python Developers

Python has a reputation as an easy language to get started with and begin building full-scale applications. In fact, it’s becoming the language of choice for introduction to programming classes at major universities. Python’s easy to use and large set of math and science libraries drive its usage among the scientific community.

Python, like Ruby, suffers from the Global Interpreter Lock (GIL). Since the Python interpreter can only be used by a single thread at any time, this makes it harder to scale CPU bound parallel workloads. With that said, it’s now being used heavily for experimentation of new algorithms by data scientists around the globe and for solving other data and analytics problems, partially due to the speed that can be achieved with it.

Background on Python

You can develop RESTful APIs without using frameworks, but using one of the popular web frameworks can make them a lot easier to build and scale.

Full-stack frameworks usually come with everything needed to build an entire application.Due to this, many tech decisions are made for you and application architecture is more standardized. A few examples of this include:

  • Django - Arguable the most popular framework in Python.
  • TurboGears - A full stack framework for rapid development. Create a database-driven, ready-to-extend application in minutes.

Non full-stack frameworks sometimes are better for developing APIs since they are less bloated and can be more easily customized. Especially for simple or lightweight applications, the simplicity of these frameworks can be beneficial. A few examples of such frameworks include:

  • Bottle - Bottle is a fast, simple and lightweight WSGI micro web-framework for a Python api. It is distributed as a single file module and has no dependencies other than the Python Standard Library.
  • Flask - Flask is a micro-framework for Python based on Werkzeug, Jinja 2 and good intentions. It’s BSD licensed!
  • Pyramid - Their tagline is “the startsSmall, finish big and stay finished Framework.” Pyramid is a Pylons Project, and is the successor to the Pylons web framework.

Tutorials and Resources for Creating RESTFul APIs

If you’re getting started with Python and it’s corresponding frameworks, these tutorials and resources will likely help. All of them are organized and maintained by major frameworks.

Much of these tutorials cover the standard and popular ways of building out RESTful web APIs. This includes sending request and responses in a JSON format and using the HTTP protocol to send and receive data from the API.

These resources are ideal for building APIs within a python application.

Tutorials for Creating GraphQL APIs

GraphQL is promoted as an alternative to RESTful API, you can read more about the background on GraphQL, and other types of APIs here.

Tutorials for Deployment

Useful Libraries

Pip is the default management system for Python packages. Many Python projects will require external dependencies to make certain things work or to make them easier. This is why using pip is an essential piece of using Python for building your applications. Using pip, you can add the packages listed below to augment your applications and development experience.

  • Documentation

  • Authentication

    • Authomatic - Simple but powerful framework agnostic API authentication and authorization client.
    • django-allauth - Authentication app for Django that “just works.”
    • django-oauth-toolkit - OAuth 2 goodies for Django.
    • Flask-OAuthlib - OAuth 1.0/a, 2.0 implementation of client and provider for Flask.
    • OAuthLib - A generic and thorough implementation of the OAuth request-signing logic.
    • python-oauth2 - A fully tested, abstract interface to creating OAuth clients and servers.
    • rauth - A Python library for OAuth 1.0/a, 2.0, and Ofly.
    • sanction - A dead simple OAuth2 client implementation.
    • jose - JavaScript Object Signing and Encryption draft implementation.
    • PyJWT - Implementation of the JSON Web Token draft 01.
    • python-jws - Implementation of JSON Web Signatures draft 02.
    • python-jwt - Module for generating and verifying JSON Web Tokens.
  • CORS

    • Flask Cors - A Flask extension for handling Cross Origin Resource Sharing (CORS), making cross-origin AJAX possible.
    • Django Cors - A Django application for handling the server headers required for Cross-Origin Resource Sharing (CORS).
  • JSON

    • python standard json - within the standard library
    • simplejson - simplejson is a simple, fast, complete, correct and extensible JSON encoder and decoder for Python 2.5+ and Python 3.3+. It is pure Python code with no dependencies, but includes an optional C extension for a serious speed boost.
    • ujson - UltraJSON is an ultra fast JSON encoder and decoder written in pure C with bindings for Python 2.5+ and 3.
    • python-rapidjson - An extremely fast C++ JSON parser and serialization library.
  • Databases Drivers

    • mysql-python - The MySQL database connector for Python.
    • mysqlclient - mysql-python fork supporting Python 3.
    • oursql - A better MySQL connector with support for native prepared statements and BLOBs.
    • PyMySQL - Pure Python MySQL driver compatible to mysql-python.
    • psycopg2 - The most popular PostgreSQL adapter for Python.
    • queries - A wrapper of the psycopg2 library for interacting with PostgreSQL.
    • txpostgres - Twisted based asynchronous driver for PostgreSQL.
    • apsw - Another Python SQLite wrapper.
    • dataset - Store Python dicts in a database - works with SQLite, MySQL, and PostgreSQL.
    • pymssql - A simple database interface to Microsoft SQL Server.
    • cassandra-python-driver - Python driver for Cassandra.
    • HappyBase - A developer-friendly library for Apache HBase.
    • Plyvel - A fast and feature-rich Python interface to LevelDB.
    • py2neo - Python wrapper client for Neo4j’s restful interface.
    • pycassa - Python Thrift driver for Cassandra.
    • PyMongo - The official Python client for MongoDB.
    • redis-py - The Redis Python Client.
    • telephus - Twisted based client for Cassandra.
    • txRedis - Twisted based client for Redis.
  • ORMs and Query Builders

    • Django Models - A part of Django.
    • SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper.
    • Orator - The Orator ORM provides a simple yet beautiful ActiveRecord implementation.
    • Peewee - A small, expressive ORM.
    • PonyORM - ORM that provides a generator-oriented interface to SQL.
    • pyDAL - A pure Python Database Abstraction Layer.
    • python-sql - Write SQL queries pythonically.
    • django-mongodb-engine - Django MongoDB Backend.
    • flywheel - Object mapper for Amazon DynamoDB.
    • hot-redis - Rich Python data types for Redis.
    • MongoEngine - A Python Object-Document-Mapper for working with MongoDB.
    • PynamoDB - A Pythonic interface for Amazon DynamoDB.
    • redisco - A Python Library for Simple Models and Containers Persisted in Redis.
    • butterdb - A Python ORM for Google Drive Spreadsheets.
    • dataset - A JSON-based database.
  • Testing

    • hypothesis - Hypothesis is an advanced Quickcheck style property based testing library.
    • mamba - The definitive testing tool for Python. Born under the banner of BDD.
    • nose - A nicer unit test for Python.
    • nose2 - The successor to nose, based on unittest2.
    • pytest - A mature full-featured Python testing tool.
    • Robot Framework - A generic test automation framework.
    • unittest - (Python standard library) Unit testing framework.
    • green - A clean, colorful test runner.
    • tox - Auto builds and tests distributions in multiple Python versions
    • httpretty - HTTP request mock tool for Python.
    • VCR.py - Record and replay HTTP interactions on your tests.
  • RESTful API

    • django-rest-framework - A powerful and flexible toolkit to build web APIs.
    • django-tastypie - Creating delicious APIs for Django apps.
    • eve - REST API framework powered by Flask, MongoDB and good intentions.
    • flask-api-utils - Taking care of API representation and authentication for Flask.
    • flask-api - Browsable Web APIs for Flask.
    • flask-restful - Quickly building REST APIs for Flask.
    • flask-restless - Generating RESTful APIs for database models defined with SQLAlchemy.
    • cornice - A RESTful framework for Pyramid.
    • falcon - A high-performance framework for building cloud APIs and web app backends.
    • hug - A Python3 framework for cleanly exposing APIs over HTTP and the Command Line with automatic documentation and validation.
    • restless - Framework agnostic REST framework based on lessons learned from Tastypie.
    • ripozo - Quickly creating REST/HATEOAS/Hypermedia APIs.
    • sandman - Automated REST APIs for existing database-driven systems.
    • apistar - A smart Web API framework, designed for Python 3.
    • REST layer - It helps you create a comprehensive, customizable, and secure REST (graph) API on top of pluggable backend storages with no boiler plate code so you can focus on your business logic.
  • GraphQL

    • Graphene-Python - A library/framework for building GraphQL APIs in Python easily, it’s main goal is to provide a simple but extendable API for making developers life easier.
    • graphene-django - Graphene Django integration
    • graphene-mango - Graphene MongoEngine integration.
    • Flask-GraphQL - Adds GraphQL support to your Flask application.
  • Utilities

    • Logbook - Logbook is a logging system for Python that replaces the standard library’s logging module.
    • eventlet - Asynchronous framework with WSGI support.
    • gevent - A coroutine-based Python networking library that uses greenlet.
    • multiprocessing - (Python standard library) Process-based “threading” interface.
    • Tomorrow - Magic decorator syntax for asynchronous code.
    • uvloop - Ultra fast implementation of asyncio event loop on top of libuv.
  • WebSockets

    • Websockets - Websockets is a library for developing WebSocket servers and clients in Python.
    • Ws4py - WebSocket package for Python.
    • Autobahn.ws - Open-source real-time framework for Web, Mobile & Internet of Things.
    • Tornado - Tornado is a Python web framework and asynchronous networking library, originally developed at FriendFeed.
Learn More About Moesif Build Better API Products With Moesif 14 day free trial. No credit card required. Learn More
Get User-Centric API Monitoring For Python Get User-Centric API Monitoring For Python

Get User-Centric API Monitoring For Python

Learn More