Hi there,
I want to make rest api in codeigniter .Already have created backend for web app.I need to fetch json data from third party(Request Response).Can you give me the idea how to integrate rest api in backend?

In addition: so what you're searching for is a client to query remote services? Have you considered Guzzle?

You can integrate it into CI3 by using composer:

composer require guzzlehttp/guzzle:~6.0

And modifying the composer_autoload variable in application/config/config.php into:

$config['composer_autoload'] = FCPATH . 'vendor/autoload.php';

Then in your controller you can do:

public function index()
{
    $client   = new \GuzzleHttp\Client();
    $response = $client->request('GET',
                                 'http://httpbin.org/get',
                                 ['timeout' => 5]);

    print $response->getStatusCode();
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.