Instagram Private API icon

Instagram Private API

Interact with Instagram using the private API

Overview

The Instagram Private API node for n8n allows you to interact with Instagram using its private API. Specifically, the Get User Feed operation retrieves the feed (recent posts) of a specified Instagram user by their User ID. This is useful for automation scenarios where you need to monitor, analyze, or archive the content posted by a particular user.

Practical examples:

  • Automatically collect and process posts from a specific influencer or brand.
  • Monitor competitor activity by fetching their latest posts.
  • Archive your own or another user's Instagram feed for compliance or backup purposes.

Properties

Display Name Type Description
User ID String User ID to get information for. This is required to specify which user's feed should be retrieved.

Output

The output is a JSON object with the following structure:

{
  "success": true,
  "userId": "<provided User ID>",
  "sessionData": { /* session data object */ },
  "userFeed": [ /* array of post objects as returned by Instagram's private API */ ]
}
  • success: Boolean indicating if the operation was successful.
  • userId: The User ID for which the feed was fetched.
  • sessionData: Session information used for authentication (can be ignored unless you need to persist sessions).
  • userFeed: An array containing the user's feed items (posts). Each item contains details about an individual post, such as media URLs, captions, timestamps, etc., as provided by Instagram's private API.

If an error occurs (e.g., missing User ID), the output will include an error message:

{
  "success": false,
  "error": "User ID is required"
}

Dependencies

  • External Service: Requires access to Instagram via the instagram-private-api library.
  • Credentials: You must provide valid Instagram credentials (username, password, and optionally session data) in n8n's credential system under instagramPrivateApi.
  • File System Access: The node stores session data in the .n8n/instagram-sessions directory within the home folder of the running user.

Troubleshooting

Common Issues:

  • Missing User ID: If the User ID property is not provided, the node will throw an error: "User ID is required".
  • Authentication Errors: If Instagram credentials are incorrect or expired, you may see errors like "Failed to authenticate with Instagram. Please check your credentials."
  • Session Expiry: If the session data is invalid or expired, the node will attempt to re-authenticate. If this fails, you'll receive an authentication error.
  • Checkpoint Required: If Instagram requires additional verification, you may see: "Checkpoint required. Please verify your account."
  • Account Restrictions: If the target user cannot be found or accessed, you may see: "User with ID \"<id>\" not found or cannot be messaged."

How to resolve:

  • Double-check that the User ID is correct and not empty.
  • Ensure your Instagram credentials are up-to-date and have not triggered any security checks.
  • If prompted for a checkpoint, log into Instagram manually and complete any required verification steps.
  • For persistent session issues, use the "Manage Session" operation to refresh or retrieve session data.

Links and References


Note: Always comply with Instagram's terms of service when using private APIs.

Discussion