Book description
Learn all that's needed to build a fully functional web application from scratch.
Key Features
- Delve deep into the principle behind RESTful API
- Learn how to build a scalable web application with the RESTful API architecture and Flask framework
- Know what are the exact tools and methodology to test your applications and how to use them
Book Description
Python is a flexible language that can be used for much more than just script development. By knowing the Python RESTful APIs work, you can build a powerful backend for web applications and mobile applications using Python.
You'll take your first steps by building a simple API and learning how the frontend web interface can communicate with the backend. You'll also learn how to serialize and deserialize objects using the marshmallow library. Then, you'll learn how to authenticate and authorize users using Flask-JWT. You'll also learn how to enhance your APIs by adding useful features, such as email, image upload, searching, and pagination. You'll wrap up the whole book by deploying your APIs to the cloud.
By the end of this book, you'll have the confidence and skill to leverage the power of RESTful APIs and Python to build efficient web applications.
What you will learn
- Understand the concept of a RESTful API
- Build a RESTful API using Flask and the Flask-Restful extension
- Manipulate a database using Flask-SQLAlchemy and Flask-Migrate
- Send out plaintext and HTML format emails using the Mailgun API
- Implement a pagination function using Flask-SQLAlchemy
- Use caching to improve API performance and efficiently obtain the latest information
- Deploy an application to Heroku and test it using Postman
Who this book is for
This book is ideal for aspiring software developers who have a basic-to-intermediate knowledge of Python programming and who want to develop web applications using Python. Knowledge of how web applications work will be beneficial but is not essential.
Table of contents
- Preface
- 1. Your First Step
-
2. Starting to Build Our Project
- Introduction
- What is Flask-RESTful?
- Virtual Environment
- Creating a Recipe Model
- Configuring Endpoints
-
Making HTTP Requests to the Flask API using curl and httpie
- Exercise 11: Testing the Endpoints Using curl and httpie
- Exercise 12: Testing the Auto-Incremented Recipe ID
- Exercise 13: Getting All the Recipes Back
- Exercise 14: Testing the Recipe Resources
- Exercise 15: Negative Testing
- Exercise 16: Modifying the Recipes
- Exercise 17: Getting Back Specific Recipes with a Certain ID
- Activity 3: Testing the APIs Using Postman
- Activity 4: Implementing the Delete Recipe Function
- Summary
- 3. Manipulating a Database with SQLAlchemy
- 4. Authentication Services and Security with JWT
-
5. Object Serialization with marshmallow
- Introduction
- Serialization versus Deserialization
- marshmallow
- A Simple Schema
- UserSchema Design
- RecipeSchema Design
-
The PATCH Method
- Exercise 37: Using the PATCH Method to Update the Recipe
- Searching for Authors and Unpublished Recipes
- Using the webargs Package to Parse the Request Arguments
- Exercise 38: Implementing Access Control on Recipes
- Exercise 39: Retrieving Recipes from a Specific Author
- Activity 8: Serializing the recipe Object Using marshmallow
- Summary
- 6. Email Confirmation
- 7. Working with Images
- 8. Pagination, Searching, and Ordering
-
9. Building More Features
- Introduction
- Caching
-
Flask-Caching
- Exercise 56: Implementing Caching Functionality Using Flask-Caching
- Exercise 57: Testing the Caching Function with Postman
- Clearing the Cache when Data Updates
- Activity 16: Getting Cache Data after Updating Recipe Details
- Exercise 58: Implementing Cache-Clearing Functionality
- Exercise 59: Verifying the Cache-Clearing Function
- API Rate Limiting
- Flask-Limiter
- Summary
-
10. Deployment
- Introduction
- Deployment
- Comparing SaaS, PaaS, and IaaS
- The Heroku Platform
- Configuration Handling in Smilecook
- Heroku Application
- Heroku Add-Ons
- Setting Up Environment Variables for the Heroku App
- Setting Up Variables in Postman
- Setting up the Front-end Interface to Work with the Smilecook API
- Summary
-
Appendix
- 1: Your First Step
- 2: Starting to Build Our Project
- 3: Manipulating a Database with SQLAlchemy
- 4: Authenticated Services and Security with JWTs
- 5: Validating APIs Using marshmallow
- 6: Email Confirmations
- 7: Working with Images
- 8: Pagination, Searching, and Ordering
- 9: Building More Features
- 10: Deployment
Product information
- Title: Python API Development Fundamentals
- Author(s):
- Release date: November 2019
- Publisher(s): Packt Publishing
- ISBN: 9781838983994
You might also like
video
Advanced REST APIs with Flask and Python
This Advanced REST API course takes your REST API development to a whole new level by …
book
Python Concurrency with asyncio
Learn how to speed up slow Python code with concurrent programming and the cutting-edge asyncio library. …
video
REST APIs with Flask and Python in 2024
A REST API is an application that accepts data from clients and returns data back. For …
video
Build REST APIs with Django REST Framework and Python
This course touches on each and every important topic through concept explanation, documentation, and implementation. The …