API Development in Kotlin: From Basics to Production
API Development in Kotlin: From Basics to Production
Summary:
This book is a practical guide to building modern web APIs in Kotlin. If you are already familiar with the basics of Kotlin or Java and want to learn how to design and implement server applications capable of handling high loads, this edition is for you.
The author guides the reader step by step from environment setup to deploying a finished product. You will learn how to choose between popular frameworks: Ktor (lightweight, asynchronous) and Spring Boot (powerful, with a rich ecosystem). Each stage is accompanied by real code examples and explanations.
What you will learn:
- Fundamentals of RESTful API design: resources, endpoints, HTTP methods, and response codes.
- Working with JSON: serialization using kotlinx.serialization and Jackson.
- Request validation, error handling, and logging.
- Authentication and authorization: JWT, OAuth2, Basic Auth.
- Working with databases: Exposed (SQL), MongoDB (KMongo), Spring Data.
- Creating GraphQL endpoints using the graphql-kotlin library.
- API testing: unit, integration, and end-to-end tests.
- Documentation: OpenAPI/Swagger, GraphQL Playground.
- Containerization with Docker, CI/CD, deployment to cloud platforms.
Who this book is for:
- Java developers transitioning to Kotlin.
- Kotlin developers looking to master backend development.
- IT students and graduates.
- Team Leads evaluating Kotlin for new projects.
The book is written in a "from simple to complex" format. The first chapters cover basic concepts: routing, request handling, working with databases. Then you will move on to advanced topics: asynchrony (coroutines), microservice architecture, monitoring, and performance optimization. At the end of the book, a full-fledged project awaits you — building an API for an online store from scratch.
All code examples are available in a GitHub repository. You will be able not only to read but also to run the applications immediately, experiment, and adapt them to your own tasks.
Whether you are building a simple REST application or a complex system with GraphQL and microservices, this book will be your reliable companion. Kotlin is a modern, concise, and safe language, and with this guide, you will learn to use it to its full potential.
Bonus: chapters on security (CORS, SQL injection, XSS), file handling and streaming, WebSocket, integration with external APIs. The book is suitable both for self-study and corporate training.
Recommendations
Rust and Kubernetes: Reliable Cloud Application Development
Clean Code in TypeScript: Writing Maintainable and Reliable Code
Algorithms and Data Structures in TypeScript
Go (Golang) for Data Science: A Practical Guide
PHP Interview: 200 Questions and Answers
Laravel: Up & Running. Fundamentals and Practice of Working with the Framework