SuperAPI AI Directory

instagram-hikerapi

Coding & development

View repository

Updated 10-15 21:39

About this skill

Instagram SuperPower

Tools

Tool Purpose Cost
HikerAPI Analytics: profiles, reels, comments, followers, hashtags, search $0.001/request (Standard)
Cobalt Downloading video/photo from Instagram CDN Free (self-hosted)
Groq Whisper Transcription of downloaded videos Free

Documentation and links

Resource URL
HikerAPI documentation https://hiker-doc.readthedocs.io/en/latest/
HikerAPI Swagger https://api.instagrapi.com/docs
HikerAPI Redoc https://api.instagrapi.com/redoc
HikerAPI dashboard https://hikerapi.com
HikerAPI Python SDK pip install hikerapi
Cobalt GitHub https://github.com/imputnet/cobalt
instagrapi GitHub https://github.com/subzeroid/instagrapi

Path mapping

Mac mini (coordinator / agents)

What Path
Download script (Cobalt) ~/.claude/skills/instagram-hikerapi/scripts/download.sh
Analytics script (HikerAPI) ~/.claude/skills/instagram-hikerapi/scripts/analyze.sh
Watchlist script ~/.claude/skills/instagram-hikerapi/scripts/watchlist.sh
Cookie deployment script ~/.claude/skills/instagram-hikerapi/scripts/deploy-cookies.sh
Cookie check script ~/.claude/skills/instagram-hikerapi/scripts/check-cookies.sh
HikerAPI key ~/.secrets/hikerapi/api-key
Instagram credentials (for Cobalt) ~/.secrets/cobalt/accounts.json
Instagram cookies (for Cobalt) ~/.secrets/cobalt/cookies.json
Cobalt API key ~/.secrets/cobalt/api-key
Watchlist ~/.secrets/cobalt/watchlist.json
Downloaded files /tmp/downloads/

your server (YOUR_SERVER_IP, SSH: ssh $YOUR_SERVER_SSH)

What Path
Cobalt Docker Compose /opt/cobalt/docker-compose.yml
Cobalt cookies (working copy) /opt/cobalt/cookies.json
Cobalt API keys /opt/cobalt/keys/api-keys.json
Docker container cobalt-api
Cobalt API endpoint http://127.0.0.1:9000/ (localhost only)

How everything is connected

HikerAPI (облако)                    your server (YOUR_SERVER_IP)
─────────────────                    ────────────────────────────
api.hikerapi.com  ◀── curl ──  Mac mini / your server
  аналитика, данные                  Cobalt API (localhost:9000)
  $0.001/запрос                        скачивание медиа (бесплатно)

Mac mini
  analyze.sh  → HikerAPI (напрямую, без SSH)
  download.sh → SSH → your server → Cobalt → Instagram CDN
  watchlist.sh → analyze.sh + download.sh

HikerAPI -- Authentication

# ВАЖНО: используй api.instagrapi.com (без Cloudflare) вместо api.hikerapi.com
# api.hikerapi.com блокирует urllib/requests из скриптов
# Ключ хранится в:
cat ~/.secrets/hikerapi/api-key

# Использование в curl:
curl -s "https://api.instagrapi.com/ENDPOINT" \
  -H "accept: application/json" \
  -H "x-access-key: $(cat ~/.secrets/hikerapi/api-key)"

# Или как GET-параметр:
curl -s "https://api.instagrapi.com/ENDPOINT?access_key=$(cat ~/.secrets/hikerapi/api-key)"

Balance: GET /sys/balance -- shows remaining requests and amount.

HikerAPI -- Main endpoints

Users

Endpoint Description Requests
GET /v2/user/by/username?username=X Profile by username 1
GET /v2/user/by/id?id=X Profile by ID (faster) 1
GET /v2/user/clips?user_id=X User's reels (12 per page) 1
GET /gql/user/clips?user_id=X Reels via GraphQL 1
GET /v1/user/medias/chunk?user_id=X All posts (with pagination) 1
GET /v2/user/stories?user_id=X Stories 1
GET /v2/user/followers?user_id=X Followers (with pagination) 1
GET /v2/user/following?user_id=X Following 1
GET /v1/user/highlights?user_id=X Highlights 1

Media (posts/reels)

Endpoint Description Requests
GET /v2/media/info/by/code?code=X Info by post code 1
GET /v2/media/info/by/url?url=X Info by URL 1
GET /v2/media/comments?media_id=X Comments (15/page) 1
GET /v2/media/likers?media_id=X Who liked 1
GET /v1/media/download/video?media_pk=X Download video 1
GET /v1/media/download/photo?media_pk=X Download photo 1

Search

Endpoint Description Requests
GET /v2/fbsearch/topsearch?query=X Global search 1
GET /v2/fbsearch/reels?query=X Reels search 1
GET /v2/fbsearch/accounts?query=X Accounts search 1
GET /v2/fbsearch/places?query=X Places search 1

Hashtags

Endpoint Description Requests
GET /v2/hashtag/by/name?name=X Hashtag info 1
GET /v2/hashtag/medias/top?hashtag_id=X Top posts by hashtag 1
GET /v2/hashtag/medias/recent?hashtag_id=X Recent posts by hashtag 1

Data in responses

Each media object contains:

  • play_count / view_count -- views
  • like_count -- likes
  • comment_count -- comments
  • taken_at -- publication timestamp
  • code -- shortcode for URL (instagram.com/reel/{code}/)
  • caption.text -- caption text
  • user.username -- author

Quick start

Account profile

HIKER_KEY=$(cat ~/.secrets/hikerapi/api-key)
curl -s "https://api.instagrapi.com/v2/user/by/username?username=example_account" \
  -H "x-access-key: $HIKER_KEY" | python3 -m json.tool

Account reels (top performing)

HIKER_KEY=$(cat ~/.secrets/hikerapi/api-key)
# 1. Получить user_id
USER_ID=$(curl -s "https://api.instagrapi.com/v2/user/by/username?username=example_account" \
  -H "x-access-key: $HIKER_KEY" | python3 -c "import json,sys; print(json.load(sys.stdin)['user']['pk'])")

# 2. Получить рилсы
curl -s "https://api.instagrapi.com/v2/user/clips?user_id=$USER_ID" \
  -H "x-access-key: $HIKER_KEY" | python3 -c "
import json, sys
d = json.load(sys.stdin)
items = d.get('response',{}).get('items',[])
for item in sorted(items, key=lambda x: x['media'].get('play_count',0), reverse=True)[:5]:
    m = item['media']
    print(f'{m.get(\"play_count\",0):>10,} views | {m.get(\"like_count\",0):>6,} likes | https://instagram.com/reel/{m[\"code\"]}/')
"

Download reel (via Cobalt)

bash ~/.claude/skills/instagram-hikerapi/scripts/download.sh "https://www.instagram.com/reel/REEL_CODE/"

Download + transcribe (requires your own Whisper script, see below)

WHISPER_SCRIPT=/path/to/your/whisper.sh \
  bash ~/.claude/skills/instagram-hikerapi/scripts/download.sh "https://www.instagram.com/reel/REEL_CODE/" transcribe

Check HikerAPI balance

curl -s "https://api.instagrapi.com/sys/balance" \
  -H "x-access-key: $(cat ~/.secrets/hikerapi/api-key)"
# {"requests":N,"rate":8,"currency":"USD","amount":X.XX}

Typical scenarios

1. "Show the competitor's top-performing reels"

bash scripts/analyze.sh <username> 5 14

Script: HikerAPI → profile → reels → sort by engagement → result.

2. "Download this reel and tell me what it's about"

bash scripts/download.sh "<url>" transcribe

Cobalt downloads → Groq transcribes → agent analyzes.

3. "Add to monitoring"

bash scripts/watchlist.sh add <username>
bash scripts/watchlist.sh scan 3 14

4. "Full competitor breakdown"

  1. analyze.sh <username> 5 14 → top 5 reels + metrics
  2. download.sh <url> transcribe for each of the top 3
  3. Agent breaks down: hook → pain → solution → CTA

5. "What's going viral by hashtag"

HIKER_KEY=$(cat ~/.secrets/hikerapi/api-key)
# Получить hashtag_id
curl -s "https://api.instagrapi.com/v2/hashtag/by/name?name=aitools" -H "x-access-key: $HIKER_KEY"
# Топ-посты
curl -s "https://api.instagrapi.com/v2/hashtag/medias/top?hashtag_id=ID" -H "x-access-key: $HIKER_KEY"

Pagination

Many endpoints return next_page_id. For the next page:

curl -s "https://api.instagrapi.com/v2/user/clips?user_id=123&page_id=NEXT_PAGE_ID" \
  -H "x-access-key: $HIKER_KEY"

Reels: ~12 per page. For 50 reels you need ~4 requests.

Rate Limits

HikerAPI

  • Limit: 8 requests/second (Standard plan)
  • No risk of Instagram ban -- HikerAPI uses its own pool of accounts and proxies
  • Balance is checked by the command above (/sys/balance)

Cobalt (downloading)

  • Rate limits Instagram: 20 downloads/hour per 1 account
  • Pause between requests: minimum 3 seconds
  • Batch downloading (>5): pause 10-15 seconds
  • Strictly sequential, never parallel

Optimal strategy

  • Analytics (HikerAPI): no limits, up to 8 req/sec
  • Downloading (Cobalt): 20/hour, sequentially
  • HikerAPI can also download (/v1/media/download/*), but it uses paid requests -- use Cobalt

Maintenance

HikerAPI

# Баланс
curl -s "https://api.instagrapi.com/sys/balance" -H "x-access-key: $(cat ~/.secrets/hikerapi/api-key)"

# Ключ в дашборде: https://hikerapi.com → Tokens

Cobalt

# Статус
ssh $YOUR_SERVER_SSH "docker ps --filter name=cobalt-api --format '{{.Status}}'"

# Логи
ssh $YOUR_SERVER_SSH "docker logs cobalt-api --tail 20"

# Перезапуск
ssh $YOUR_SERVER_SSH "cd /opt/cobalt && docker compose restart cobalt-api"

Updating Instagram cookies (for Cobalt)

Detailed procedure: references/cookie-refresh.md

  1. Credentials: ~/.secrets/cobalt/accounts.json
  2. Chromium CDP: bash scripts/chromium-launch.sh start
  3. Login via Input.dispatchKeyEvent (character by character)
  4. Button: div[role="button"] (not <button type="submit">)
  5. 2FA: TOTP → input[name="verificationCode"]
  6. Cookies: Network.getCookies → .instagram.com → cookies.json
  7. Deploy: bash scripts/deploy-cookies.sh

Security

  • HikerAPI key: ~/.secrets/hikerapi/api-key (chmod 600)
  • Cobalt: ONLY 127.0.0.1:9000 on your server
  • Access to your server: via Tailscale SSH
  • Cookies/credentials: ONLY ~/.secrets/cobalt/ (chmod 600)
  • Prohibited: logging keys/cookies, outputting to chat, committing to git

Requirements for running

  1. HikerAPI key in ~/.secrets/hikerapi/api-key
  2. For downloading: self-hosted Cobalt + SSH access + Cobalt API key (env COBALT_SERVER=user@host)
  3. For transcription (optional): your own Whisper script (env WHISPER_SCRIPT=/path/to/whisper.sh)
  4. Skill in ~/.claude/skills/instagram-hikerapi/