The problem
TikTok pages load content dynamically and do not present a simple table of videos to an ordinary agent. A model cannot infer accurate view counts, captions, or posting dates from a profile URL. Building a browser collector also means maintaining selectors as the site changes.
How NativePort helps
NativePort lets your agent run an Apify scraper that understands TikTok profiles and videos. It returns the collected records so your agent can work on the analysis rather than page navigation. Public availability and the scraper’s coverage determine what comes back.
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 TIKTOK_USERNAME to a public username, without @. Start with a small sample.
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/clockworks~tiktok-scraper/run-sync-get-dataset-items",
headers=HEADERS,
json={"profiles": [os.environ["TIKTOK_USERNAME"]], "resultsPerPage": 5},
timeout=180,
)
response.raise_for_status()
print(response.json())The TikTok Actor input schema defines profile and search options. Validate a small run against your target before relying on it. Long collections should use the asynchronous run-and-poll endpoints described in the Apify reference.
Tool costs
| Tool used in the example | Price per call |
|---|---|
| Apify — TikTok 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.