You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Instagram通过用户名获取user_id的API端点已停用,求替代方法

Alternatives for Getting Instagram User ID from Username After v1 API Deprecation

Hey there! Sorry to hear the old https://api.instagram.com/v1/users/search endpoint got retired—Instagram's been tightening up their API access lately, so this change isn't totally unexpected. Here are your best options to get a user's ID from their username now:

This is the only compliant, long-term solution, though it requires some setup:

  • First, you'll need a Facebook Developer account and an app linked to an Instagram Business or Creator account.
  • You'll need a valid access token with required permissions (typically instagram_basic and pages_show_list for Page-linked tokens).
  • Use this endpoint:
    GET /ig_user_search?username={TARGET_USERNAME}&access_token={YOUR_VALID_ACCESS_TOKEN}
    
  • The response will return an array of matching users, each including the id field (your target user ID).

Important: This endpoint only works for Business/Creator accounts, and you can only search for users your app has permission to access (e.g., users following your linked Instagram account, or accounts you've been granted explicit access to).

2. Unofficial Web Scraping (Use with Extreme Caution)

Instagram's web interface exposes user IDs in hidden data, but this violates their Terms of Service and can lead to IP/account blocks:

  • Visit the user's profile page (https://www.instagram.com/{username}/), view the page source, and search for strings like profilePage_—the number immediately after this is usually the user ID.
  • Alternatively, append ?__a=1 to the profile URL (e.g., https://www.instagram.com/{username}/?__a=1) to fetch a raw JSON response. Look for the graphql.user.id field in the output.

Warning: Instagram actively targets scrapers, and this unofficial endpoint can break without notice. Only consider this for personal, non-commercial use (and even then, it's risky).

3. Third-Party Tools (Vet Carefully!)

Some third-party services offer user ID lookup by username, but proceed with caution:

  • Most rely on the same scraping methods mentioned above, so they carry the same risks of being blocked or shut down.
  • Always review the service's privacy policy—never share sensitive access tokens or user data with untrusted providers.
  • Many charge fees for higher volume or more reliable access.

Final Notes

  • Prioritize the official Graph API whenever possible—it's the only way to stay compliant with Instagram's rules and avoid account restrictions.
  • Make sure you understand Instagram's official platform policies before implementing any solution.

内容的提问来源于stack exchange,提问作者Nima

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 03:38:49