AgentFlare

Guides · For agent developers · Intermediate

Budgeting a Paid Crawl: Discover, Survey, Then Buy

Crawl a whole site on a fixed budget by reading free discovery files first, choosing targets from the free tier, then buying only the deep files you need. Keep a running total and stop when a 402 insufficient_balance appears.

LevelIntermediate
Reading time6 min
Steps65 with code
Sources5primary docs
✓ Open accessFree

You're reading the full report — free for humans. The machine-readable dataset for this section is open to all agents too — no payment required.

⚡ Agents: fetch .data.json → agents: allowed (no charge) · verify at https://esa.aisa.one/api/v1/access/verify

This guide is for developers building agents that crawl an entire publisher site rather than one known URL, using the AISA pay-per-crawl network. You will read the free discovery files to learn the cost landscape, check your real balance, use the free HTML and .md tier to choose what is worth buying, and fetch only those paid files. You will also skip blocked directories without retrying, track what each request charges, and stop cleanly when the balance runs out so a human can top up.

How the flow works

For agent developersDrawn from the AISA agent and publisher documentation
Pay-per-crawl request flow: 1. Your agent to Publisher edge: GET file + X-Crawler-Token; 2. Publisher edge to AISA: authorize token against price rule; 3. AISA to Publisher edge: grant: deduct price once; 4. Publisher edge to Your agent: 200 content (+ charge receipt); 5. Publisher edge to Your agent: or 402 JSON: error + guidance; 6. Publisher edge to Your agent: or 403 access_blockedYour agentcrawler tokenPublisher edgeCDN gatewayAISAverify + balance1. GET file + X-Crawler-Token2. authorize token against price rule3. grant: deduct price once4. 200 content (+ charge receipt)5. or 402 JSON: error + guidance6. or 403 access_blocked

Before you start

  • A registered AISA crawler account with a crawler token
  • curl and Python 3 with the requests library
  • A genuine User-Agent string that identifies your bot

Step by step

  1. Fetch the free discovery files

    Start with files that never charge: robots.txt, llms.txt, sitemap.xml and pricing.json. robots.txt points to the sitemap, llms.txt maps the content by section, and pricing.json declares per-directory prices and modes (pay, allow, block). Reading all four tells you the cost landscape before you spend anything. No token is needed for these requests on agentflare.org.

    bash
    curl -s https://agentflare.org/robots.txt
    curl -s https://agentflare.org/llms.txt
    curl -s https://agentflare.org/sitemap.xml
    curl -s https://agentflare.org/pricing.json
  2. Check your real balance first

    Fetch the balance with the same crawler token you will crawl with, and treat that number as your budget. The header is X-Crawler-Token; it replaces the earlier X-AISA-Crawler-Token spelling, which older pages still show. Never send the crawler token in Authorization: Bearer. Always fetch the balance rather than quoting it from memory, because a remembered figure goes stale the moment you spend.

    bash
    curl -s https://cdn.aisa.one/api/agent/balance \
      -H 'X-Crawler-Token: YOUR_CRAWLER_TOKEN'
  3. Classify directories by mode and price

    Parse the rules array in pricing.json. Each rule has a urlPattern, a mode and a price. Directories in pay mode cost money per request, the guides directory is in allow mode with price 0, and the members directory is in block mode. Build your allow-list from pay and allow rules, and drop every URL under a blocked directory before any request is sent.

    python
    import requests
    
    p = requests.get('https://agentflare.org/pricing.json').json()
    for rule in p['rules']:
        print(rule['mode'], rule['price'], rule['urlPattern'])
  4. Survey the free tier to choose targets

    Use the free .html pages and .md teasers only to decide what is worth buying. List URLs from the sitemap, filter out the blocked members directory, then read the free summaries of the remaining candidates. Rank them by value against price, so the cheap news directory and the pricier research directory are weighed against your budget. Only the .data.json and .full.md files are metered.

    bash
    curl -s https://agentflare.org/sitemap.xml \
      | grep -o 'https://[^<]*' \
      | grep -v '/members/' \
      | head -20
    
    # free teaser for one candidate
    curl -s https://PUBLISHER-SITE/news/ARTICLE.md
  5. Buy selectively with a running total

    Fetch each chosen paid file once; fetching twice charges twice. Add the X-AISA-Charge-Amount receipt header to a running total after each 200. Stop the loop on a 402 whose error is insufficient_balance. On a 403 access_blocked, skip only that URL and continue; payment does not unlock it and denials never charge.

    python
    import requests
    
    H = {'X-Crawler-Token': 'YOUR_CRAWLER_TOKEN',
         'User-Agent': 'MyBot/1.0 (+https://example.com/bot)'}
    urls = ['https://PUBLISHER-SITE/news/ARTICLE.data.json']
    spent = 0.0
    for u in urls:
        r = requests.get(u, headers=H)
        if r.status_code == 200:
            spent += float(r.headers.get('X-AISA-Charge-Amount', 0))
        elif r.status_code == 403:
            continue
        elif r.status_code == 402:
            if r.json().get('error') == 'insufficient_balance':
                break
    print(spent)
  6. Report and hand off funding to a human

    When the loop ends, fetch the balance again and report what was free, what was paid, the amount charged and the real remaining balance. The charge equals the balance before minus the balance now. If you stopped on insufficient_balance, tell the user the crawler.shortfall value and surface the checkout_url from the top-up session. Wait for them to pay; never call the balance/add endpoint yourself.

AgentFlare directory modes and prices

DirectoryModePrice USD per request
/news/pay0.005
/social/, /markets/, /predictions/, /crypto/pay0.01
/research/, /scholar/pay0.02
/guides/allow0
/members/block0

Common pitfalls

  • Fetching a priced resource twice charges you twice, so cache every paid response and never re-request it.
  • A 403 access_blocked is a publisher policy. Do not retry it or top up for it; skip the URL and move on to pay-mode directories.
  • Never send the crawler token in Authorization: Bearer; the request is treated as unauthenticated and returns 402 invalid_token.
  • Do not call POST /api/agent/balance/add to refill mid-crawl. It is for human operators seeding test accounts, not for agents.

Key takeaways

  • Discovery files and the free .html and .md tier cost nothing, so use them to choose targets before spending.
  • Only .data.json and .full.md files in pay directories are metered; each request is charged once, so track a running total.
  • Stop on insufficient_balance, skip blocked URLs, and give the user the checkout_url instead of funding yourself.

FAQ

How do I know what a site charges before I crawl it?

Fetch /pricing.json, which maps each directory to a price and mode, and read /llms.txt for the tiers. Both are free. A 402 response also carries the exact price in rule.price, and denials never charge.

What does a crawler do on a 402 insufficient_balance?

Stop the paid requests. The response includes crawler.shortfall, the amount you still need. Tell your user, give them the checkout_url from a Stripe top-up session, wait for payment, then retry.

Should I retry a 403 access_blocked after topping up?

No. The publisher forbids crawler access to that resource, and payment does not unlock it. Skip that URL and continue with the directories listed as pay or allow in pricing.json.

How do I confirm what a request cost?

A paid 200 may carry X-AISA-Charged and X-AISA-Charge-Amount headers. To verify, call GET /api/agent/balance with X-Crawler-Token before and after; the difference is the charge.

How this page is made. Written from 5 primary sources — the AISA agent and publisher documentation and AgentFlare's own files (pricing.json, robots.txt, llms.txt, live responses, .data.json field lists). Each step links the sources it relies on; steps naming a header, endpoint, error code or figure that the sources do not contain are removed. Refreshed weekly.

Sources & citations

  1. Header name: X-Crawler-Token esa.aisa.one
  2. AISA Agent Integration Guide — API reference esa.aisa.one
  3. AISA agent skill (SKILL.md) esa.aisa.one
  4. AgentFlare pricing.json (directory price map) agentflare.org
  5. AgentFlare robots.txt agentflare.org