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.
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.
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
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
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.jsonCheck 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'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'])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.mdBuy 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)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
| Directory | Mode | Price USD per request |
|---|---|---|
/news/ | pay | 0.005 |
/social/, /markets/, /predictions/, /crypto/ | pay | 0.01 |
/research/, /scholar/ | pay | 0.02 |
/guides/ | allow | 0 |
/members/ | block | 0 |
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
- Header name: X-Crawler-Token esa.aisa.one
- AISA Agent Integration Guide — API reference esa.aisa.one
- AISA agent skill (SKILL.md) esa.aisa.one
- AgentFlare pricing.json (directory price map) agentflare.org
- AgentFlare robots.txt agentflare.org