{"url_pattern":"^https?://(www\\.)?instagram\\.com(/.*)?$","site_name":"instagram","allowed_domains":["instagram.com"],"tools":[{"name":"instagram_explore","description":"Instagram explore/discover trending posts","inputSchema":{"type":"object","properties":{"limit":{"type":"number","description":"Number of posts","default":20}},"required":null},"handler":"(params) => {\n  const args = Object.assign({\"limit\": 20}, params || {});\n  let data = null;\n  let __wbContextUrl = globalThis.location?.href || '';\n  let __wbContextDocument = globalThis.document || null;\n    const __wbDefault = (value, fallback) => (value === undefined || value === null || value === '' ? fallback : value);\n    const __wbJoin = (value, separator) => Array.isArray(value) ? value.join(separator) : (value ?? '');\n    const __wbGet = (value, path) => {\n      if (!path) return value;\n      return String(path).split('.').reduce((acc, part) => (acc == null ? undefined : acc[part]), value);\n    };\n    const __wbBaseUrl = () => (__wbContextUrl || globalThis.location?.href || '');\n    const __wbResolve = (target, base) => {\n      if (target == null) return '';\n      const text = String(target);\n      try {\n        if (/^https?:/i.test(text)) return text;\n        const resolvedBase = base || __wbBaseUrl();\n        return resolvedBase ? new URL(text, resolvedBase).toString() : text;\n      } catch (_error) {\n        return text;\n      }\n    };\n    const __wbFetch = async (target, options) => {\n      const url = __wbResolve(target, __wbBaseUrl());\n      const resp = await globalThis.fetch(url, Object.assign({ credentials: 'include' }, options || {}));\n      if (!resp.ok) {\n        throw new Error(`HTTP ${resp.status} for ${url}`);\n      }\n      const text = await resp.text();\n      try {\n        return { url, text, data: JSON.parse(text) };\n      } catch (_error) {\n        return { url, text, data: text };\n      }\n    };\n  return (async () => {\n    {\n      const __wbResp = await __wbFetch(\"https://www.instagram.com\");\n      __wbContextUrl = __wbResp.url;\n      __wbContextDocument = new DOMParser().parseFromString(__wbResp.text, 'text/html');\n      data = __wbContextDocument;\n    }\n    {\n      const document = __wbContextDocument || globalThis.document;\n      const location = new URL(__wbBaseUrl());\n      const window = { document, location };\n      const fetch = (target, options) => globalThis.fetch(__wbResolve(target, __wbBaseUrl()), Object.assign({ credentials: 'include' }, options || {}));\n      data = await (((async () => {\n  const limit = (args.limit);\n  const res = await fetch(\n    'https://www.instagram.com/api/v1/discover/web/explore_grid/',\n    {\n      credentials: 'include',\n      headers: { 'X-IG-App-ID': '936619743392459' }\n    }\n  );\n  if (!res.ok) throw new Error('HTTP ' + res.status + ' - make sure you are logged in to Instagram');\n  const data = await res.json();\n  const posts = [];\n  for (const sec of (data?.sectional_items || [])) {\n    for (const m of (sec?.layout_content?.medias || [])) {\n      const media = m?.media;\n      if (media) posts.push({\n        user: media.user?.username || '',\n        caption: (media.caption?.text || '').replace(/\\n/g, ' ').substring(0, 100),\n        likes: media.like_count ?? 0,\n        comments: media.comment_count ?? 0,\n        type: media.media_type === 1 ? 'photo' : media.media_type === 2 ? 'video' : 'carousel',\n      });\n    }\n  }\n  return posts.slice(0, limit).map((p, i) => ({ rank: i + 1, ...p }));\n})())());\n    }\n    return data;\n  })();\n}"},{"name":"instagram_followers","description":"List followers of an Instagram user","inputSchema":{"type":"object","properties":{"username":{"type":"string","description":"Instagram username"},"limit":{"type":"number","description":"Number of followers","default":20}},"required":["username"]},"handler":"(params) => {\n  const args = Object.assign({\"limit\": 20}, params || {});\n  let data = null;\n  let __wbContextUrl = globalThis.location?.href || '';\n  let __wbContextDocument = globalThis.document || null;\n    const __wbDefault = (value, fallback) => (value === undefined || value === null || value === '' ? fallback : value);\n    const __wbJoin = (value, separator) => Array.isArray(value) ? value.join(separator) : (value ?? '');\n    const __wbGet = (value, path) => {\n      if (!path) return value;\n      return String(path).split('.').reduce((acc, part) => (acc == null ? undefined : acc[part]), value);\n    };\n    const __wbBaseUrl = () => (__wbContextUrl || globalThis.location?.href || '');\n    const __wbResolve = (target, base) => {\n      if (target == null) return '';\n      const text = String(target);\n      try {\n        if (/^https?:/i.test(text)) return text;\n        const resolvedBase = base || __wbBaseUrl();\n        return resolvedBase ? new URL(text, resolvedBase).toString() : text;\n      } catch (_error) {\n        return text;\n      }\n    };\n    const __wbFetch = async (target, options) => {\n      const url = __wbResolve(target, __wbBaseUrl());\n      const resp = await globalThis.fetch(url, Object.assign({ credentials: 'include' }, options || {}));\n      if (!resp.ok) {\n        throw new Error(`HTTP ${resp.status} for ${url}`);\n      }\n      const text = await resp.text();\n      try {\n        return { url, text, data: JSON.parse(text) };\n      } catch (_error) {\n        return { url, text, data: text };\n      }\n    };\n  return (async () => {\n    {\n      const __wbResp = await __wbFetch(\"https://www.instagram.com\");\n      __wbContextUrl = __wbResp.url;\n      __wbContextDocument = new DOMParser().parseFromString(__wbResp.text, 'text/html');\n      data = __wbContextDocument;\n    }\n    {\n      const document = __wbContextDocument || globalThis.document;\n      const location = new URL(__wbBaseUrl());\n      const window = { document, location };\n      const fetch = (target, options) => globalThis.fetch(__wbResolve(target, __wbBaseUrl()), Object.assign({ credentials: 'include' }, options || {}));\n      data = await (((async () => {\n  const username = ((args.username));\n  const limit = (args.limit);\n  const headers = { 'X-IG-App-ID': '936619743392459' };\n  const opts = { credentials: 'include', headers };\n\n  const r1 = await fetch(\n    'https://www.instagram.com/api/v1/users/web_profile_info/?username=' + encodeURIComponent(username),\n    opts\n  );\n  if (!r1.ok) throw new Error('HTTP ' + r1.status + ' - make sure you are logged in to Instagram');\n  const d1 = await r1.json();\n  const userId = d1?.data?.user?.id;\n  if (!userId) throw new Error('User not found: ' + username);\n\n  const r2 = await fetch(\n    'https://www.instagram.com/api/v1/friendships/' + userId + '/followers/?count=' + limit,\n    opts\n  );\n  if (!r2.ok) throw new Error('Failed to fetch followers: HTTP ' + r2.status);\n  const d2 = await r2.json();\n  return (d2?.users || []).slice(0, limit).map((u, i) => ({\n    rank: i + 1,\n    username: u.username || '',\n    name: u.full_name || '',\n    verified: u.is_verified ? 'Yes' : 'No',\n    private: u.is_private ? 'Yes' : 'No',\n  }));\n})())());\n    }\n    return data;\n  })();\n}"},{"name":"instagram_following","description":"List accounts an Instagram user is following","inputSchema":{"type":"object","properties":{"username":{"type":"string","description":"Instagram username"},"limit":{"type":"number","description":"Number of accounts","default":20}},"required":["username"]},"handler":"(params) => {\n  const args = Object.assign({\"limit\": 20}, params || {});\n  let data = null;\n  let __wbContextUrl = globalThis.location?.href || '';\n  let __wbContextDocument = globalThis.document || null;\n    const __wbDefault = (value, fallback) => (value === undefined || value === null || value === '' ? fallback : value);\n    const __wbJoin = (value, separator) => Array.isArray(value) ? value.join(separator) : (value ?? '');\n    const __wbGet = (value, path) => {\n      if (!path) return value;\n      return String(path).split('.').reduce((acc, part) => (acc == null ? undefined : acc[part]), value);\n    };\n    const __wbBaseUrl = () => (__wbContextUrl || globalThis.location?.href || '');\n    const __wbResolve = (target, base) => {\n      if (target == null) return '';\n      const text = String(target);\n      try {\n        if (/^https?:/i.test(text)) return text;\n        const resolvedBase = base || __wbBaseUrl();\n        return resolvedBase ? new URL(text, resolvedBase).toString() : text;\n      } catch (_error) {\n        return text;\n      }\n    };\n    const __wbFetch = async (target, options) => {\n      const url = __wbResolve(target, __wbBaseUrl());\n      const resp = await globalThis.fetch(url, Object.assign({ credentials: 'include' }, options || {}));\n      if (!resp.ok) {\n        throw new Error(`HTTP ${resp.status} for ${url}`);\n      }\n      const text = await resp.text();\n      try {\n        return { url, text, data: JSON.parse(text) };\n      } catch (_error) {\n        return { url, text, data: text };\n      }\n    };\n  return (async () => {\n    {\n      const __wbResp = await __wbFetch(\"https://www.instagram.com\");\n      __wbContextUrl = __wbResp.url;\n      __wbContextDocument = new DOMParser().parseFromString(__wbResp.text, 'text/html');\n      data = __wbContextDocument;\n    }\n    {\n      const document = __wbContextDocument || globalThis.document;\n      const location = new URL(__wbBaseUrl());\n      const window = { document, location };\n      const fetch = (target, options) => globalThis.fetch(__wbResolve(target, __wbBaseUrl()), Object.assign({ credentials: 'include' }, options || {}));\n      data = await (((async () => {\n  const username = ((args.username));\n  const limit = (args.limit);\n  const headers = { 'X-IG-App-ID': '936619743392459' };\n  const opts = { credentials: 'include', headers };\n\n  const r1 = await fetch(\n    'https://www.instagram.com/api/v1/users/web_profile_info/?username=' + encodeURIComponent(username),\n    opts\n  );\n  if (!r1.ok) throw new Error('HTTP ' + r1.status + ' - make sure you are logged in to Instagram');\n  const d1 = await r1.json();\n  const userId = d1?.data?.user?.id;\n  if (!userId) throw new Error('User not found: ' + username);\n\n  const r2 = await fetch(\n    'https://www.instagram.com/api/v1/friendships/' + userId + '/following/?count=' + limit,\n    opts\n  );\n  if (!r2.ok) throw new Error('Failed to fetch following: HTTP ' + r2.status);\n  const d2 = await r2.json();\n  return (d2?.users || []).slice(0, limit).map((u, i) => ({\n    rank: i + 1,\n    username: u.username || '',\n    name: u.full_name || '',\n    verified: u.is_verified ? 'Yes' : 'No',\n    private: u.is_private ? 'Yes' : 'No',\n  }));\n})())());\n    }\n    return data;\n  })();\n}"},{"name":"instagram_profile","description":"Get Instagram user profile info","inputSchema":{"type":"object","properties":{"username":{"type":"string","description":"Instagram username"}},"required":["username"]},"handler":"(params) => {\n  const args = Object.assign({}, params || {});\n  let data = null;\n  let __wbContextUrl = globalThis.location?.href || '';\n  let __wbContextDocument = globalThis.document || null;\n    const __wbDefault = (value, fallback) => (value === undefined || value === null || value === '' ? fallback : value);\n    const __wbJoin = (value, separator) => Array.isArray(value) ? value.join(separator) : (value ?? '');\n    const __wbGet = (value, path) => {\n      if (!path) return value;\n      return String(path).split('.').reduce((acc, part) => (acc == null ? undefined : acc[part]), value);\n    };\n    const __wbBaseUrl = () => (__wbContextUrl || globalThis.location?.href || '');\n    const __wbResolve = (target, base) => {\n      if (target == null) return '';\n      const text = String(target);\n      try {\n        if (/^https?:/i.test(text)) return text;\n        const resolvedBase = base || __wbBaseUrl();\n        return resolvedBase ? new URL(text, resolvedBase).toString() : text;\n      } catch (_error) {\n        return text;\n      }\n    };\n    const __wbFetch = async (target, options) => {\n      const url = __wbResolve(target, __wbBaseUrl());\n      const resp = await globalThis.fetch(url, Object.assign({ credentials: 'include' }, options || {}));\n      if (!resp.ok) {\n        throw new Error(`HTTP ${resp.status} for ${url}`);\n      }\n      const text = await resp.text();\n      try {\n        return { url, text, data: JSON.parse(text) };\n      } catch (_error) {\n        return { url, text, data: text };\n      }\n    };\n  return (async () => {\n    {\n      const __wbResp = await __wbFetch(\"https://www.instagram.com\");\n      __wbContextUrl = __wbResp.url;\n      __wbContextDocument = new DOMParser().parseFromString(__wbResp.text, 'text/html');\n      data = __wbContextDocument;\n    }\n    {\n      const document = __wbContextDocument || globalThis.document;\n      const location = new URL(__wbBaseUrl());\n      const window = { document, location };\n      const fetch = (target, options) => globalThis.fetch(__wbResolve(target, __wbBaseUrl()), Object.assign({ credentials: 'include' }, options || {}));\n      data = await (((async () => {\n  const username = ((args.username));\n  const res = await fetch(\n    'https://www.instagram.com/api/v1/users/web_profile_info/?username=' + encodeURIComponent(username),\n    {\n      credentials: 'include',\n      headers: { 'X-IG-App-ID': '936619743392459' }\n    }\n  );\n  if (!res.ok) throw new Error('HTTP ' + res.status + ' - make sure you are logged in to Instagram');\n  const data = await res.json();\n  const u = data?.data?.user;\n  if (!u) throw new Error('User not found: ' + username);\n  return [{\n    username: u.username,\n    name: u.full_name || '',\n    bio: (u.biography || '').replace(/\\n/g, ' ').substring(0, 120),\n    followers: u.edge_followed_by?.count ?? 0,\n    following: u.edge_follow?.count ?? 0,\n    posts: u.edge_owner_to_timeline_media?.count ?? 0,\n    verified: u.is_verified ? 'Yes' : 'No',\n    url: 'https://www.instagram.com/' + u.username,\n  }];\n})())());\n    }\n    return data;\n  })();\n}"},{"name":"instagram_saved","description":"Get your saved Instagram posts","inputSchema":{"type":"object","properties":{"limit":{"type":"number","description":"Number of saved posts","default":20}},"required":null},"handler":"(params) => {\n  const args = Object.assign({\"limit\": 20}, params || {});\n  let data = null;\n  let __wbContextUrl = globalThis.location?.href || '';\n  let __wbContextDocument = globalThis.document || null;\n    const __wbDefault = (value, fallback) => (value === undefined || value === null || value === '' ? fallback : value);\n    const __wbJoin = (value, separator) => Array.isArray(value) ? value.join(separator) : (value ?? '');\n    const __wbGet = (value, path) => {\n      if (!path) return value;\n      return String(path).split('.').reduce((acc, part) => (acc == null ? undefined : acc[part]), value);\n    };\n    const __wbBaseUrl = () => (__wbContextUrl || globalThis.location?.href || '');\n    const __wbResolve = (target, base) => {\n      if (target == null) return '';\n      const text = String(target);\n      try {\n        if (/^https?:/i.test(text)) return text;\n        const resolvedBase = base || __wbBaseUrl();\n        return resolvedBase ? new URL(text, resolvedBase).toString() : text;\n      } catch (_error) {\n        return text;\n      }\n    };\n    const __wbFetch = async (target, options) => {\n      const url = __wbResolve(target, __wbBaseUrl());\n      const resp = await globalThis.fetch(url, Object.assign({ credentials: 'include' }, options || {}));\n      if (!resp.ok) {\n        throw new Error(`HTTP ${resp.status} for ${url}`);\n      }\n      const text = await resp.text();\n      try {\n        return { url, text, data: JSON.parse(text) };\n      } catch (_error) {\n        return { url, text, data: text };\n      }\n    };\n  return (async () => {\n    {\n      const __wbResp = await __wbFetch(\"https://www.instagram.com\");\n      __wbContextUrl = __wbResp.url;\n      __wbContextDocument = new DOMParser().parseFromString(__wbResp.text, 'text/html');\n      data = __wbContextDocument;\n    }\n    {\n      const document = __wbContextDocument || globalThis.document;\n      const location = new URL(__wbBaseUrl());\n      const window = { document, location };\n      const fetch = (target, options) => globalThis.fetch(__wbResolve(target, __wbBaseUrl()), Object.assign({ credentials: 'include' }, options || {}));\n      data = await (((async () => {\n  const limit = (args.limit);\n  const res = await fetch(\n    'https://www.instagram.com/api/v1/feed/saved/posts/',\n    {\n      credentials: 'include',\n      headers: { 'X-IG-App-ID': '936619743392459' }\n    }\n  );\n  if (!res.ok) throw new Error('HTTP ' + res.status + ' - make sure you are logged in to Instagram');\n  const data = await res.json();\n  return (data?.items || []).slice(0, limit).map((item, i) => {\n    const m = item?.media;\n    return {\n      index: i + 1,\n      user: m?.user?.username || '',\n      caption: (m?.caption?.text || '').replace(/\\n/g, ' ').substring(0, 100),\n      likes: m?.like_count ?? 0,\n      comments: m?.comment_count ?? 0,\n      type: m?.media_type === 1 ? 'photo' : m?.media_type === 2 ? 'video' : 'carousel',\n    };\n  });\n})())());\n    }\n    return data;\n  })();\n}"},{"name":"instagram_search","description":"Search Instagram users","inputSchema":{"type":"object","properties":{"query":{"type":"string","description":"Search query"},"limit":{"type":"number","description":"Number of results","default":10}},"required":["query"]},"handler":"(params) => {\n  const args = Object.assign({\"limit\": 10}, params || {});\n  let data = null;\n  let __wbContextUrl = globalThis.location?.href || '';\n  let __wbContextDocument = globalThis.document || null;\n    const __wbDefault = (value, fallback) => (value === undefined || value === null || value === '' ? fallback : value);\n    const __wbJoin = (value, separator) => Array.isArray(value) ? value.join(separator) : (value ?? '');\n    const __wbGet = (value, path) => {\n      if (!path) return value;\n      return String(path).split('.').reduce((acc, part) => (acc == null ? undefined : acc[part]), value);\n    };\n    const __wbBaseUrl = () => (__wbContextUrl || globalThis.location?.href || '');\n    const __wbResolve = (target, base) => {\n      if (target == null) return '';\n      const text = String(target);\n      try {\n        if (/^https?:/i.test(text)) return text;\n        const resolvedBase = base || __wbBaseUrl();\n        return resolvedBase ? new URL(text, resolvedBase).toString() : text;\n      } catch (_error) {\n        return text;\n      }\n    };\n    const __wbFetch = async (target, options) => {\n      const url = __wbResolve(target, __wbBaseUrl());\n      const resp = await globalThis.fetch(url, Object.assign({ credentials: 'include' }, options || {}));\n      if (!resp.ok) {\n        throw new Error(`HTTP ${resp.status} for ${url}`);\n      }\n      const text = await resp.text();\n      try {\n        return { url, text, data: JSON.parse(text) };\n      } catch (_error) {\n        return { url, text, data: text };\n      }\n    };\n  return (async () => {\n    {\n      const __wbResp = await __wbFetch(\"https://www.instagram.com\");\n      __wbContextUrl = __wbResp.url;\n      __wbContextDocument = new DOMParser().parseFromString(__wbResp.text, 'text/html');\n      data = __wbContextDocument;\n    }\n    {\n      const document = __wbContextDocument || globalThis.document;\n      const location = new URL(__wbBaseUrl());\n      const window = { document, location };\n      const fetch = (target, options) => globalThis.fetch(__wbResolve(target, __wbBaseUrl()), Object.assign({ credentials: 'include' }, options || {}));\n      data = await (((async () => {\n  const query = ((args.query));\n  const limit = (args.limit);\n  const res = await fetch(\n    'https://www.instagram.com/web/search/topsearch/?query=' + encodeURIComponent(query) + '&context=user',\n    {\n      credentials: 'include',\n      headers: { 'X-IG-App-ID': '936619743392459' }\n    }\n  );\n  if (!res.ok) throw new Error('HTTP ' + res.status + ' - make sure you are logged in to Instagram');\n  const data = await res.json();\n  const users = (data?.users || []).slice(0, limit);\n  return users.map((item, i) => ({\n    rank: i + 1,\n    username: item.user?.username || '',\n    name: item.user?.full_name || '',\n    verified: item.user?.is_verified ? 'Yes' : 'No',\n    private: item.user?.is_private ? 'Yes' : 'No',\n    url: 'https://www.instagram.com/' + (item.user?.username || ''),\n  }));\n})())());\n    }\n    return data;\n  })();\n}"},{"name":"instagram_user","description":"Get recent posts from an Instagram user","inputSchema":{"type":"object","properties":{"username":{"type":"string","description":"Instagram username"},"limit":{"type":"number","description":"Number of posts","default":12}},"required":["username"]},"handler":"(params) => {\n  const args = Object.assign({\"limit\": 12}, params || {});\n  let data = null;\n  let __wbContextUrl = globalThis.location?.href || '';\n  let __wbContextDocument = globalThis.document || null;\n    const __wbDefault = (value, fallback) => (value === undefined || value === null || value === '' ? fallback : value);\n    const __wbJoin = (value, separator) => Array.isArray(value) ? value.join(separator) : (value ?? '');\n    const __wbGet = (value, path) => {\n      if (!path) return value;\n      return String(path).split('.').reduce((acc, part) => (acc == null ? undefined : acc[part]), value);\n    };\n    const __wbBaseUrl = () => (__wbContextUrl || globalThis.location?.href || '');\n    const __wbResolve = (target, base) => {\n      if (target == null) return '';\n      const text = String(target);\n      try {\n        if (/^https?:/i.test(text)) return text;\n        const resolvedBase = base || __wbBaseUrl();\n        return resolvedBase ? new URL(text, resolvedBase).toString() : text;\n      } catch (_error) {\n        return text;\n      }\n    };\n    const __wbFetch = async (target, options) => {\n      const url = __wbResolve(target, __wbBaseUrl());\n      const resp = await globalThis.fetch(url, Object.assign({ credentials: 'include' }, options || {}));\n      if (!resp.ok) {\n        throw new Error(`HTTP ${resp.status} for ${url}`);\n      }\n      const text = await resp.text();\n      try {\n        return { url, text, data: JSON.parse(text) };\n      } catch (_error) {\n        return { url, text, data: text };\n      }\n    };\n  return (async () => {\n    {\n      const __wbResp = await __wbFetch(\"https://www.instagram.com\");\n      __wbContextUrl = __wbResp.url;\n      __wbContextDocument = new DOMParser().parseFromString(__wbResp.text, 'text/html');\n      data = __wbContextDocument;\n    }\n    {\n      const document = __wbContextDocument || globalThis.document;\n      const location = new URL(__wbBaseUrl());\n      const window = { document, location };\n      const fetch = (target, options) => globalThis.fetch(__wbResolve(target, __wbBaseUrl()), Object.assign({ credentials: 'include' }, options || {}));\n      data = await (((async () => {\n  const username = ((args.username));\n  const limit = (args.limit);\n  const headers = { 'X-IG-App-ID': '936619743392459' };\n  const opts = { credentials: 'include', headers };\n\n  // Get user ID first\n  const r1 = await fetch(\n    'https://www.instagram.com/api/v1/users/web_profile_info/?username=' + encodeURIComponent(username),\n    opts\n  );\n  if (!r1.ok) throw new Error('HTTP ' + r1.status + ' - make sure you are logged in to Instagram');\n  const d1 = await r1.json();\n  const userId = d1?.data?.user?.id;\n  if (!userId) throw new Error('User not found: ' + username);\n\n  // Get user feed\n  const r2 = await fetch(\n    'https://www.instagram.com/api/v1/feed/user/' + userId + '/?count=' + limit,\n    opts\n  );\n  if (!r2.ok) throw new Error('Failed to fetch user feed: HTTP ' + r2.status);\n  const d2 = await r2.json();\n  return (d2?.items || []).slice(0, limit).map((p, i) => ({\n    index: i + 1,\n    caption: (p.caption?.text || '').replace(/\\n/g, ' ').substring(0, 100),\n    likes: p.like_count ?? 0,\n    comments: p.comment_count ?? 0,\n    type: p.media_type === 1 ? 'photo' : p.media_type === 2 ? 'video' : 'carousel',\n    date: p.taken_at ? new Date(p.taken_at * 1000).toLocaleDateString() : '',\n  }));\n})())());\n    }\n    return data;\n  })();\n}"}]}