Consuming APIs In Laravel is Now Available! πŸŽ‰

Published on by

Consuming APIs In Laravel is Now Available! πŸŽ‰ image

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: LN20

πŸ‘‰ The book is also available in a bundle (Consuming APIs in Laravel and Battle Ready Laravel). Get 10% off the bundle with discount code: LN10

πŸ‘‰ 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 LN20 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 LN10 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

Ashley Allen photo

I am a freelance Laravel web developer who loves contributing to open-source projects, building exciting systems, and helping others learn about web development.

Filed in:
Cube

Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.

image
No Compromises

Joel and Aaron, the two seasoned devs from the No Compromises podcast, are now available to hire for your Laravel project.

Visit No Compromises
Laravel Forge logo

Laravel Forge

Easily create and manage your servers and deploy your Laravel applications in seconds.

Laravel Forge
Tinkerwell logo

Tinkerwell

The must-have code runner for Laravel developers. Tinker with AI, autocompletion and instant feedback on local and production environments.

Tinkerwell
No Compromises logo

No Compromises

Joel and Aaron, the two seasoned devs from the No Compromises podcast, are now available to hire for your Laravel project. ⬧ Flat rate of $7500/mo. ⬧ No lengthy sales process. ⬧ No contracts. ⬧ 100% money back guarantee.

No Compromises
Kirschbaum logo

Kirschbaum

Providing innovation and stability to ensure your web application succeeds.

Kirschbaum
Shift logo

Shift

Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Shift
Bacancy logo

Bacancy

Supercharge your project with a seasoned Laravel developer with 4-6 years of experience for just $2500/month. Get 160 hours of dedicated expertise & a risk-free 15-day trial. Schedule a call now!

Bacancy
Lucky Media logo

Lucky Media

Bespoke software solutions built for your business. We β™₯ Laravel

Lucky Media
Lunar: Laravel E-Commerce logo

Lunar: Laravel E-Commerce

E-Commerce for Laravel. An open-source package that brings the power of modern headless e-commerce functionality to Laravel.

Lunar: Laravel E-Commerce
LaraJobs logo

LaraJobs

The official Laravel job board

LaraJobs
Larafast: Laravel SaaS Starter Kit logo

Larafast: Laravel SaaS Starter Kit

Larafast is a Laravel SaaS Starter Kit with ready-to-go features for Payments, Auth, Admin, Blog, SEO, and beautiful themes. Available with VILT and TALL stacks.

Larafast: Laravel SaaS Starter Kit
SaaSykit: Laravel SaaS Starter Kit logo

SaaSykit: Laravel SaaS Starter Kit

SaaSykit is a Laravel SaaS Starter Kit that comes with all features required to run a modern SaaS. Payments, Beautiful Checkout, Admin Panel, User dashboard, Auth, Ready Components, Stats, Blog, Docs and more.

SaaSykit: Laravel SaaS Starter Kit
Rector logo

Rector

Your partner for seamless Laravel upgrades, cutting costs, and accelerating innovation for successful companies

Rector

The latest

View all →
DirectoryTree Authorization is a Native Role and Permission Management Package for Laravel image

DirectoryTree Authorization is a Native Role and Permission Management Package for Laravel

Read article
Sort Elements with the Alpine.js Sort Plugin image

Sort Elements with the Alpine.js Sort Plugin

Read article
Anonymous Event Broadcasting in Laravel 11.5 image

Anonymous Event Broadcasting in Laravel 11.5

Read article
Microsoft Clarity Integration for Laravel image

Microsoft Clarity Integration for Laravel

Read article
Apply Dynamic Filters to Eloquent Models with the Filterable Package image

Apply Dynamic Filters to Eloquent Models with the Filterable Package

Read article
Property Hooks Get Closer to Becoming a Reality in PHP 8.4 image

Property Hooks Get Closer to Becoming a Reality in PHP 8.4

Read article