Instagram API for Node.js

Instagram API for Node.js Developers

HikerAPI is a REST API that works with any HTTP client. For Node.js, use the built-in fetch (Node 18+) or axios.

Installation

npm install axios
# or use built-in fetch (Node 18+)

Quick Start with fetch

const API_KEY = "your_access_key";
const BASE = "https://api.hikerapi.com";

async function getUser(username) {
  const resp = await fetch(
    `${BASE}/v1/user/by/username?username=${username}`,
    { headers: { "x-access-key": API_KEY } }
  );
  return resp.json();
}

const user = await getUser("instagram");
console.log(`Followers: ${user.follower_count.toLocaleString()}`);

With axios

const axios = require("axios");

const api = axios.create({
  baseURL: "https://api.hikerapi.com",
  headers: { "x-access-key": "your_access_key" },
});

// Get user profile
const { data: user } = await api.get("/v1/user/by/username", {
  params: { username: "instagram" },
});

// Get user posts
const { data: posts } = await api.get("/v1/user/medias/chunk", {
  params: { user_id: user.pk },
});

posts.items.forEach((post) => {
  console.log(`${post.caption_text?.slice(0, 80)}${post.like_count} likes`);
});

Concurrent Requests

const usernames = ["instagram", "nike", "natgeo", "nasa", "spotify"];

const profiles = await Promise.all(
  usernames.map((username) =>
    fetch(`${BASE}/v1/user/by/username?username=${username}`, {
      headers: { "x-access-key": API_KEY },
    }).then((r) => r.json())
  )
);

profiles.forEach((p) => {
  console.log(`${p.username}: ${p.follower_count.toLocaleString()} followers`);
});

Pagination — Get All Followers

async function getAllFollowers(userId) {
  const followers = [];
  let maxId = null;

  while (true) {
    const params = new URLSearchParams({ user_id: userId });
    if (maxId) params.set("max_id", maxId);

    const resp = await fetch(`${BASE}/v1/user/followers/chunk?${params}`, {
      headers: { "x-access-key": API_KEY },
    });
    const data = await resp.json();

    followers.push(...data.users);
    maxId = data.next_max_id;

    if (!maxId) break;
  }

  return followers;
}

TypeScript

HikerAPI returns JSON — define your own interfaces:

interface InstagramUser {
  pk: number;
  username: string;
  full_name: string;
  follower_count: number;
  media_count: number;
  biography: string;
}

const resp = await fetch(`${BASE}/v1/user/by/username?username=instagram`, {
  headers: { "x-access-key": API_KEY },
});
const user: InstagramUser = await resp.json();

FAQ

Does HikerAPI have a Node.js SDK?
Not yet. Use fetch or axios — it's a standard REST API with JSON responses.

What Node.js version do I need?
Node 18+ for built-in fetch. Any version works with axios.

Getting Started

  1. npm install axios (or use built-in fetch)
  2. Register for an API key
  3. API docs — all 147+ endpoints

Ready to get started?

100 free API requests. No credit card required.

Sign Up Free