Mahmoud Al-HabashOpen to new projects
  • WorkWork
  • ServicesServices
  • LabLab
  • WritingWriting
  • ContactContact
Amman--:--عربي
Writing/Laravel

Laravel HTTP Client: External API Calls

Make HTTP requests to external APIs with Laravel HTTP client.

16 January 20261 min readLaravelاقرأ بالعربية

On this page

  1. Basic Request
  2. With Headers
  3. POST Request
  4. Error Handling
  5. Retry

HTTP client requests:

Basic Request

php
$response = Http::get('https://api.example.com/users');
$data = $response->json();

With Headers

php
$response = Http::withHeaders([
    'Authorization' => 'Bearer ' . $token,
])->get($url);

POST Request

php
$response = Http::post($url, [
    'name' => 'John',
    'email' => 'john@example.com',
]);

Error Handling

php
$response->successful();
$response->failed();
$response->throw();

Retry

php
Http::retry(3, 100)->get($url);
All articles

Keep reading

  • Laravel Action Classes Pattern16 January 20261 min read
  • Laravel Action Classes: Single Responsibility16 January 20261 min read
  • Laravel API Rate Limiting16 January 20261 min read