> ## Documentation Index
> Fetch the complete documentation index at: https://docs.olostep.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 従量課金制 (x402)

> ステーブルコインを使用した従量課金制APIエンドポイント

## 概要

Olostep APIエンドポイントをステーブルコインを使用した従量課金制で利用できるようになりました。

これらのエンドポイントはx402支払いプロトコルを使用しており、ステーブルコインによる従量課金アクセスを可能にします。各リクエストには認証と支払いのための支払いヘッダーが必要です。

<Info>
  **従量課金制エンドポイント**

  以下にリストされているすべてのエンドポイントは、x402プロトコルを介してステーブルコインでの支払いを受け付けます。サブスクリプションは不要で、使用した分だけ支払います。
</Info>

## 認証

リクエストに支払いヘッダーを含めてください:

```
X-Payment: {{paymentHeader}}
```

支払いは自動的に処理され、リクエストが完了する前に確認されます。

***

## Olostep API

### 支払い対応エンドポイント

#### POST /v1/maps

このエンドポイントでは、特定のウェブサイト上のすべてのURLを取得できます。複雑なウェブサイトの場合、最大120秒かかることがあります。大規模なウェブサイトの場合、結果はカーソルベースのページネーションを使用してページ分けされます。

**価格:** リクエストごとに\$0.01

**ネットワーク:** base (USDC)

```bash theme={null}
curl -X POST 'https://api.olostep.com/x402/v1/maps' \\
  -H 'Content-Type: application/json' \\
  -H 'X-Payment: {{paymentHeader}}' \\
  -d '{
    "url": "example",
    "search_query": "example",
    "top_n": 123,
    "include_subdomain": true,
    "include_urls": "",
    "exclude_urls": "",
    "cursor": "example"
  }'
```

#### POST /v1/scrapes

ウェブページのスクレイピングを開始します

**価格:** リクエストごとに\$0.01

**ネットワーク:** base (USDC)

```bash theme={null}
curl -X POST 'https://api.olostep.com/x402/v1/scrapes' \\
  -H 'Content-Type: application/json' \\
  -H 'X-Payment: {{paymentHeader}}' \\
  -d '{
    "url_to_scrape": "example",
    "wait_before_scraping": "",
    "formats": "",
    "remove_css_selectors": "example",
    "actions": "",
    "country": "example",
    "transformer": "example",
    "remove_images": true,
    "remove_class_names": "",
    "parser": "",
    "llm_extract": "",
    "links_on_page": "",
    "screen_size": "",
    "metadata": ""
  }'
```

#### POST /v1/crawls

新しいクロールを開始します。進行状況を追跡するための`id`を受け取ります。操作はサイトや深さ、ページ数のパラメータに応じて1〜10分かかることがあります。

**価格:** 動的 - 使用量に基づいてリクエストごとに計算

<Note>
  このエンドポイントは動的な価格設定を使用しています。実際のコストはリクエストパラメータによって決定され、処理前に402 Payment Requiredレスポンスで表示されます。
</Note>

**ネットワーク:** base (USDC)

```bash theme={null}
curl -X POST 'https://api.olostep.com/x402/v1/crawls' \\
  -H 'Content-Type: application/json' \\
  -H 'X-Payment: {{paymentHeader}}' \\
  -d '{
    "start_url": "example",
    "max_pages": 123,
    "include_urls": "",
    "exclude_urls": "",
    "max_depth": 123,
    "include_external": true,
    "include_subdomain": true,
    "search_query": "example",
    "top_n": 123,
    "webhook_url": "example",
    "timeout": 123
  }'
```

#### POST /v1/answers

AIがウェブページを検索・閲覧して提供されたタスクの答えを見つけます。実行時間は複雑さに応じて3〜30秒です。長時間のタスクにはエージェントエンドポイントを使用してください。

**価格:** リクエストごとに\$0.05

**ネットワーク:** base (USDC)

```bash theme={null}
curl -X POST 'https://api.olostep.com/x402/v1/answers' \\
  -H 'Content-Type: application/json' \\
  -H 'X-Payment: {{paymentHeader}}' \\
  -d '{
    "task": "example",
    "json_format": ""
  }'
```

### 標準エンドポイント

これらのエンドポイントは支払いを必要としません:

* **GET** `/v1/crawls/{crawl_id}` - 特定のクロールに関する情報を取得します。
* **GET** `/v1/batches/{batch_id}/items` - バッチで処理されたアイテムのリストを取得します。その後、Retrieve Endpointを使用してコンテンツを取得できます。
* **GET** `/v1/crawls/{crawl_id}/pages` - 特定のクロールのページリストを取得します。
* **GET** `/v1/batches/{batch_id}` - バッチのステータスと進行状況情報を取得します。バッチのコンテンツを取得するには、こちらを参照してください。
* **GET** `/v1/answers/{answer_id}` - このエンドポイントはIDによって以前に完了した答えを取得します。
* **GET** `/v1/scrapes/{scrape_id}` - スクレイプのレスポンスを取得するために使用できます。
* **GET** `/v1/retrieve` - 処理されたバッチとクロールのURLのページコンテンツを取得します。

***

## x402の仕組み

支払いの流れはx402 SDKによって自動的に処理されます:

1. **リクエストを送信** - エンドポイントにリクエストを送信
2. **支払い要求** - サーバーが支払い要件（402ステータス）で応答
3. **自動支払い** - SDKが自動的に支払いを作成し提出
4. **レスポンスを取得** - APIレスポンスを受け取る

## はじめに

言語に合わせてx402 SDKをインストールします:

```bash theme={null}
# Node.js
npm install x402-fetch viem

# Python  
pip install x402 eth-account
```

## 使用例

<CodeGroup>
  ```javascript Node.js theme={null}
  import { wrapFetchWithPayment } from "x402-fetch";
  import { privateKeyToAccount } from "viem/accounts";

  const account = privateKeyToAccount(process.env.PRIVATE_KEY);
  const fetchWithPayment = wrapFetchWithPayment(fetch, account);

  // 有料リクエストを行う - 支払いは自動
  const response = await fetchWithPayment("https://api.olostep.com/x402/v1/maps", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({ /* your data */ })
  });

  const result = await response.json();
  console.log(result);
  ```

  ```python Python theme={null}
  import requests
  from eth_account import Account
  from x402.clients.requests import x402_http_adapter

  account = Account.from_key(os.getenv("PRIVATE_KEY"))
  session = requests.Session()
  adapter = x402_http_adapter(account)
  session.mount("https://", adapter)

  # 有料リクエストを行う - 支払いは自動
  response = session.post(
      "https://api.olostep.com/x402/v1/maps",
      json={"key": "value"}
  )

  print(response.json())
  ```
</CodeGroup>

## 詳細情報

* [x402 Protocol Docs](https://x402.org)
* [Coinbase x402 Guide](https://docs.cdp.coinbase.com/x402/)

***

Powered by [Orthogonal](https://orthogonal.sh)
