Instagram原公开数据JSON接口失效,求新接口或替代方案
?__a=1 Endpoint Replacement Solutions Hey there, sorry to hear that the old https://www.instagram.com/<username>/?__a=1 endpoint stopped working for you — Instagram has been tightening up their public API access over time, so this kind of breakage isn't unexpected. Here are some reliable alternatives you can explore:
1. Official Basic Display API (Recommended for Long-Term Projects)
This is Instagram's official, supported way to access public (and authorized private) user data. It requires a bit of setup, but it's the most stable option:
- First, create a Meta Developer account and register a new app.
- Submit your app for review if you need access to non-public user data (public data might be accessible without full review in some cases).
- Use endpoints like
GET /{user-id}/mediato fetch posts, orGET /{user-id}to retrieve basic user info. You'll need an access token to authenticate requests.
The biggest upside here is compliance with Instagram's terms of service — you won't risk getting your IP blocked or your access revoked unexpectedly.
2. Web-Based GraphQL API (For Personal/Small-Scale Use)
Instagram's web interface relies heavily on GraphQL to load content, and you can replicate these requests programmatically. Here's how it works:
- When you visit a user's profile in your browser, open the developer tools (Network tab) and look for requests to
https://www.instagram.com/graphql/query/. - You'll notice two key parameters:
query_hash(a fixed string that identifies the specific query being run) andvariables(a JSON object with parameters like the user's ID and number of posts to fetch). - Example request format:
Note: Query hashes can change without warning, so you'll need to periodically check and update them. Also, avoid making too many rapid requests — Instagram will rate-limit or block your IP if you do.https://www.instagram.com/graphql/query/?query_hash=e769aa130647d2354c40ea6a439bfc08&variables={"id":"123456789","first":20}
3. Third-Party Data Services
If you don't want to handle API setup or GraphQL maintenance, there are third-party services that wrap Instagram's data into easy-to-use APIs. These services handle authentication, rate-limiting, and query hash updates for you. Just make sure to choose a reputable provider that adheres to Instagram's terms to avoid any issues.
Important Notes
- Always follow Instagram's Terms of Service when accessing their data — unauthorized scraping or excessive requests can lead to account or IP bans.
- For production applications, the Official Basic Display API is the only sustainable choice.
内容的提问来源于stack exchange,提问作者Diego Mora Cespedes

