Basic Example
Extract product data from any page:from tinyfish import TinyFish, EventType, RunStatus
client = TinyFish()
with client.agent.stream(
url="https://scrapeme.live/shop/Bulbasaur/",
goal="Extract the product name, price, and stock status. Return as JSON.",
) as stream:
for event in stream:
if event.type == EventType.COMPLETE and event.status == RunStatus.COMPLETED:
print("Result:", event.result_json)
import { TinyFish, EventType, RunStatus } from "@tiny-fish/sdk";
async function main() {
const client = new TinyFish();
const stream = await client.agent.stream({
url: "https://scrapeme.live/shop/Bulbasaur/",
goal: "Extract the product name, price, and stock status. Return as JSON.",
});
for await (const event of stream) {
if (event.type === EventType.COMPLETE && event.status === RunStatus.COMPLETED) {
console.log("Result:", event.result);
}
}
}
main();
curl -N -X POST https://agent.tinyfish.ai/v1/automation/run-sse \
-H "X-API-Key: $TINYFISH_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://scrapeme.live/shop/Bulbasaur/",
"goal": "Extract the product name, price, and stock status. Return as JSON."
}'
tinyfish agent run "Extract the product name, price, and stock status. Return as JSON." \
--url scrapeme.live/shop/Bulbasaur/ --pretty
{
"name": "Bulbasaur",
"price": "£63.00",
"inStock": true
}
Extract Multiple Items
Get all products from a category page:from tinyfish import TinyFish
client = TinyFish()
with client.agent.stream(
url="https://scrapeme.live/shop/",
goal="Extract all products on this page. For each product return: name, price, and link. Return as JSON.",
) as stream:
for event in stream:
print(event)
import { TinyFish } from "@tiny-fish/sdk";
async function main() {
const client = new TinyFish();
const stream = await client.agent.stream({
url: "https://scrapeme.live/shop/",
goal: "Extract all products on this page. For each product return: name, price, and link. Return as JSON.",
});
for await (const event of stream) {
console.log(event);
}
}
main();
curl -N -X POST https://agent.tinyfish.ai/v1/automation/run-sse \
-H "X-API-Key: $TINYFISH_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://scrapeme.live/shop/",
"goal": "Extract all products on this page. For each product return: name, price, and link. Return as JSON."
}'
{
"products": [
{ "name": "Bulbasaur", "price": "£63.00", "link": "https://..." },
{ "name": "Ivysaur", "price": "£87.00", "link": "https://..." },
{ "name": "Venusaur", "price": "£105.00", "link": "https://..." }
]
}
Use Stealth Mode
For sites with bot protection:from tinyfish import TinyFish, BrowserProfile
client = TinyFish()
with client.agent.stream(
url="https://protected-site.com",
goal="Extract product data",
browser_profile=BrowserProfile.STEALTH,
) as stream:
for event in stream:
print(event)
import { TinyFish, BrowserProfile } from "@tiny-fish/sdk";
async function main() {
const client = new TinyFish();
const stream = await client.agent.stream({
url: "https://protected-site.com",
goal: "Extract product data",
browser_profile: BrowserProfile.STEALTH,
});
for await (const event of stream) {
console.log(event);
}
}
main();
curl -N -X POST https://agent.tinyfish.ai/v1/automation/run-sse \
-H "X-API-Key: $TINYFISH_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://protected-site.com",
"goal": "Extract product data",
"browser_profile": "stealth"
}'
Use Proxy
Route through a specific country:from tinyfish import TinyFish, BrowserProfile, ProxyConfig, ProxyCountryCode
client = TinyFish()
with client.agent.stream(
url="https://geo-restricted-site.com",
goal="Extract data",
browser_profile=BrowserProfile.STEALTH,
proxy_config=ProxyConfig(enabled=True, country_code=ProxyCountryCode.US),
) as stream:
for event in stream:
print(event)
import { TinyFish, BrowserProfile, ProxyCountryCode } from "@tiny-fish/sdk";
async function main() {
const client = new TinyFish();
const stream = await client.agent.stream({
url: "https://geo-restricted-site.com",
goal: "Extract data",
browser_profile: BrowserProfile.STEALTH,
proxy_config: { enabled: true, country_code: ProxyCountryCode.US },
});
for await (const event of stream) {
console.log(event);
}
}
main();
curl -N -X POST https://agent.tinyfish.ai/v1/automation/run-sse \
-H "X-API-Key: $TINYFISH_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://geo-restricted-site.com",
"goal": "Extract data",
"browser_profile": "stealth",
"proxy_config": {
"enabled": true,
"country_code": "US"
}
}'
Try It
Related
Form Filling
Automate form submissions
Run SSE API
Complete API docs