web_scraper_get_task_status
Polls for the result of a task enqueued by a *_async tool
- Prijs
- Gratis
- Dienst
- Web scraper
- Categorie
- Webtoegang
- Endpoint
POST /v1/web-scraper/get_task_status
Reads back the result of a task previously enqueued by `web_scraper_scrape_url_async` -- pure read, no fetch performed. `status` is one of `pending` (still queued/running), `finished` (see `ok`/`result`), or `unknown` (the id is invalid or has expired).
Parameters
task_id | string · verplicht | The `task_id` a `*_async` tool returned. |
|---|
Voorbeeldverzoek
Wat je agent verstuurt
{}Kale curl stopt bij de 402-challenge: voeg een x402-client toe (tabs Node.js of Python) om automatisch te betalen.
# Kale curl stopt bij de 402-challenge: voeg een x402-client toe (tabs Node.js of Python) om automatisch te betalen.
curl -X POST 'https://api.17711.xyz/registry/web-scraper/v1/web-scraper/get_task_status' \
-H 'content-type: application/json' \
-d '{"task_id":"string"}'De x402-SDK regelt de 402, de handtekening en de nieuwe poging voor je: één aanroep, één resultaat.
// npm install @x402/fetch @x402/evm viem
import { wrapFetchWithPayment } from "@x402/fetch";
import { x402Client } from "@x402/core/client";
import { ExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";
const signer = privateKeyToAccount(process.env.EVM_PRIVATE_KEY as `0x${string}`);
const client = new x402Client();
client.register("eip155:*", new ExactEvmScheme(signer));
const fetchWithPayment = wrapFetchWithPayment(fetch, client);
const res = await fetchWithPayment("https://api.17711.xyz/registry/web-scraper/v1/web-scraper/get_task_status", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({"task_id":"string"}),
});
console.log(await res.json());De x402-SDK regelt de 402, de handtekening en de nieuwe poging voor je: één aanroep, één resultaat.
# pip install "x402[httpx]" eth_account
import asyncio, os
from eth_account import Account
from x402 import x402Client
from x402.http.clients import x402HttpxClient
from x402.mechanisms.evm import EthAccountSigner
from x402.mechanisms.evm.exact.register import register_exact_evm_client
async def main() -> None:
client = x402Client()
account = Account.from_key(os.environ["EVM_PRIVATE_KEY"])
register_exact_evm_client(client, EthAccountSigner(account))
async with x402HttpxClient(client) as http:
response = await http.post("https://api.17711.xyz/registry/web-scraper/v1/web-scraper/get_task_status", json={"task_id":"string"})
await response.aread()
print(response.json())
asyncio.run(main())De Java-referentieclient uit de officiële x402-repository. Er is nog geen gepubliceerde Java-SDK: de handtekening lever je zelf (bijv. met web3j).
// Reference client from github.com/coinbase/x402 (java/): build it with `mvn clean install`, then
// <dependency><groupId>org.x402</groupId><artifactId>x402</artifactId><version>1.0.0-SNAPSHOT</version></dependency>
import org.x402.client.X402HttpClient;
import org.x402.crypto.CryptoSigner;
import java.math.BigInteger;
import java.net.URI;
import java.net.http.HttpResponse;
import java.util.Map;
public class Call {
public static void main(String[] args) throws Exception {
// You provide the EIP-3009 signature (for example with web3j) from your private key (env EVM_PRIVATE_KEY).
CryptoSigner signer = new CryptoSigner() {
@Override
public String sign(Map<String, Object> payload) {
return signWithWallet(System.getenv("EVM_PRIVATE_KEY"), payload);
}
};
X402HttpClient client = new X402HttpClient(signer);
BigInteger amount = BigInteger.valueOf(0); // in USDC (6 decimals)
String usdcOnBase = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
String payTo = "<the seller address from the 402 challenge>";
HttpResponse<String> response = client.get(URI.create("https://api.17711.xyz/registry/web-scraper/v1/web-scraper/get_task_status"), amount, usdcOnBase, payTo);
System.out.println(response.body());
}
}De x402-SDK regelt de 402, de handtekening en de nieuwe poging voor je: één aanroep, één resultaat.
// go get github.com/x402-foundation/x402/go/v2
package main
import (
"context"
"fmt"
"io"
"net/http"
"os"
"time"
"strings"
x402 "github.com/x402-foundation/x402/go/v2"
x402http "github.com/x402-foundation/x402/go/v2/http"
evm "github.com/x402-foundation/x402/go/v2/mechanisms/evm/exact/client"
evmsigners "github.com/x402-foundation/x402/go/v2/signers/evm"
)
func main() {
signer, _ := evmsigners.NewClientSignerFromPrivateKey(os.Getenv("EVM_PRIVATE_KEY"))
client := x402.Newx402Client().Register("eip155:*", evm.NewExactEvmScheme(signer))
httpClient := x402http.WrapHTTPClientWithPayment(http.DefaultClient, x402http.Newx402HTTPClient(client))
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
req, _ := http.NewRequestWithContext(ctx, "POST", "https://api.17711.xyz/registry/web-scraper/v1/web-scraper/get_task_status", strings.NewReader(`{"task_id":"string"}`))
req.Header.Set("content-type", "application/json")
res, err := httpClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res.StatusCode, string(body))
}De x402-SDK regelt de 402, de handtekening en de nieuwe poging voor je: één aanroep, één resultaat.
// Cargo.toml: x402-reqwest = "0.6", x402-chain-eip155, alloy-signer-local, reqwest, tokio (features = ["full"])
use alloy_signer_local::PrivateKeySigner;
use reqwest::Client;
use std::sync::Arc;
use x402_chain_eip155::V2Eip155ExactClient;
use x402_reqwest::{ReqwestWithPayments, ReqwestWithPaymentsBuild, X402Client};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let signer: Arc<PrivateKeySigner> = Arc::new(std::env::var("EVM_PRIVATE_KEY")?.parse()?);
let x402 = X402Client::new().register(V2Eip155ExactClient::new(signer));
let http = Client::new().with_payments(x402).build();
let res = http
.post("https://api.17711.xyz/registry/web-scraper/v1/web-scraper/get_task_status")
.header("content-type", "application/json")
.body(r#"{"task_id":"string"}"#)
.send()
.await?;
println!("{} {}", res.status(), res.text().await?);
Ok(())
}Wat de x402-client van je agent achter de schermen doet (technisch, ter illustratie).
- 1
Endpoint aanroepen
→POST https://api.17711.xyz/registry/web-scraper/v1/web-scraper/get_task_status content-type: application/json { "task_id": "string" }←402 Payment RequiredHTTP/1.1 402 Payment Required PAYMENT-REQUIRED: <base64> { "x402Version": 2, "accepts": [ { "scheme": "exact", "network": "eip155:8453", "amount": "0", "asset": "USDC", "payTo": "0x…" } ] } - 2
Betaling ondertekenen (lokaal)
Je wallet ondertekent lokaal een USDC-machtiging. Alleen de handtekening verlaat je machine.
→wallet.sign(transferWithAuthorization, to: payTo, value: 0 ( USDC), network: base)←signaturePAYMENT-SIGNATURE: <signed authorisation> - 3
Opnieuw met de handtekening
→POST https://api.17711.xyz/registry/web-scraper/v1/web-scraper/get_task_status PAYMENT-SIGNATURE: <signed authorisation> content-type: application/json { "task_id": "string" }←200 OKHTTP/1.1 200 OK PAYMENT-RESPONSE: <settlement receipt> { … the tool's JSON answer … }
De x402-SDK doet stap 2 en 3 voor je.
OpenAPI-definitie
OpenAPI-definitie · web_scraper_get_task_status
{
"operationId": "web_scraper_get_task_status",
"summary": "Polls for the result of a task enqueued by a *_async tool",
"description": "Reads back the result of a task previously enqueued by `web_scraper_scrape_url_async` -- pure read, no fetch performed. `status` is one of `pending` (still queued/running), `finished` (see `ok`/`result`), or `unknown` (the id is invalid or has expired).",
"security": [],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"task_id": {
"type": "string",
"description": "The `task_id` a `*_async` tool returned."
}
},
"required": [
"task_id"
]
},
"example": {
"task_id": "string"
}
}
}
},
"responses": {
"200": {
"description": "Successful response",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"status": {
"type": "string",
"enum": [
"pending",
"finished",
"unknown"
],
"description": "`\"pending\"` (enqueued, no result yet), `\"finished\"` (a worker wrote a result -- see `ok`/ `result`), or `\"unknown\"` (this id was never valid, or both it and its result have expired -- see [`nimpoleon_tasks::TaskState`]'s own doc comment for why this is 3 states, not 2)."
},
"ok": {
"type": [
"boolean",
"null"
]
},
"result": true
},
"required": [
"status"
]
},
"example": {
"status": "pending",
"ok": false,
"result": null
}
}
}
},
"default": {
"description": "Standardized error envelope, on every non-2xx response from this fleet: {\"error\": {\"code\": <dotted string, e.g. \"request.bad_request\">, \"index\": <integer>, \"status\": <HTTP status code>, \"message\": <client-safe description>, \"debug\": <object, present only for an authorized caller>}}.",
"content": {
"application/json": {
"schema": {
"type": "object",
"description": "ErrorEnvelope"
}
}
}
}
}
}