Skip to content

Web

Live web search and single-page scrape, optimized for LLM grounding (Tavily/Exa/Brave · Firecrawl/Jina).

Overview

Base path: https://api.infrai.cc/v1/web
Auth header: Authorization: Bearer $INFRAI_API_KEY
bash
# Call any /v1/web capability over raw HTTP — no SDK to install.
# curl:
curl https://api.infrai.cc/v1/web/... \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json"

Methods

web.scrape

POST /v1/web/scrape

Fetch and read a single web page, returning clean text/markdown for an LLM to summarize. Read-only and honors robots.txt — no crawl, no paywall bypass. Vendor-backed (Firecrawl/Jina). Billable work-action.

Parameters

NameTypeRequiredDescription
urlstring
Required
URL of the single page to fetch and read.
format"markdown" | "text"OptionalOutput format for the scraped content: markdown (default) or text.
idempotency_keystringOptionalOptional dedup key; identical retries return the same result.

Returns

ScrapeResult { url, title, content, format }

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X POST https://api.infrai.cc/v1/web/scrape \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url": "..."}'

All capabilities

Every routed capability in this module — the complete public REST contract. The methods above are the guided walkthrough; this index is the full reference.

CapabilityEndpointDescription
web.scrapePOST /v1/web/scrapeFetch and read a single web page, returning clean text/markdown for an LLM to summarize. Read-only and honors robots.txt — no crawl, no paywall bypass. Vendor-backed (Firecrawl/Jina). Billable work-action.
web.searchPOST /v1/web/searchSearch the live web and return ranked results (title, url, snippet) optimized for LLM grounding — adds real-time knowledge to an AI app. Vendor-backed (Tavily/Exa/Brave). Billable work-action.

End-to-end example

A production-style walkthrough of this module: configure once, then run the flow. It exercises most of the module's APIs.

A copy-paste-runnable single-file Python program (stdlib only, no SDK): set your INFRAI_API_KEY, run it, and walk this module's core flow with REAL billed calls — later steps reuse real fields returned by earlier ones. The 12-line helper is the entire integration.

python
#!/usr/bin/env python3
"""Infrai · web — runnable real-app example (single file, zero deps).

Copy this file, set your key, run it: every step is a REAL call to
api.infrai.cc, billed at the real (tiny) per-call price, printing the
live JSON response. Get a key at https://infrai.cc/login (Google/
GitHub sign-in grants $2 free credit); add funds at
https://infrai.cc/billing. No SDK — the 12-line helper below is the
entire integration."""
import json
import os
from urllib import error, request

KEY = os.environ.get("INFRAI_API_KEY") or "ifr_..."  # <- your key
BASE = "https://api.infrai.cc"


# Same raw HTTPS POST/GET as every per-method example on this page —
# wrapped once for reuse. There is nothing else to it: no SDK.
def infrai(method, path, body=None):
    req = request.Request(
        BASE + path, method=method,
        data=json.dumps(body).encode() if body is not None else None,
        headers={"Authorization": f"Bearer {KEY}",
                 "Content-Type": "application/json"})
    try:
        with request.urlopen(req, timeout=60) as r:
            return json.loads(r.read())
    except error.HTTPError as e:
        return json.loads(e.read())


def show(label, resp):
    print(f"\n== {label} ==")
    print(json.dumps(resp, indent=2, ensure_ascii=False))
    return resp


# 1) web.search — POST /v1/web/search · Search the live web and return ranked results (title, url, snippet) optimized for LLM grounding — adds real-time knowledge to an AI app. Vendor-backed (Tavily/Exa/Brave). Billable work-action.
r1 = show("web.search", infrai("POST", "/v1/web/search", {"query":"what is retrieval-augmented generation","max_results":3}))

# 2) web.scrape — POST /v1/web/scrape · Fetch and read a single web page, returning clean text/markdown for an LLM to summarize. Read-only and honors robots.txt — no crawl, no paywall bypass. Vendor-backed (Firecrawl/Jina). Billable work-action.
r2 = show("web.scrape", infrai("POST", "/v1/web/scrape", {"url":"https://infrai.cc","format":"markdown"}))