You've built a great app, but now your users want more power.
Maybe they want their monthly reports to be sent to their accounting software. Perhaps they need to automatically create new tasks in their project management tool, or they want contact form submissions to be automatically sent to their CRM.
Thereβs no doubt that integrating with third-party APIs and adding these features to your app is a great way to add value for your users, but it can also be super daunting to get started.
In fact, Iβd go as far as to say API integrations are one of the most complex and scary things Iβve faced in my entire developer career! There are just so many things youβve got to know if you want your API integration to work properly and be robust, secure and easy to maintain.
But even more frustrating is the fact itβs also just so damn hard to find reliable information you can trust.
Take a look online and youβll come across a huge amount of information about APIs thatβs either completely outdated or just plain wrong. If youβve ever done any research yourself, youβll know itβs often near impossible to know whatβs still relevant, or exactly how some of the concepts youβre learning are supposed to fit into your application.
Theory is great - but what you really need is actionable information!
That's why I'm really excited to announce that my new book, Consuming APIs In Laravel, is now available to buy!
This book is a 440+ page, deep dive into the world of APIs. It's your complete guide to confidently building robust and powerful API integrations in your Laravel projects to add cool new features.
Itβs the comprehensive API manual I wish I had when I started out as a developer. One you can trust and will want to refer back to again and again.
π Get 20% off the book with discount code: CAIL20
π The book is also available in a bundle (Consuming APIs in Laravel and Battle Ready Laravel). Get 10% off the bundle with discount code: BUNDLE10
π You can download a FREE sample of the book. The sample is from the Webhooks chapter and covers the Building Webhook Routes and Webhook Security sections.
You can buy the book or download your free sample at consuming-apis-in-laravel.com.
What's Covered In The Book?
The book aims to help you build powerful API integrations that are testable, maintainable, and easy to understand.
I'll show you the way I've built integrations for many projects that help my clients and their users, including specific code examples that give context as to exactly where, why, and how youβd use something in your Laravel app.
The book is broken down into five chapters:
Chapter 1: About APIs
This chapter covers the theory of APIs to give you a solid foundation to build upon. It covers things like:
- β Data formats: JSON vs. XML
- β HTTP message structures
- β Types of web APIs
- β Benefits and drawbacks of APIs
- β API authentication
- β API integration security
Chapter 2: Code Techniques
This chapter covers code techniques that I use to make my API integrations more robust and easier to maintain. It covers:
- β Strict type-checking
- β Composition over inheritance
- β Final classes
- β Data transfer objects
- β Readonly classes and properties
- β Using interfaces and the service containers
- β Redacting sensitive parameters
- β Enums
The techniques covered in this chapter don't just apply to API integrations though. You can use them anywhere in your Laravel apps.
Chapter 3: Building an API Integration Using Saloon
We'll be covering how to consume APIs using Saloon v3, an awesome PHP package built by Sam CarrΓ© that has over 500k downloads!
Saloon provides a simple, fluent, and object-oriented approach for consuming APIs, making it easy for you to build API integrations without having to worry about the underlying implementation.
Inside, we'll take a look at what Saloon is, the benefits of using it, and alternative approaches that you may want to use. We'll then step through and reveal exactly how you can confidently use Saloon in your Laravel applications.
We'll cover:
- β Alternatives to Saloon
- β API authentication
- β Sending requests and parsing responses
- β Pagination
- β Solo requests
- β Sending concurrent requests
- β Middleware
- β Plugins
- β Error handling
- β Retrying requests
- β Handling API rate limits
- β Caching API responses
- β Testing API integrations
In particular, we'll be putting a focus on the testability of your code. By the end of this chapter, you'll also be able to write tests for your API integrations with ease.
Chapter 4: OAuth
OAuth is a scary topic for a lot of developers! There are so many moving parts and it can be hard to know where to start.
In this chapter, we're demystifying OAuth and covering:
- β Use cases for OAuth
- β OAuth terminology
- β Breakdown of each OAuth 2.0 flow
- β Benefits and drawbacks of OAuth
- β OAuth security & best practices
- β Integrating with an OAuth API using Saloon
- β Testing OAuth integrations
We'll then take a look at how you can use Saloon to build an OAuth integration with Spotify. This includes learning how to write tests for your OAuth integration to give you confidence that it works as expected.
Chapter 5: Webhooks
Finally, we'll then dive into the world of webhooks. We'll cover what webhooks are, how they work, and how to securely handle webhooks in your Laravel applications.
We'll cover:
- β What webhooks are and how they work
- β Advantages and disadvantages of webhooks
- β Webhook security & best practices
- β Securely webhooks in Laravel
- β Testing webhook routes
- β Using Laravel's queue system to improve your webhook performance
Who Is This Book For?
If your client or boss uttering the words βwe need it to integrate with XYZβs APIβ gives you nightmares, this book is for you.
Likewise, if you've never been sure how to structure your API integrations, or you've struggled to write tests for them, this book is for you.
The book doesn't just show you how to write code. It also focuses on teaching you skills to improve the standardisation, maintainability and testability of your code. It teaches you techniques that you can use to improve your code quality and make your API integrations more robust and easier to maintain.
It also shows you how to write tests for your API integrations so you can have confidence that your code works as expected.
By the end of this book, you'll be able to confidently build powerful API integrations for your Laravel applications.
Pricing
The book is available for $39. You will get:
- β PDF (light mode)
- β PDF (dark mode)
- β EPUB
You can use the discount code CAIL20
to get 20% off your purchase. This brings the price down to $31.20!
The book is also available in a bundle for $59. You will get:
- β Consuming APIs In Laravel - PDF (light mode)
- β Consuming APIs In Laravel - PDF (dark mode)
- β Consuming APIs In Laravel - EPUB
- β Battle Ready Laravel - PDF (light mode)
- β Battle Ready Laravel - PDF (dark mode)
- β Battle Ready Laravel - EPUB
You can use the discount code BUNDLE10
to get 10% off this bundle as well. This brings the price down to $53.10!
π There's also a FREE sample of the book. The sample is from the Webhooks chapter and covers the Building Webhook Routes and Webhook Security sections.
π You can get your copy at: consuming-apis-in-laravel.com.
About the Author
I'm Ash Allen (@AshAllenDesign on Twitter/X).
I'm a Laravel web developer from the UK.
I've worked with many companies around the world to help build and improve Laravel applications they can be proud of!
I wrote "Battle Ready Laravel" which has sold over 750+ copies and is available as a PDF, EPUB, and a paperback. I've also written "The Clean Coder's Guide to Laravel" which has been downloaded more than 6k times, and I have an active blog where I write about Laravel and PHP. I've also had articles published on the Laravel News, Vonage, and Honeybadger blogs.
I have several PHP packages (such as Short URL and Laravel Exchange Rates) which have been installed over 610k times. I also love working on other open-source projects and have contributed to the Laravel framework.
Need a Little More Convincing?
Here's what some of the early readers have said about the book:
"This book is a treasure trove of knowledge and practical ways to integrate with third party APIs. Ash has a brilliant skill of breaking down complex integration methods and RFC specification into beautiful, readable and testable code." - Sam CarrΓ©, Creator of Saloon, Head of Engineering at Plannr CRM
"If you work on a Laravel application and that application hooks into an API such as Stripe, GitHub, HubSpot etc... then this book is absolutely for you. There's a lot of great content and it's changed how I plan on approaching handling APIs in the future" - Jon Purvis, DevOps Engineering Lead