The problem
An Instagram URL is not a dataset. A text-only agent cannot load the feed, follow its page structure, and consistently collect captions and profile details on its own. Ordinary fetches may also return a login screen or incomplete content.
How NativePort helps
NativePort connects the agent to an Apify scraper built for Instagram. You give it a public profile URL and choose whether you want posts or profile details. It returns records that your agent can analyze without maintaining its own Instagram scraper.
Technical implementation
Use Python 3 with requests installed (python -m pip install requests). Set NATIVEPORT_API_KEY in your environment to your NativePort key. Run the snippets on your server, where your key stays private.
Set INSTAGRAM_URL to a public profile URL. This small synchronous request collects up to five posts.
import os
import requests
BASE = "https://api.nativeport.ai"
HEADERS = {"Authorization": f"Bearer {os.environ['NATIVEPORT_API_KEY']}"}
response = requests.post(
BASE + "/apify/v2/acts/apify~instagram-scraper/run-sync-get-dataset-items",
headers=HEADERS,
json={"directUrls": [os.environ["INSTAGRAM_URL"]],
"resultsType": "posts", "resultsLimit": 5},
timeout=180,
)
response.raise_for_status()
posts = response.json()
print(posts)For profile metadata, send a separate request with resultsType: "details". Inputs follow the Instagram Actor schema. Test your target profiles before scheduling collection: availability and fields depend on Instagram and the Actor. For longer runs use the asynchronous Apify flow.
Tool costs
| Tool used in the example | Price per call |
|---|---|
| Apify — Instagram scraper | $0.01055 / call |
Prices in USD. Usage-based tools have no fixed per-call price. View pricing.
Let your agent build it
You don’t need to write this code yourself. Copy this page’s link and paste it into your agent. Ask it to follow the guide and implement the feature for you.