Composer client with LazyJsonMapper response models and ready-to-run examples. Supports 97 Instagram Scraper API methods.
Package: jsonscraper/instagram-api-php · Methods · Examples · Documentation
1. Get your key from the Instagram API product page and set it on your server:
export JSONSCRAPER_INSTAGRAM_LICENSE_KEY='your-license-key'2. Install the package:
composer require jsonscraper/instagram-api-php:^0.13. Make a request:
<?php
require __DIR__.'/vendor/autoload.php';
$client = new JsonScraper\Instagram(getenv('JSONSCRAPER_INSTAGRAM_LICENSE_KEY'), models: true);
$response = $client->v1_user_by_username(['username'=>'apple', 'cache_timeout'=>60]);
if ($response->isOk() && $response->getIg()) {
echo $response->getIg()->getUsername();
}The API payload is in ig. Live calls require a valid API license and may consume quota. Response examples and status handling.
97 methods are available. Common starting points:
| What you need | Method |
|---|---|
| Read a profile | v1_user_by_username() |
| Read a profile by ID | v1_user_by_id() |
| List profile posts | v1_user_medias_chunk() |
| Read a post or reel | v1_media_by_code() |
| Read comments | v1_media_comments_chunk() |
| Search profiles | v1_search_users() |
Each example includes command-line parameters, key setup, timeouts, error handling and response output. Run it with --help first; this makes no API request.
Browse all 97 complete examples · Full method and parameter reference
Use models: true for LazyJsonMapper objects such as Profile, Media, Comment and Collection. Use the default array mode for the full upstream envelope.
$profile = $response->getIg();
echo $profile->getUsername();
echo $profile->getFollowerCount();Model hierarchy, media and collection examples · All model classes
Requests use a 30-second timeout by default. Configure caching and retries to fit your application's request budget. Keys are read from your server environment; redirects are disabled.
Configuration options, HTTP errors, caching and pagination · Full integration guide
Prefer an assistant connection? Use the shared jsonscraper MCP server. Connect an Instagram API license, a TikTok API license, or both; each product keeps its own plan and quota. MCP source and setup.
The SDK source is MIT-licensed. Hosted API access requires a separate Instagram license. Check current plans and get access.
Service support · SDK issues · Changelog · MIT license
python3 tests/contract.pyTests use a local/mock server and require no API key. A GitHub Actions template is available for optional automation.
The SDK has no installation or usage telemetry. README links use campaign parameters for website referral analytics. jsonscraper is independent and is not affiliated with Instagram or Meta.