Microservice APIs: With examples in Python
- Length: 425 pages
- Edition: 1
- Language: English
- Publisher: Manning
- Publication Date: 2022-08-30
- ISBN-10: 1617298417
- ISBN-13: 9781617298417
- Sales Rank: #6659046 (See Top 100 Books)
Tips, best practices, and handy Python features for designing better microservices architecture and streamlining API integrations.
Microservice APIs shares successful strategies and techniques for designing Microservices systems, with a particular emphasis on creating easy-to-consume APIs.
This practical guide focuses on implementation over philosophizing and has just enough theory to get you started. You’ll quickly go hands on designing the architecture for a microservices platform, produce standard specifications for REST and GraphQL APIs, and bake in authentication features to keep your APIs secure. Written in a framework-agnostic manner, its universal principles of API and microservices design can easily be applied to your favorite stack and toolset.
Microservice APIs MEAP V10 Copyright welcome brief contents Chapter 1: What are microservice web APIs? 1.1 What are microservices? 1.1.1 Defining microservices 1.1.2 What is a monolith? 1.1.3 Introducing the CoffeeMesh application 1.1.4 Microservices vs monoliths 1.1.5 Microservices today and how we got there 1.2 What are web APIs? 1.2.1 What is an API? 1.2.2 What is a web API? 1.3 Why does it make sense to deploy web APIs as microservices? 1.4 How Python makes it easier to develop microservice web APIs 1.5 Microservices-specific challenges 1.5.1 Effective service decomposition 1.5.2 Microservices integration tests 1.5.3 Handling service unavailability 1.5.4 Distributed transactions 1.5.5 Increased operational complexity 1.5.6 Infrastructure overhead 1.6 What you will learn in this book 1.7 Summary Chapter 2: A basic API implementation 2.1 Introducing the API specification 2.2 High-level architecture of the orders application 2.3 Implementing the API endpoints 2.4 Validating API requests payloads and marshalling responses 2.4.1 Defining validation schemas with Pydantic 2.4.2 Validating request payloads with Pydantic 2.4.3 Marshalling and validating response payloads with Pydantic 2.5 Adding an in-memory list of orders to the API 2.6 Summary Chapter 3: Designing and managing microservice APIs 3.1 Types of web APIs and protocols 3.1.1 Web APIs in RPC, XML-RPC, JSON-RPC 3.1.2 Web APIs in SOAP 3.1.3 Web APIs in gRPC 3.1.4 Web APIs in REST 3.1.5 Web APIs in GraphQL 3.2 Defining the application boundaries 3.2.1 Decomposition by business capability 3.2.2 Decomposition by subdomains 3.2.3 Service decomposition strategies for microservices: practical and organizational matters 3.3 What is API Governance and why should you care? 3.3.1 API documentation with specification standards 3.3.2 Managing API changes with versioning 3.3.3 Managing the lifecycle of your APIs 3.3.4 API security and authentication 3.4 Introducing Documentation-Driven Development 3.5 Summary Chapter 4: Designing a RESTful API 4.1 Design principles of REST APIs 4.1.1 What is Representational State Transfer? 4.1.2 Constraints of a RESTful application 4.1.3 Hypermedia as the Engine of Application State (HATEOAS) 4.1.4 The Richardson Maturity Model 4.2 Applying CRUD to the design of REST APIs 4.3 REST over HTTP: leveraging HTTP for meaningful API communication 4.1.5 Using HTTP verbs to create meaningful HTTP endpoints 4.1.6 Using HTTP Status Codes to create meaningful HTTP responses 4.1.7 Returning meaningful responses to the API clients 4.4 Request payloads and URL query parameters 4.1.8 Using payloads to send data to the server 4.1.9 Using URL query parameters to filter resources 4.5 Summary Chapter 5: Producing a REST API specification 5.1 JSON Schema for API documentation 5.2 Documenting the API with Swagger/OpenAPI 5.2.1 Anatomy of a Swagger/OpenAPI file 5.2.2 Documenting the API endpoints 5.2.3 Defining the authentication scheme of the API 5.3 Generating the API specification with code 5.4 Summary Chapter 6: Implementing REST APIs with Python 6.1 Overview of the Orders API 6.2 URL query parameters for the Orders API 6.3 Validating payloads with unknown fields 6.4 Automatically loading validation schemas from the specification 6.5 Overview of the kitchen API 6.6 FastAPI vs flask-smorest 6.7 Initializing the web application for the API 6.8 Implementing the API endpoints 6.9 Implementing payload validation models 6.10 Validating URL query parameters 6.11 Validating data before serializing the response 6.12 Implementing an in-memory list of schedules 6.13 Summary Chapter 7: Service implementation patterns for microservices 7.1 Hexagonal architectures for microservices 7.2 Setting up the environment and the project structure 7.3 Implementing the database models 7.4 Implementing the Repository Pattern for data access 7.4.1 The case for the Repository Pattern: what is it ,and why is it useful? 7.4.2 Implementing the Repository Pattern 7.5 Implementing the business layer 7.6 Implementing the Unit of Work pattern 7.7 Integrating the API layer and the service layer 7.8 Summary Chapter 8: Designing GraphQL APIs 8.1 Introducing GraphQL 8.2 Introducing the products API 8.3 Introducing GraphQL’s type system 8.3.1 Creating property definitions with scalars 8.3.2 Modeling resources with object types 8.3.3 Creating custom scalars 8.4 Representing collections of items with lists 8.5 Think graphs: building meaningful connections between object types 8.5.1 Connecting types through edge properties 8.5.2 Creating connections with through types 8.6 Combining different types through unions and interfaces 8.7 Constraining property values with enumerations 8.8 Defining queries to serve data from the API 8.9 Altering the state of the server with mutations 8.10 Summary Chapter 9: Consuming GraphQL APIs 9.1 Running a GraphQL mock server 9.2 Introducing GraphQL queries 9.2.1 Running simple queries 9.2.2 Running queries with parameters 9.2.3 Understanding query errors 9.3 Using fragments in queries 9.4 Running queries with input parameters 9.5 Navigating the API graph 9.6 Running multiple queries and query aliasing 9.6.1 Running multiple queries in the same request 9.6.2 Aliasing our queries 9.7 Running GraphQL mutations 9.8 Running parametrized queries and mutations 9.9 Demystifying GraphQL queries 9.10 Calling a GraphQL API with Python code 9.11 Summary Chapter 10: Implementing a GraphQL API 10.1 Analyzing the API requirements 10.2 Introducing the tech stack 10.3 Introducing Ariadne 10.4 Implementing the products API 10.4.1 Laying out the project structure 10.4.2 Creating an entry point for the GraphQL server 10.4.3 Implementing query resolvers 10.4.4 Implementing type resolvers 10.4.5 Handling query parameters 10.4.6 Implementing mutation resolvers 10.4.7 Building resolvers for custom scalar types 10.4.8 Implementing field resolvers 10.5 Summary Chapter 11: Authorizing access to your APIs 11.1 Setting up the environment for this chapter 11.2 Understanding authentication and authorization protocols 11.2.1 Understanding Open Authorization 11.2.2 Understanding OpenID Connect 11.3 Working with JSON Web Tokens 11.3.1 Understanding the JWT header 11.3.2 Understanding JWT claims 11.3.3 Producing JSON Web Tokens 11.3.4 Inspecting JSON Web Tokens 11.3.5 Validating JSON Web Tokens 11.4 Adding authorization to the API server 11.4.1 Creating an authorization module 11.4.2 Creating an authorization middleware 11.4.3 Adding CORS middleware 11.5 Authorizing resource access 11.5.1 Updating the database to link users and orders 11.5.2 Restricting user access to their own resources 11.6 Using an identity as a service provider 11.7 Using the implicit authorization flow 11.8 Using the client credentials flow 11.9 Summary
Donate to keep this site alive
1. Disable the AdBlock plugin. Otherwise, you may not get any links.
2. Solve the CAPTCHA.
3. Click download link.
4. Lead to download server to download.