Building RESTful Python Web Services
上QQ阅读APP看书,第一时间看更新

What this book covers

Chapter 1, Developing RESTful APIs with Django, in this chapter we will start working with Django and Django REST Framework, and we will create a RESTful Web API that performs CRUD (Create, Read, Update and Delete) operations on a simple SQLite database.

Chapter 2, Working with Class-Based Views and Hyperlinked APIs in Django, in this chapter we will expand the capabilities of the RESTful API that we started in the previous chapter. We will change the ORM settings to work with a more powerful PostgreSQL database and we will take advantage of advanced features included in Django REST Framework that allow us to reduce boilerplate code for complex APIs, such as class based views.

Chapter 3, Improving and Adding Authentication to an API with Django, in this chapter we will improve the RESTful API that we started in the previous chapter. We will add unique constraints to the model and update the database. We will make it easy to update single fields with the PATCH method and we will take advantage of pagination. We will start working with authentication, permissions and throttling.

Chapter 4, Throttling, Filtering, Testing and Deploying an API with Django, in this chapter we will take advantage of many features included in Django REST Framework to define throttling policies. We will use filtering, searching and ordering classes to make it easy to configure filters, search queries and desired order for the results in HTTP requests. We will use the browsable API feature to test these new features included in our API. We will write a first round of unit tests, measure test coverage and then write additional unit tests to improve test coverage. Finally, we will learn many considerations for deployment and scalability.

Chapter 5 , Developing RESTful APIs with Flask, in this chapter we will start working with Flask and its Flask-RESTful extension. We will create a RESTful Web API that performs CRUD operations on a simple list.

Chapter 6, Working with Models, SQLAlchemy, and Hyperlinked APIs in Flask, in this chapter we will expand the capabilities of the RESTful API that we started in the previous chapter. We will use SQLAlchemy as our ORM to work with a PostgreSQL database and we will take advantage of advanced features included in Flask and Flask-RESTful that will allow us to easily organize code for complex APIs, such as models and blueprints.

Chapter 7, Improving and Adding Authentication to an API with Flask, in this chapter we will improve the RESTful API in many ways. We will add user friendly error messages when resources aren’t unique. We will test how to update single or multiple fields with the PATCH method and we will create our own generic pagination class. Then, we will start working with authentication and permissions. We will added a user model and we will update the database. We will make many changes in the different pieces of code to achieve a specific security goal and we will take advantage of Flask-HTTPAuth and passlib to use HTTP authentication in our API.

Chapter 8, Testing and Deploying an API with Flask, in this chapter we will set up a testing environment. We will install nose2 to make it easy to discover and execute unit tests and we will create a new database to be used for testing. We will write a first round of unit tests, measure test coverage and then write additional unit tests to improve test coverage. Finally, we will learn many considerations for deployment and scalability.

Chapter 9,Developing RESTful APIs with Tornado, we will work with Tornado to create a RESTful Web API. We will design a RESTful API to interact with slow sensors and actuators. We will defined the requirements for our API and we will understand the tasks performed by each HTTP method. We will create the classes that represent a drone and write code to simulate slow I/O operations that are called for each HTTP request method. We will write classes that represent request handlers and process the different HTTP requests and configure the URL patterns to route URLs to request handlers and their methods.

Chapter 10, Working with Asynchronous Code, Testing, and Deploying an API with Tornado, in this chapter we will understand the difference between synchronous and asynchronous execution. We will create a new version of the RESTful API that takes advantage of the non-blocking features in Tornado combined with asynchronous execution. We will improve scalability for our existing API and we will make it possible to start executing other requests while waiting for the slow I/O operations with sensors and actuators. Then, we will set up a testing environment. We will install nose2 to make it easy to discover and execute unit tests. We will wrote a first round of unit tests, measure test coverage and then write additional unit tests to improve test coverage. We will create all the necessary tests to have a complete coverage of all the lines of code.