WORLDBOOK

Worldbooks | WebMCP | Search | Submit WebMCP

instagram WebMCP

Browser tool configuration for instagram

URL Pattern: ^https?://(www\.)?instagram\.com(/.*)?$
Allowed Extra Domains: instagram.com

Tools (7)

instagram_explore()

Instagram explore/discover trending posts

Parameters

limit number - Number of posts

JavaScript Handler

(params) => {
  const args = Object.assign({"limit": 20}, params || {});
  let data = null;
  let __wbContextUrl = globalThis.location?.href || '';
  let __wbContextDocument = globalThis.document || null;
    const __wbDefault = (value, fallback) => (value === undefined || value === null || value === '' ? fallback : value);
    const __wbJoin = (value, separator) => Array.isArray(value) ? value.join(separator) : (value ?? '');
    const __wbGet = (value, path) => {
      if (!path) return value;
      return String(path).split('.').reduce((acc, part) => (acc == null ? undefined : acc[part]), value);
    };
    const __wbBaseUrl = () => (__wbContextUrl || globalThis.location?.href || '');
    const __wbResolve = (target, base) => {
      if (target == null) return '';
      const text = String(target);
      try {
        if (/^https?:/i.test(text)) return text;
        const resolvedBase = base || __wbBaseUrl();
        return resolvedBase ? new URL(text, resolvedBase).toString() : text;
      } catch (_error) {
        return text;
      }
    };
    const __wbFetch = async (target, options) => {
      const url = __wbResolve(target, __wbBaseUrl());
      const resp = await globalThis.fetch(url, Object.assign({ credentials: 'include' }, options || {}));
      if (!resp.ok) {
        throw new Error(`HTTP ${resp.status} for ${url}`);
      }
      const text = await resp.text();
      try {
        return { url, text, data: JSON.parse(text) };
      } catch (_error) {
        return { url, text, data: text };
      }
    };
  return (async () => {
    {
      const __wbResp = await __wbFetch("https://www.instagram.com");
      __wbContextUrl = __wbResp.url;
      __wbContextDocument = new DOMParser().parseFromString(__wbResp.text, 'text/html');
      data = __wbContextDocument;
    }
    {
      const document = __wbContextDocument || globalThis.document;
      const location = new URL(__wbBaseUrl());
      const window = { document, location };
      const fetch = (target, options) => globalThis.fetch(__wbResolve(target, __wbBaseUrl()), Object.assign({ credentials: 'include' }, options || {}));
      data = await (((async () => {
  const limit = (args.limit);
  const res = await fetch(
    'https://www.instagram.com/api/v1/discover/web/explore_grid/',
    {
      credentials: 'include',
      headers: { 'X-IG-App-ID': '936619743392459' }
    }
  );
  if (!res.ok) throw new Error('HTTP ' + res.status + ' - make sure you are logged in to Instagram');
  const data = await res.json();
  const posts = [];
  for (const sec of (data?.sectional_items || [])) {
    for (const m of (sec?.layout_content?.medias || [])) {
      const media = m?.media;
      if (media) posts.push({
        user: media.user?.username || '',
        caption: (media.caption?.text || '').replace(/\n/g, ' ').substring(0, 100),
        likes: media.like_count ?? 0,
        comments: media.comment_count ?? 0,
        type: media.media_type === 1 ? 'photo' : media.media_type === 2 ? 'video' : 'carousel',
      });
    }
  }
  return posts.slice(0, limit).map((p, i) => ({ rank: i + 1, ...p }));
})())());
    }
    return data;
  })();
}

instagram_followers()

List followers of an Instagram user

Parameters

username string required - Instagram username
limit number - Number of followers

JavaScript Handler

(params) => {
  const args = Object.assign({"limit": 20}, params || {});
  let data = null;
  let __wbContextUrl = globalThis.location?.href || '';
  let __wbContextDocument = globalThis.document || null;
    const __wbDefault = (value, fallback) => (value === undefined || value === null || value === '' ? fallback : value);
    const __wbJoin = (value, separator) => Array.isArray(value) ? value.join(separator) : (value ?? '');
    const __wbGet = (value, path) => {
      if (!path) return value;
      return String(path).split('.').reduce((acc, part) => (acc == null ? undefined : acc[part]), value);
    };
    const __wbBaseUrl = () => (__wbContextUrl || globalThis.location?.href || '');
    const __wbResolve = (target, base) => {
      if (target == null) return '';
      const text = String(target);
      try {
        if (/^https?:/i.test(text)) return text;
        const resolvedBase = base || __wbBaseUrl();
        return resolvedBase ? new URL(text, resolvedBase).toString() : text;
      } catch (_error) {
        return text;
      }
    };
    const __wbFetch = async (target, options) => {
      const url = __wbResolve(target, __wbBaseUrl());
      const resp = await globalThis.fetch(url, Object.assign({ credentials: 'include' }, options || {}));
      if (!resp.ok) {
        throw new Error(`HTTP ${resp.status} for ${url}`);
      }
      const text = await resp.text();
      try {
        return { url, text, data: JSON.parse(text) };
      } catch (_error) {
        return { url, text, data: text };
      }
    };
  return (async () => {
    {
      const __wbResp = await __wbFetch("https://www.instagram.com");
      __wbContextUrl = __wbResp.url;
      __wbContextDocument = new DOMParser().parseFromString(__wbResp.text, 'text/html');
      data = __wbContextDocument;
    }
    {
      const document = __wbContextDocument || globalThis.document;
      const location = new URL(__wbBaseUrl());
      const window = { document, location };
      const fetch = (target, options) => globalThis.fetch(__wbResolve(target, __wbBaseUrl()), Object.assign({ credentials: 'include' }, options || {}));
      data = await (((async () => {
  const username = ((args.username));
  const limit = (args.limit);
  const headers = { 'X-IG-App-ID': '936619743392459' };
  const opts = { credentials: 'include', headers };

  const r1 = await fetch(
    'https://www.instagram.com/api/v1/users/web_profile_info/?username=' + encodeURIComponent(username),
    opts
  );
  if (!r1.ok) throw new Error('HTTP ' + r1.status + ' - make sure you are logged in to Instagram');
  const d1 = await r1.json();
  const userId = d1?.data?.user?.id;
  if (!userId) throw new Error('User not found: ' + username);

  const r2 = await fetch(
    'https://www.instagram.com/api/v1/friendships/' + userId + '/followers/?count=' + limit,
    opts
  );
  if (!r2.ok) throw new Error('Failed to fetch followers: HTTP ' + r2.status);
  const d2 = await r2.json();
  return (d2?.users || []).slice(0, limit).map((u, i) => ({
    rank: i + 1,
    username: u.username || '',
    name: u.full_name || '',
    verified: u.is_verified ? 'Yes' : 'No',
    private: u.is_private ? 'Yes' : 'No',
  }));
})())());
    }
    return data;
  })();
}

instagram_following()

List accounts an Instagram user is following

Parameters

username string required - Instagram username
limit number - Number of accounts

JavaScript Handler

(params) => {
  const args = Object.assign({"limit": 20}, params || {});
  let data = null;
  let __wbContextUrl = globalThis.location?.href || '';
  let __wbContextDocument = globalThis.document || null;
    const __wbDefault = (value, fallback) => (value === undefined || value === null || value === '' ? fallback : value);
    const __wbJoin = (value, separator) => Array.isArray(value) ? value.join(separator) : (value ?? '');
    const __wbGet = (value, path) => {
      if (!path) return value;
      return String(path).split('.').reduce((acc, part) => (acc == null ? undefined : acc[part]), value);
    };
    const __wbBaseUrl = () => (__wbContextUrl || globalThis.location?.href || '');
    const __wbResolve = (target, base) => {
      if (target == null) return '';
      const text = String(target);
      try {
        if (/^https?:/i.test(text)) return text;
        const resolvedBase = base || __wbBaseUrl();
        return resolvedBase ? new URL(text, resolvedBase).toString() : text;
      } catch (_error) {
        return text;
      }
    };
    const __wbFetch = async (target, options) => {
      const url = __wbResolve(target, __wbBaseUrl());
      const resp = await globalThis.fetch(url, Object.assign({ credentials: 'include' }, options || {}));
      if (!resp.ok) {
        throw new Error(`HTTP ${resp.status} for ${url}`);
      }
      const text = await resp.text();
      try {
        return { url, text, data: JSON.parse(text) };
      } catch (_error) {
        return { url, text, data: text };
      }
    };
  return (async () => {
    {
      const __wbResp = await __wbFetch("https://www.instagram.com");
      __wbContextUrl = __wbResp.url;
      __wbContextDocument = new DOMParser().parseFromString(__wbResp.text, 'text/html');
      data = __wbContextDocument;
    }
    {
      const document = __wbContextDocument || globalThis.document;
      const location = new URL(__wbBaseUrl());
      const window = { document, location };
      const fetch = (target, options) => globalThis.fetch(__wbResolve(target, __wbBaseUrl()), Object.assign({ credentials: 'include' }, options || {}));
      data = await (((async () => {
  const username = ((args.username));
  const limit = (args.limit);
  const headers = { 'X-IG-App-ID': '936619743392459' };
  const opts = { credentials: 'include', headers };

  const r1 = await fetch(
    'https://www.instagram.com/api/v1/users/web_profile_info/?username=' + encodeURIComponent(username),
    opts
  );
  if (!r1.ok) throw new Error('HTTP ' + r1.status + ' - make sure you are logged in to Instagram');
  const d1 = await r1.json();
  const userId = d1?.data?.user?.id;
  if (!userId) throw new Error('User not found: ' + username);

  const r2 = await fetch(
    'https://www.instagram.com/api/v1/friendships/' + userId + '/following/?count=' + limit,
    opts
  );
  if (!r2.ok) throw new Error('Failed to fetch following: HTTP ' + r2.status);
  const d2 = await r2.json();
  return (d2?.users || []).slice(0, limit).map((u, i) => ({
    rank: i + 1,
    username: u.username || '',
    name: u.full_name || '',
    verified: u.is_verified ? 'Yes' : 'No',
    private: u.is_private ? 'Yes' : 'No',
  }));
})())());
    }
    return data;
  })();
}

instagram_profile()

Get Instagram user profile info

Parameters

username string required - Instagram username

JavaScript Handler

(params) => {
  const args = Object.assign({}, params || {});
  let data = null;
  let __wbContextUrl = globalThis.location?.href || '';
  let __wbContextDocument = globalThis.document || null;
    const __wbDefault = (value, fallback) => (value === undefined || value === null || value === '' ? fallback : value);
    const __wbJoin = (value, separator) => Array.isArray(value) ? value.join(separator) : (value ?? '');
    const __wbGet = (value, path) => {
      if (!path) return value;
      return String(path).split('.').reduce((acc, part) => (acc == null ? undefined : acc[part]), value);
    };
    const __wbBaseUrl = () => (__wbContextUrl || globalThis.location?.href || '');
    const __wbResolve = (target, base) => {
      if (target == null) return '';
      const text = String(target);
      try {
        if (/^https?:/i.test(text)) return text;
        const resolvedBase = base || __wbBaseUrl();
        return resolvedBase ? new URL(text, resolvedBase).toString() : text;
      } catch (_error) {
        return text;
      }
    };
    const __wbFetch = async (target, options) => {
      const url = __wbResolve(target, __wbBaseUrl());
      const resp = await globalThis.fetch(url, Object.assign({ credentials: 'include' }, options || {}));
      if (!resp.ok) {
        throw new Error(`HTTP ${resp.status} for ${url}`);
      }
      const text = await resp.text();
      try {
        return { url, text, data: JSON.parse(text) };
      } catch (_error) {
        return { url, text, data: text };
      }
    };
  return (async () => {
    {
      const __wbResp = await __wbFetch("https://www.instagram.com");
      __wbContextUrl = __wbResp.url;
      __wbContextDocument = new DOMParser().parseFromString(__wbResp.text, 'text/html');
      data = __wbContextDocument;
    }
    {
      const document = __wbContextDocument || globalThis.document;
      const location = new URL(__wbBaseUrl());
      const window = { document, location };
      const fetch = (target, options) => globalThis.fetch(__wbResolve(target, __wbBaseUrl()), Object.assign({ credentials: 'include' }, options || {}));
      data = await (((async () => {
  const username = ((args.username));
  const res = await fetch(
    'https://www.instagram.com/api/v1/users/web_profile_info/?username=' + encodeURIComponent(username),
    {
      credentials: 'include',
      headers: { 'X-IG-App-ID': '936619743392459' }
    }
  );
  if (!res.ok) throw new Error('HTTP ' + res.status + ' - make sure you are logged in to Instagram');
  const data = await res.json();
  const u = data?.data?.user;
  if (!u) throw new Error('User not found: ' + username);
  return [{
    username: u.username,
    name: u.full_name || '',
    bio: (u.biography || '').replace(/\n/g, ' ').substring(0, 120),
    followers: u.edge_followed_by?.count ?? 0,
    following: u.edge_follow?.count ?? 0,
    posts: u.edge_owner_to_timeline_media?.count ?? 0,
    verified: u.is_verified ? 'Yes' : 'No',
    url: 'https://www.instagram.com/' + u.username,
  }];
})())());
    }
    return data;
  })();
}

instagram_saved()

Get your saved Instagram posts

Parameters

limit number - Number of saved posts

JavaScript Handler

(params) => {
  const args = Object.assign({"limit": 20}, params || {});
  let data = null;
  let __wbContextUrl = globalThis.location?.href || '';
  let __wbContextDocument = globalThis.document || null;
    const __wbDefault = (value, fallback) => (value === undefined || value === null || value === '' ? fallback : value);
    const __wbJoin = (value, separator) => Array.isArray(value) ? value.join(separator) : (value ?? '');
    const __wbGet = (value, path) => {
      if (!path) return value;
      return String(path).split('.').reduce((acc, part) => (acc == null ? undefined : acc[part]), value);
    };
    const __wbBaseUrl = () => (__wbContextUrl || globalThis.location?.href || '');
    const __wbResolve = (target, base) => {
      if (target == null) return '';
      const text = String(target);
      try {
        if (/^https?:/i.test(text)) return text;
        const resolvedBase = base || __wbBaseUrl();
        return resolvedBase ? new URL(text, resolvedBase).toString() : text;
      } catch (_error) {
        return text;
      }
    };
    const __wbFetch = async (target, options) => {
      const url = __wbResolve(target, __wbBaseUrl());
      const resp = await globalThis.fetch(url, Object.assign({ credentials: 'include' }, options || {}));
      if (!resp.ok) {
        throw new Error(`HTTP ${resp.status} for ${url}`);
      }
      const text = await resp.text();
      try {
        return { url, text, data: JSON.parse(text) };
      } catch (_error) {
        return { url, text, data: text };
      }
    };
  return (async () => {
    {
      const __wbResp = await __wbFetch("https://www.instagram.com");
      __wbContextUrl = __wbResp.url;
      __wbContextDocument = new DOMParser().parseFromString(__wbResp.text, 'text/html');
      data = __wbContextDocument;
    }
    {
      const document = __wbContextDocument || globalThis.document;
      const location = new URL(__wbBaseUrl());
      const window = { document, location };
      const fetch = (target, options) => globalThis.fetch(__wbResolve(target, __wbBaseUrl()), Object.assign({ credentials: 'include' }, options || {}));
      data = await (((async () => {
  const limit = (args.limit);
  const res = await fetch(
    'https://www.instagram.com/api/v1/feed/saved/posts/',
    {
      credentials: 'include',
      headers: { 'X-IG-App-ID': '936619743392459' }
    }
  );
  if (!res.ok) throw new Error('HTTP ' + res.status + ' - make sure you are logged in to Instagram');
  const data = await res.json();
  return (data?.items || []).slice(0, limit).map((item, i) => {
    const m = item?.media;
    return {
      index: i + 1,
      user: m?.user?.username || '',
      caption: (m?.caption?.text || '').replace(/\n/g, ' ').substring(0, 100),
      likes: m?.like_count ?? 0,
      comments: m?.comment_count ?? 0,
      type: m?.media_type === 1 ? 'photo' : m?.media_type === 2 ? 'video' : 'carousel',
    };
  });
})())());
    }
    return data;
  })();
}

instagram_search()

Search Instagram users

Parameters

query string required - Search query
limit number - Number of results

JavaScript Handler

instagram_user()

Get recent posts from an Instagram user

Parameters

username string required - Instagram username
limit number - Number of posts

JavaScript Handler

(params) => {
  const args = Object.assign({"limit": 12}, params || {});
  let data = null;
  let __wbContextUrl = globalThis.location?.href || '';
  let __wbContextDocument = globalThis.document || null;
    const __wbDefault = (value, fallback) => (value === undefined || value === null || value === '' ? fallback : value);
    const __wbJoin = (value, separator) => Array.isArray(value) ? value.join(separator) : (value ?? '');
    const __wbGet = (value, path) => {
      if (!path) return value;
      return String(path).split('.').reduce((acc, part) => (acc == null ? undefined : acc[part]), value);
    };
    const __wbBaseUrl = () => (__wbContextUrl || globalThis.location?.href || '');
    const __wbResolve = (target, base) => {
      if (target == null) return '';
      const text = String(target);
      try {
        if (/^https?:/i.test(text)) return text;
        const resolvedBase = base || __wbBaseUrl();
        return resolvedBase ? new URL(text, resolvedBase).toString() : text;
      } catch (_error) {
        return text;
      }
    };
    const __wbFetch = async (target, options) => {
      const url = __wbResolve(target, __wbBaseUrl());
      const resp = await globalThis.fetch(url, Object.assign({ credentials: 'include' }, options || {}));
      if (!resp.ok) {
        throw new Error(`HTTP ${resp.status} for ${url}`);
      }
      const text = await resp.text();
      try {
        return { url, text, data: JSON.parse(text) };
      } catch (_error) {
        return { url, text, data: text };
      }
    };
  return (async () => {
    {
      const __wbResp = await __wbFetch("https://www.instagram.com");
      __wbContextUrl = __wbResp.url;
      __wbContextDocument = new DOMParser().parseFromString(__wbResp.text, 'text/html');
      data = __wbContextDocument;
    }
    {
      const document = __wbContextDocument || globalThis.document;
      const location = new URL(__wbBaseUrl());
      const window = { document, location };
      const fetch = (target, options) => globalThis.fetch(__wbResolve(target, __wbBaseUrl()), Object.assign({ credentials: 'include' }, options || {}));
      data = await (((async () => {
  const username = ((args.username));
  const limit = (args.limit);
  const headers = { 'X-IG-App-ID': '936619743392459' };
  const opts = { credentials: 'include', headers };

  // Get user ID first
  const r1 = await fetch(
    'https://www.instagram.com/api/v1/users/web_profile_info/?username=' + encodeURIComponent(username),
    opts
  );
  if (!r1.ok) throw new Error('HTTP ' + r1.status + ' - make sure you are logged in to Instagram');
  const d1 = await r1.json();
  const userId = d1?.data?.user?.id;
  if (!userId) throw new Error('User not found: ' + username);

  // Get user feed
  const r2 = await fetch(
    'https://www.instagram.com/api/v1/feed/user/' + userId + '/?count=' + limit,
    opts
  );
  if (!r2.ok) throw new Error('Failed to fetch user feed: HTTP ' + r2.status);
  const d2 = await r2.json();
  return (d2?.items || []).slice(0, limit).map((p, i) => ({
    index: i + 1,
    caption: (p.caption?.text || '').replace(/\n/g, ' ').substring(0, 100),
    likes: p.like_count ?? 0,
    comments: p.comment_count ?? 0,
    type: p.media_type === 1 ? 'photo' : p.media_type === 2 ? 'video' : 'carousel',
    date: p.taken_at ? new Date(p.taken_at * 1000).toLocaleDateString() : '',
  }));
})())());
    }
    return data;
  })();
}

🔌 Chrome MCP Server Extension

Use these tools with Claude, ChatGPT, and other AI assistants.

Get Extension →

How to Use WebMCP

WebMCP tools are designed for browser extensions or automation frameworks. The browser extension matches the current URL against the pattern and executes the JavaScript handler when the tool is invoked.

API Endpoint:

GET /api/webmcp/match?url=https://www.instagram.com/...