Learn how to create effective REST clients on Android with Retrofit. Boost your productivity and enjoy working with complex APIs.
Every modern Android app needs to connect to at least one private or public API. Interacting with services can be difficult due to the extreme variety of request and response formats. Depending on the API, you’ll need to change your request payloads, authentication, data formats, and much more.
Retrofit: a type-safe HTTP client for Android and Java Retrofit Homepage
Retrofit handles all of the complicated and repetitive parts of network implementations for
you. It hides the entire network layer, from creating a connection to processing the
handling on a separate thread, from you. Retrofit even does the mapping of the requests and responses to
Java objects for you (e.g., creating a JSON payload from your passed List<User>
). You
only need to describe what and how you want to send or receive it.
This awesomeness comes at a cost: an initial learning curve. Retrofit might look a little more complicated at the beginning, but pays off multiple times in the long run.
If you’re thinking about using Retrofit, or haven’t developed a deep knowledge of it yet, you’ll benefit from this book. We’ve created this book with the vision of being the ultimate guide to understanding Retrofit. After working through this book, you’ll be able to connect to new APIs and services within minutes.
You can find a Retrofit tutorial series on our website and our free video tutorial series on YouTube, where we describe some elements of Retrofit. The book extends and connects these tutorials into one common thread that guides you through all important aspects of Retrofit. The chapters are structured in a way that rewards a linear reading. Retrofit rookies can and should read it cover to cover. Experienced Retrofit developers can jump to specific sections for guides on how to solve their specific problem.
The list below provides a comprehensive overview of covered topics in the book.
Additionally to the regular content we provide an appendix with three sections:
In short: this book is for you. We believe that every developer reading this book will take away new ideas on how to optimize their Android apps in the sense of interacting with APIs or web services using Retrofit. You’ll recognize goodies that are applicable for the projects you’re working on.
This book is for Android developers, who want to receive a substantial overview and reference book on Retrofit. You’ll benefit from clearly recognizable code examples related to your daily work with Retrofit.
If you’re just starting out with Retrofit (or coming from another HTTP library like Android Asynchronous Http Client or Volley) this book will show you all important parts on how to create sustainable REST clients on Android. The provided code snippets let you jumpstart and create your first successful API client within minutes!
If you’ve already worked with Retrofit, you’ll profit from our extensive code snippets and apply the learnings to your existing code base. Additionally, the book illustrates various use cases for different functionalities and setups like authentication against different backends, request composition, file uploads and downloads, and much more!
One focus of this book is not only to implement the requirements, but also do so in a clean way. We’ve seen way to many complicated and messy usages of Retrofit. We focus on providing code samples which adhere to clean code standards. We avoid any unnecessary duplication at all costs. This has the side effect of some extra app performance gains by efficient Java object handling.
With the purchase of this book, you benefit from the sample project that awaits your download within the extras section on Leanpub. The sample project is an Android project based on gradle. You can directly touch and use classes that are only illustrated in excerpts within this book.
Check your Leanpub Library and select Retrofit: Love working with APIs on Android to download the sample code base.
We’ve published the first version of this Retrofit book in July 2015. Since this initial release we’ve extended and updated the book more than a dozen times. Once you buy the book, you get all future updates for free. Even if it’s a huge Retrofit update, for example from version 1.9 to 2.0. With every new release of Retrofit we’ll evaluate the entire book content and update it accordingly.
Of course, we’re listening to your feedback and add new sections and even chapters, if it can be useful to all readers. If you still have a question after reading this book, let us know and we might be able to help!
If you’re still on the fence if this book helps you, checkout the sample or, even better, use Leanpub’s (and our) happiness guarantee. Try this book out and if you don’t think this book provides enough value, you can refund your money within 45 days with no questions asked. You don’t have any risk in testing this book, which saves you hours of headaches and makes your Android app code so much cleaner.
The current version of this book is fully focused on Retrofit 2.x, no hint or code snippet that points to Retrofit 1. If you’re interested in the first version of the book that based on Retrofit 1, please visit this book’s extras page on Leanpub. As a reader of this book, the first version is also available for you!