Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Python API Development Fundamentals

You're reading from   Python API Development Fundamentals Develop a full-stack web application with Python and Flask

Arrow left icon
Product type Paperback
Published in Nov 2019
Publisher
ISBN-13 9781838983994
Length 372 pages
Edition 1st Edition
Languages
Tools
Concepts
Arrow right icon
Authors (3):
Arrow left icon
Jack Chan Jack Chan
Author Profile Icon Jack Chan
Jack Chan
Jack Huang Jack Huang
Author Profile Icon Jack Huang
Jack Huang
Ray Chung Ray Chung
Author Profile Icon Ray Chung
Ray Chung
Arrow right icon
View More author details
Toc

Table of Contents (12) Chapters Close

Preface 1. Your First Step FREE CHAPTER 2. Starting to Build Our Project 3. Manipulating a Database with SQLAlchemy 4. Authentication Services and Security with JWT 5. Object Serialization with marshmallow 6. Email Confirmation 7. Working with Images 8. Pagination, Searching, and Ordering 9. Building More Features 10. Deployment Appendix

About the Book

Python is a flexible language that can be used for much more than just script development. By knowing how 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. Apart from all this, 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 the 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.

About the Authors

Jack Chan started programming at the age of 10. He was an active participant in worldwide programming contests at university. Since graduation, he has been working in the finance and IT industries for more than 10 years, building systems that analyze millions of transactions and positions to spot suspicious activity. He has leveraged the powerful analytical Python libraries to perform data analysis and performance optimization for a trading system that works at a microsecond level. He has an in-depth knowledge of the modern software development life cycle, which uses automated testing, continuous integration, and agile methodologies. Among all programming languages, he found Python to be the most expressive and powerful. He has created courses and taught students all over the world, using Python as the teaching language. Inspiring aspiring developers to take on the software engineering career path has always been Jack's goal.

Ray Chung is a developer and an instructor. He loves helping students learn to code and master software development. He is now self-employed and develops web applications, network applications, and chatbots using Python. The first program he sold was a network application that helped clients to configure, maintain and test thousands of multi-vendor network devices. He's experienced with big projects such as a Marathon's online registration system, rental car management systems, and more. He has worked extensively with Google App Engine, PostgreSQL, and advanced system architecture design. He has been a self-taught developer for many years and knows the most efficient ways to learn a new skill.

Jack Huang is a programmer with more than 7 years of experience in developing web applications in Python, Javascript, and .NET. He is skilled in web frameworks such as Flask, Django, and Vue, as well as in PostgreSQL, DynamoDB, MongoDB, RabbitMQ, Redis, Elasticsearch, RESTful API design, payment processing, system architecture design, database design, and Unix systems. He has written applications for an accessories shop platform, an ERP system, a divination web application, a podcast platform, a job search service, a blog system, a salon reservation system, an e-commerce service, and more. He also has experience in handling large amounts of data and optimizing payment processing. He is an expert web application developer who loves coding and is constantly following the newest technology.

Learning Objectives

By the end of this book, you will be able to:

  • 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

Audience

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.

Approach

This book takes the learning-by-doing approach to explain concepts to you. You'll build a real-life web application by implementing each concept that you learn in theory. This way, you'll reinforce your new skill.

Hardware Requirements

For the optimal experience, we recommend the following hardware configuration:

  • Processor: Intel Core i5 or equivalent
  • Memory: 4 GB RAM (8 GB preferred)
  • Storage: 35 GB available space

Software Requirements

We also recommend that you have the following software installed in advance:

  • OS: Windows 7 SP1 64-bit, Windows 8.1 64-bit or Windows 10 64-bit, Ubuntu Linux, or the latest version of OS X
  • Browser: Google Chrome/Mozilla Firefox (the latest version)
  • Python 3.4+ (the latest version is Python 3.8: from https://python.org)
  • Pycharm
  • Postman
  • Postgres Database

Conventions

Code words in the text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows:

"Next, we will work on the create_recipe function, which creates a recipe in memory. Use the /recipes route to trigger the create_recipe function and the methods = [POST] argument to specify that the route decorator will only respond to POST requests."

New terms and important words are shown in bold. Words that you see on screen, for example, in menus or dialog boxes, appear in the text like this: " Then, select Definition and set the password. Click Save".

A block of code is set as follows:

    if not recipe:
        return jsonify({'message': 'recipe not found'}), HTTPStatus.NOT_FOUND

Installation and Setup

Before we can do awesome things with data, we need to be prepared with the most productive environment. In this short section, we will see how to do that.

Installing Python

Go to https://www.python.org/downloads/ and follow the instructions specific to your platform.

Installing Pycharm Community Edition

Go to https://www.jetbrains.com/pycharm/download/ and follow the instructions specific to your platform.

Installing Postman

Go to https://www.getpostman.com/downloads/ and follow the instructions specific to your platform.

Installing Postgres Database

We are going to install Postgres on our local machine:

  1. Go to http://www.postgresql.org and click Download for the download page.
  2. Select macOS or Windows, depending on your operation system.
  3. Under Interactive installer by EnterpriseDB, download the latest version of the installer. The installer contains PostgreSQL as well as pgAdmin, which is a graphical tool for managing and developing your databases.
  4. Install Postgres version 11.4. Follow the on-screen instructions to install Postgres and set the password.
  5. Once you are done with the installation, you will be brought to pgAdmin. Please set up a pgAdmin password.

Additional Resources

The code bundle for this book is also hosted on GitHub at https://github.com/TrainingByPackt/Python-API-Development-Fundamentals. We also have other code bundles from our rich catalog of courses and videos available at https://github.com/PacktPublishing/. Check them out!

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image