Skip to main content

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",
) as stream:
    for event in stream:
        if event.type == EventType.COMPLETE and event.status == RunStatus.COMPLETED:
            print("Result:", event.result_json)
Output:
{
  "name": "Bulbasaur",
  "price": 63,
  "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",
) as stream:
    for event in stream:
        print(event)
Output:
{
  "products": [
    { "name": "Bulbasaur", "price": 63, "link": "https://..." },
    { "name": "Ivysaur", "price": 87, "link": "https://..." },
    { "name": "Venusaur", "price": 105, "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)

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)

Try It

1

Save the code

Save any example above as scraper.mjs
2

Set your API key

export TINYFISH_API_KEY="your_api_key"
3

Run it

node scraper.mjs

Form Filling

Automate form submissions

Run SSE API

Complete API docs