Cloudflare overview
We solve two kinds of Cloudflare challenges:
- A challenge page: the
403“Just a moment…” page of a managed, non-interactive or interactive challenge, or Under Attack mode. Getting through sets thecf_clearancecookie. - A Turnstile widget
Getting through takes a browser about eight requests in a row. To solve it you need you send us each part, we’ll give you the payload to submit using your TLS client.
One of those requests is Turnstile’s api.js, from challenges.cloudflare.com. We read it to build the widget’s frame.
On a widget page it is always the first request. On a challenge page we ask for it only the first time we see that
version of it, so most solves skip it.
Challenges and blocks tells a challenge from a block or a widget. Examples with httpcloak has a whole client in Python, Go and JavaScript.
Base URL: https://cf.antibotapi.com. We solve as Chrome 155 on Windows: send your client’s User-Agent as user_agent.
The loop
Section titled “The loop”- Request the site and get the challenge page (or the page with the widget).
POST /solveswith the address, the page’s HTML and your User-Agent. Keep theid.- Take the
request: waitwait_ms, then send itsmethod,url,headers(in that order, with your cookies in thecookieone) andbody. Give up aftertimeout_msif it is not 0. POST /solves/{id}/nextwith the status, headers and body (Base64) that came back, whatever they were. Status0if you gave up.- Repeat 3–4 until the answer has
done.
A challenge page ends with "cleared": true, and its cf_clearance cookie is in your jar. A widget ends with token: post
it as the page’s form would (its cf-turnstile-response field, unless the page names another).
let { id, request } = await api('/solves', { url, html, user_agent: UA });for (;;) { await sleep(request.wait_ms); const res = await send(request.method, request.url, request.headers, request.body, request.timeout_ms); const next = await api(`/solves/${id}/next`, { status: res.status, headers: res.headers, body: base64(res.body) }); if (next.done) return next; // { done, cleared } or { done, token } request = next.request;}Errors
Section titled “Errors”A 422 means we could not take the next step, usually because a response was not what it should be (a 403 where a
200 was due). The solve is over; start a new one. A 404 on /next means the solve has ended or expired, and a 400 on
/solves that we do not solve as your User-Agent (the body lists the ones we do).