Build
Robust and Powerful API Integrations
For Your Laravel Projects With Ease

Learn how to confidently integrate third-party APIs in your Laravel projects using maintainable, testable and extensible code.

The world of APIs has finally been made simple!

440+ pages! Only $39! Over 700+ copies sold!
Battle Ready book cover

Books emoji Enhance Your Laravel Apps Without The Stress

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.

If your client or boss uttering the words “we need it to integrate with XYZ’s API” gives you nightmares, you’re certainly not alone.

What’s more, once you’ve started building your integration, it’s difficult to know how to write automated tests for your code. After all, creating an API integration without writing tests is a surefire way to build an integration that has bugs and is difficult 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 info 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 from someone who knows the subject inside out…

And that’s exactly what I’m offering you today . 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.

Introducing Consuming APIs in Laravel, your complete guide to confidently building robust and powerful API integrations in your Laravel projects to add cool new features.

Whether you’re an experienced pro or just starting out in your developer career, it includes all the information you need to consume APIs directly from your Laravel application using maintainable, testable, and extensible code.

Inside, you’ll get instant access to over 440-pages of detailed yet easy-to-digest information with tons of real-world code examples you can start applying to your projects straight away.

Finally you can easily integrate third-party APIs with your Laravel project and feel confident in doing so!

Books emoji 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… Something I’ve found to be sorely lacking in many other books and tutorials I’ve read on the subject.

We'll cover techniques that we can use to improve the quality of API integration code .

We'll look at how we can use these techniques to integrate with real-world APIs using Saloon. We'll cover how to write tests for your API integrations, how to handle rate limits, and how to deal with errors .

When I started writing the book, one of my main aims was to really hone in on the areas that developers often find particularly confusing. For example, I’ve included a whole chapter on OAuth , which is a complex topic that people are often scared of going anywhere near, so I finally wanted to make it super understandable and less nightmarish! It contains diagrams and step-by-step instructions on how each “OAuth flow” works.

I’ve also added a full guide on how you can use Saloon in your Laravel applications to interact with an OAuth API . I’m really hoping that this section makes developers less scared of OAuth and encourages them to feel more confident and comfortable using it.

There’s also a dedicated section on securely handling webhooks sent from third-party APIs back to your application. I’ve worked on many projects where the developers haven’t written secure code for handling the webhooks, which has meant that there have been security vulnerabilities in the systems that could be exploited. Using code examples, I’ll show you exactly how to securely handle webhooks and make your API integration more robust and bulletproof.

In my experience, it’s information like this that is pure gold when it comes to becoming more competent and confident with handling APIs.

Throughout, I’ve really tried hard to break down a lot of the barriers and make everything super simple for you to dive right in with confidence and make your Laravel projects even more awesome!

Making API Requests

You'll learn how to make requests to third-party API integrations using Saloon.

Securely Handling Webhooks

Discover how to securely handle webhooks sent from third-party APIs back to your Laravel application.

Testing

Master how to write tests for your API integrations to prove they work as expected.

Caching Responses

You'll learn how to cache responses from third-party APIs to reduce the number of requests you make and improve your application's performance.

Working with Rate Limits

You'll uncover techniques that you can use to avoid hitting rate limits when making requests to third-party APIs.

Handling Errors

Learn different ways to effectively handle errors that occur when making requests using your API integration.

Understand OAuth

Discover exactly how to use OAuth to authenticate with third-party applications (such as GitHub) directly from your Laravel applications.

Robust Code Practices

You'll learn several techniques that you can use to improve the quality of your API integration code, such as data transfer objects, read-only classes and properties, strict type checking, and more.

Learn About APIs

You'll fully understand APIs, how they work, and the benefits they can provide for businesses.

Cowboy emoji Learn How to Consume APIs 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 install and use Saloon in your Laravel applications.

Saloon Logo
Sections & Chapters Covered

📚 Table Of Contents

Chapter 1: About APIs


  1. What is an API?
  2. Data Formats: JSON vs XML
  3. HTTP Message Structure
    • Example HTTP Request Message
    • Example HTTP Response Message
  4. Types of Web APIs
    • REST APIs
    • GraphQL APIs
    • RPC APIs
    • SOAP APIs
  5. Benefits of APIs
  6. Drawbacks of APIs
  7. Authentication
    • Bearer Tokens
    • JSON Web Tokens (JWT)
    • Basic Authentication
  8. API Integration Security

Chapter 2: Code Techniques


  1. Strict Type-Checking
  2. Composition Over Inheritance
  3. Final Classes
  4. Data Transfer Objects
  5. Readonly Classes and Properties
  6. Using Interfaces and the Service Container
  7. Redacting Sensitive Parameters
  8. Enums

Chapter 3: Building an API Integration Using Saloon


  1. What is Saloon?
  2. Alternatives to Saloon
    • Guzzle
    • Http Facade
    • cURL
    • API SDK
    • Should I Use Saloon?
  3. Connectors, Requests, and Senders
  4. Installation and Configuration
  5. Available Artisan Commands
  6. Preparing the API Integration
  7. Building the Interface and Classes
    • Building the Interface
    • Building the DTOs
    • Building the Collections
    • Creating the Integration Service Class
    • Binding the Interface to the Concrete Implementation
  8. Preparing the Connector
    • Creating the Connector Class
    • Adding the Connector to the Service Class
  9. Authentication
    • Where to Use Authentication
    • Types of Authentication
  10. Sending Requests
    • Fetching a Single Resource
    • Fetching a List of Resources
    • Creating a New Resource
    • Updating an Existing Resource
    • Deleting a Resource
  11. Pagination
    • Understanding Paginated Responses
    • Sending Requests to Paginated Endpoints in Saloon
    • Sending the Requests to the API
  12. Solo Requests in Saloon
  13. Sending Concurrent Requests
    • Sequential vs Concurrent Requests
    • Sending Concurrent Requests in Saloon
  14. Middleware
  15. Plugins
  16. Error Handling
    • Saloon's Exceptions
    • Manually Handling Errors
    • Automatically Handling Errors
    • Using Your Own Exceptions
    • Changing the Exception Logic
  17. Retrying Requests
  18. Handling API Rate Limits
    • What is Rate Limiting?
    • Strategies for Working with Rate Limited APIs
    • Installing the Saloon Rate Limit Plugin
    • Configuring the Rate Limits
    • Sending the Requests
    • Catching 429 Error Responses
    • Setting Rate Limit Thresholds
  19. Caching Responses
  20. Testing API Integrations
    • Benefits of Testing
    • Should We Make Real Requests?
    • What Should We Test?
    • Using a Test Double
    • Extracting Test Helpers Into Traits
    • Adding Assertions to Your Test Double
    • Mocking HTTP Responses
    • Recording HTTP Responses

Chapter 4: OAuth


  1. What is OAuth?
  2. Use Cases for OAuth
  3. OAuth Terminology
    • OAuth Roles
    • Flows and Grants
    • Tokens
    • Client ID and Client Secret
    • Public and Confidential Clients
    • Scopes
  4. OAuth 2.0 Flows
    • Authorization Code Grant
    • Authorization Code Grant with PKCE
    • Refresh Token Grant
    • Client Credentials Grant
    • Device Code Grant
    • Implicit Grant
    • Resource Owner Password Grant
  5. The Benefits of Using OAuth
  6. The Drawbacks of Using OAuth
  7. OAuth Best Practices
  8. Laravel Packages for OAuth
    • Laravel Socialite
    • Laravel Passport
  9. OAuth with Saloon - Authorization Code Grant
    • Preparing the OAuth Integration
    • Creating the OAuth Routes
    • Preparing Your Connector for OAuth
    • Building the Interface and Classes
    • Building the DTOs and Collection
    • Preparing Our Model and Database
    • Creating the Integration Service Class
    • Binding the Interface to the Concrete Implementation
    • Generating an Authorization URL
    • Handling the Authorization Callback
    • Making a Request Using the Access Token
  10. Testing Your OAuth Integration
    • Preparing for Testing
    • Testing the Controllers
    • Testing the Service Class

Chapter 5: Webhooks


  1. What are Webhooks?
  2. Advantages of Webhooks
  3. Disadvantages of Webhooks
  4. Defining Webhook Routes
    • Defining Webhook Routes in the External Application's Dashboard
    • Defining Webhook Routes at Runtime
  5. Building Webhook Routes
    • What Will Be Sent
    • Creating the Route
    • Creating the Enum
    • Creating the Model
    • Creating the Controller
  6. Webhook Security
    • Why You Must Secure Your Webhooks
    • Validating a Mailgun Webhook
  7. Testing Webhook Routes
  8. Using Queues to Process Webhooks
So, How Much Is It?

Money with wings emoji Pricing

Consuming APIs in Laravel

Consuming APIs in Laravel examples
$

39

Buy Now!

Instant access to the entire book. Start learning in minutes!

Start learning how to build your own awesome API integrations.

What's included:

  • PDF (Light Mode)

  • PDF (Dark Mode)

  • EPUB (for E-Readers)

  • Instant Access

Best Value Bundle!

Consuming APIs in Laravel + Battle Ready Laravel

Consuming APIs in Laravel examples

$78

$

59

Buy Now!

Both books for one great value price!

Instant access to Consuming APIs in Laravel + my best-selling book Battle Ready Laravel, the complete blueprint for learning how to audit, test and improve your Laravel applications.

What's included:

  • Both books

  • PDF (Light & Dark Mode)

  • EPUB (for E-Readers)

  • Instant Access

Waving emoji About the Author

Hey there! My name's Ash Allen !

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 1,200+ 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 5k times, and I have an active blog where I write about Laravel and PHP. I've also had articles published on the Laravel News 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.

Ash Allen

Ash Allen 🚀

Web Developer

What People Say About the Book

Sparkles emoji Testimonials

Dwight Watson

Dwight Watson

@DwightConrad
It was super helpful in making sense of all the different types of APIs I’ve reckoned with in the past, properly understanding the differences and the conventions of each standard. Also great to learn better approaches to testing my API integrations going forward .
Sam Carré

Sam Carré

@carre_sam
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 .
Helge Sverre

Helge Sverre

@HelgeSverre
It's very good , buy it!
Häz

Häz

@haztakki
An excellent resource for developers who want to learn about webhooks. The book provides clear and concise examples, and breaks down complex concepts into bite-sized chunks , making it easy to follow and understand. I highly recommend this book to anyone who wants to deepen their knowledge of webhooks.

Aleksander Bless

I loved the course. I'm now able to use Saloon to create the integrations I wanted .
Jon Purvis

Jon Purvis

@CriticalRespawn
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

❓ Frequently Asked Questions

Point emoji What format is the book available in?

The book is available to download as a PDF or as an EPUB. You'll get both of these versions when you purchase the book through this site.

Point emoji Where can I buy a printed copy?

You can buy a printed copy of Consuming APIs in Laravel from Amazon. You can either buy it from amazon.com using this link, or you can search for 'Consuming APIs in Laravel' on your region's Amazon site.

Point emoji Do you offer PPP or a student discount?

Yes! I do offer PPP (purchasing power parity) and a student discount. Drop me an email at mail@ashallendesign.co.uk and I'll provide you with a discount code that you can use.

Point emoji Can I get an invoice?

Of course! As soon as you purchase the book, you'll be sent an email with the invoice.

Point emoji Can I get in touch with you?

Sure! If you have any questions at all, you can get in touch with me at mail@ashallendesign.co.uk

Books emoji From the Creator of...

Battle Ready Laravel banner

Rocket emoji Powered by Ash Allen Design

Zap emoji Analytics by Fathom Analytics

Fire emoji Hosted using Digital Ocean

Get Your Free Sample!

Enter your name and email below and you'll get sent a free sample from the "Webhooks" chapter about:

Checkmark emoji Building Webhook Routes
Checkmark emoji Webhook Security