
12 Designing a secure API
This chapter covers
- Exposing only the necessary data and operations
- Ensuring that implemented operations behave according to context
- Ensuring data integrity
- Preventing protocol or infrastructure-based data leaks
- Limiting access with security scopes
- Erroring securely
A versatile API that does the job and is user-friendly and interoperable is nice, but it’s worth nothing if it’s not secure. As APIs have grown in popularity, the number of API attacks has increased exponentially, making APIs the primary hacking attack vector in 2022. In 2023, 95% of organizations faced API security problems, such as distributed denial of service (DDoS) attacks, lack of authentication, API key leaks, shadow or zombie APIs that no one knows about, sensitive data overexposure, and business logic abuse. API security problems can cause reputational damage, financial losses, disruption to business operations, and data privacy threats.