TypeScript SDK: HttpClient: website requests
Get a client with ctx.http(). Requests use the site settings, proxy, limits, and request log. Network calls are asynchronous.
Each example is a separate fragment inside async function run(ctx: Akmelo.Context): Promise<void>. Use await only for methods whose signature returns a Promise.
Methods
withHeaders
ctx.http().withHeaders(headers) → HttpClient
Return a copy of the client with additional HTTP headers. The original client is unchanged.
const result = ctx.http().withHeaders({ Accept: 'application/json' });
withoutCache
ctx.http().withoutCache() → HttpClient
Return a client copy that fetches fresh responses without reading the cache.
const result = ctx.http().withoutCache();
get
ctx.http().get(url, autoCaptcha=true) → Promise<Response>
Load a page or JSON from a URL with GET.
const result = await ctx.http().get(ctx.param('catalog_url', 'https://example.com/catalog'));
post
ctx.http().post(url, body, autoCaptcha=true) → Promise<Response>
Send a POST request with a body. To send exact JSON, serialize it explicitly and set Content-Type.
const result = await ctx.http().post(ctx.param('catalog_url', 'https://example.com/catalog'));
request
ctx.http().request(method, url, body, autoCaptcha=true) → Promise<Response>
Send a request with an explicit HTTP method. get or post is usually enough.
const result = await ctx.http().request('GET', ctx.param('catalog_url', 'https://example.com/catalog'));
pool
ctx.http().pool(urls, autoCaptcha=true) → Promise<Array<Response>>
Load a small batch of independent URLs in parallel.
const result = await ctx.http().pool(['https://example.com/a', 'https://example.com/b']);
Concurrency and response size. The regular profile accepts 1 to 8 URLs and runs at most two requests at a time. A self-hosted agent with the High throughput profile accepts up to 6000 URLs. Actual concurrency is bounded by the site's concurrency setting and the network service's shared capacity. The rps rate, burst, robots.txt and other site policies still apply.
Responses preserve input order. The total SDK response, including metadata, is limited to 8,000,000 bytes. Use smaller batches for large HTML pages and process batches in sequence. A network exception or an exceeded size limit fails the pool; bodies are never silently truncated. An HTTP status such as 404 or 500 is not a network exception by itself: inspect status and response.ok() on each response. 6000 HTTP requests do not mean 6000 browsers or scripts. See High HTTP throughput on your agent.
pages
ctx.http().pages(template, from, to, autoCaptcha=true) → AsyncIterable<[number, Response]>
Visit a known range of pages in order. Use {page} in the template for the page number.
for await (const [number, response] of ctx.http().pages('https://example.com/catalog?page={page}', 1, 3)) {
ctx.log(`Page ${number}: HTTP ${response.status}`);
}
tryJson
ctx.http().tryJson(urls, autoCaptcha=true) → Promise<unknown | null>
Try several JSON addresses in order and use the first suitable response.
const result = await ctx.http().tryJson(['https://example.com/a', 'https://example.com/b']);
Automatic CAPTCHA handling
autoCaptcha is optional and defaults to true. Pass false to disable automatic solving. With automatic mode disabled, the request does not start paid CAPTCHA tasks. Platform and site settings, supported challenge types and quotas still apply. This argument is also available in get, post, request, pool, pages and tryJson.
const response = await ctx.http().get(url, false);
CAPTCHA on a self-hosted agent
Automatic mode and opt-out also work on your agent. A browser, connectivity to Akmelo and an eligible plan are required. No additional CAPTCHA keys need to be configured. Checks and costs belong to the agent's workspace; local execution does not make CAPTCHA handling free.
CAPTCHA usage reference
Complete CAPTCHA SDK and REST reference covers all hint fields, automatic defaults, explicit calls, session opt-out, result verification, agents, limits and failures. User guide and current prices explain setup and billing.
Object selection uses kind: "yandex_image"; automatic detection normally needs no hints. image_selector identifies only the task image, instructions_selector the selection order, and success_selector a result that appears after success. No target-domain list is needed. Unsupported variants fail instead of returning fabricated data. Do not repeatedly retry the same rejected task.