Friday, June 12, 2026
HomeLanguagesHow to Call External API in Laravel

How to Call External API in Laravel

Call external APIs in laravel 10/9/8/7 apps; In this tutorial, you will learn how to send http get, post, put and delete request to call external APIs in laravel from controller, blade and model using Http facade.

Sometimes, you need to call external APIs in laravel controller, blade, and model, So you can GET, POST, PUT, DELETE, requests with headers for that.

How to Call External APIs in Laravel Apps using Http facade

Let’s use the following methods to call external APIs from the controller, blade, and model in laravel 10/9/8/7/6 using Http facade:

  • Method 1: Laravel Call GET Request API
  • Method 2: Laravel Call POST Request API

Method 1: Laravel Call GET Request API

Let’s use the following controller method to call or send curl http get request in laravel:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use Illuminate\Support\Facades\Http;


class PostController extends Controller

{

    /**

     * Write code on Method

     *

     * @return response()

     */

    public function index()

    {

        $response = Http::get('https://jsonplaceholder.typicode.com/posts');


        $jsonData = $response->json();

        dd($jsonData);

    }

}

Method 2: Laravel Call POST Request API

Let’s use the following controller method to call or send a curl HTTP post request in laravel

<?php


namespace App\Http\Controllers;

use Illuminate\Http\Request;

use Illuminate\Support\Facades\Http;


class PostController extends Controller

{

    /**

     * Write code on Method

     *

     * @return response()

     */

    public function store()

    {
        $response = Http::post('https://jsonplaceholder.typicode.com/posts', [

                    'title' => 'This is test from geeksforgeeks.org',

                    'body' => 'This is test from geeksforgeeks.org as body',

                ]);

  

        $jsonData = $response->json();


        dd($jsonData);

    }

}

Conclusion

Call external APIs in laravel; In this tutorial, you have learned how to call external APIs in laravel from the controller.

Recommended Laravel Tutorials

RELATED ARTICLES

Most Popular

Dominic
32515 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6897 POSTS0 COMMENTS
Nicole Veronica
12013 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12109 POSTS0 COMMENTS
Shaida Kate Naidoo
7019 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6976 POSTS0 COMMENTS
Umr Jansen
6963 POSTS0 COMMENTS