Skip to main content

Basic Example

Fill and submit a contact form:
from tinyfish import TinyFish, EventType, RunStatus

client = TinyFish()

with client.agent.stream(
    url="https://example.com/contact",
    goal="""Fill in the contact form:
        - Name field: "John Doe"
        - Email field: "john@example.com"
        - Message field: "I am interested in your services."
        Then click the Submit button and extract the success message.
    """,
) as stream:
    for event in stream:
        if event.type == EventType.COMPLETE and event.status == RunStatus.COMPLETED:
            print("Result:", event.result_json)
Output:
{
  "success": true,
  "message": "Thank you for contacting us!"
}

Multi-Step Form

Handle multi-step forms in a single goal:
from tinyfish import TinyFish

client = TinyFish()

with client.agent.stream(
    url="https://example.com/signup",
    goal="""Complete the multi-step signup form:

        Step 1 (Personal Info):
        - First name: "John"
        - Last name: "Doe"
        - Email: "john@example.com"
        - Click "Next"

        Step 2 (Address):
        - Street: "123 Main St"
        - City: "San Francisco"
        - State: "CA"
        - ZIP: "94102"
        - Click "Next"

        Step 3 (Preferences):
        - Select "Email notifications" checkbox
        - Click "Submit"

        Extract the confirmation number from the success page.
    """,
) as stream:
    for event in stream:
        print(event)

Tips

  • Use stealth mode for login/signup forms
  • Be explicit about field values in your goal
  • Describe buttons by their text (“click ‘Submit’”)
  • Handle multi-step forms in one goal

Try It

1

Save the code

Save any example above as form.mjs
2

Set your API key

export TINYFISH_API_KEY="your_api_key"
3

Run it

node form.mjs

Web Scraping

Extract data from pages

Run SSE API

Complete API docs