Instagram API for PHP

Instagram API for PHP Developers

HikerAPI is a REST API that works with PHP's built-in HTTP functions. Use file_get_contents, cURL, or Guzzle.

Quick Start with cURL

<?php
$apiKey = "your_access_key";
$baseUrl = "https://api.hikerapi.com";

function apiRequest($endpoint, $params = []) {
    global $apiKey, $baseUrl;
    $url = $baseUrl . $endpoint . "?" . http_build_query($params);
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, ["x-access-key: $apiKey"]);
    $response = curl_exec($ch);
    curl_close($ch);
    return json_decode($response, true);
}

$user = apiRequest("/v1/user/by/username", ["username" => "instagram"]);
echo "Followers: " . number_format($user["follower_count"]);

With Guzzle (Laravel / Symfony)

<?php
use GuzzleHttp\Client;

$client = new Client([
    "base_uri" => "https://api.hikerapi.com",
    "headers" => ["x-access-key" => "your_access_key"],
]);

$response = $client->get("/v1/user/by/username", [
    "query" => ["username" => "instagram"],
]);

$user = json_decode($response->getBody(), true);
echo $user["full_name"];

Pagination

<?php
function getAllFollowers($userId) {
    $followers = [];
    $maxId = null;
    do {
        $params = ["user_id" => $userId];
        if ($maxId) $params["max_id"] = $maxId;
        $data = apiRequest("/v1/user/followers/chunk", $params);
        $followers = array_merge($followers, $data["users"]);
        $maxId = $data["next_max_id"] ?? null;
    } while ($maxId);
    return $followers;
}

FAQ

What PHP version do I need?
PHP 7.4+ recommended.

Does it work with Laravel?
Yes. Use Guzzle or the HTTP facade.

Getting Started

  1. Register for an API key
  2. API docs — all 147+ endpoints

Ready to get started?

100 free API requests. No credit card required.

Sign Up Free