Cloudflare Turnstile solver · Java
Solve Cloudflare Turnstile in Java
Java 17's HttpClient and a JSON library are all it takes: create a Turnstile task, poll for the token and read the API's error code when a task fails. There is no Java SDK to add.
No SDK needed: plain JSON over HTTPS
The steps in Java
Get an API key
Sign up with an email and a password, create your key in the dashboard and add funds in crypto, from $10.
Create a task
Send createTask with the page's URL, its Turnstile site key, and the widget's action and cData when it sets them. The price is held on your balance and a taskId comes back at once.
Poll for the token
Ask getTaskResult every two seconds until the status is ready, and stop after a deadline of your own, such as three minutes.
Use the token within 300 seconds
Send the token where the page sends it, usually the cf-turnstile-response form field. It works once, and expires 300 seconds after it was issued.
New to the API? The quickstart walks through sign-up, the key and the first task.
Good to know
The sample uses Jackson for JSON; any JSON library works the same way.
Treat taskId as a string, and check errorId on every reply: the compatible format answers HTTP 200 with errorId 1 on failure.
Share one HttpClient across tasks; it is thread-safe and reuses connections.
Read next
- APIcreateTask and getTaskResult: The Captcha API Format ExplainedHow the createTask, getTaskResult and getBalance format works: request bodies, replies, errorId, polling, and ZeroCaptcha's Cloudflare Turnstile tasks.
- APICaptcha Solver Concurrency, 429s and Retry-AfterRun many Cloudflare Turnstile tasks at once: how ZeroCaptcha paces calls, what 429, ERROR_RATE_LIMIT and ERROR_NO_SLOT_AVAILABLE mean, and how to back off.
- APICaptcha API Error Codes: What Each Means and What It CostsERROR_CAPTCHA_UNSOLVABLE, ERROR_ZERO_BALANCE, ERROR_KEY_DOES_NOT_EXIST and the rest: what each captcha API error means, whether to retry, and what it costs.
Java questions
Is there a Java SDK?
No. The API is plain JSON over HTTPS, so java.net.http and a JSON library are enough, as the sample shows.
How long does a Cloudflare Turnstile token last?
A Cloudflare Turnstile token works once and expires 300 seconds after it is issued, so solve right before you submit. Every result tells you when its token expires.
What does a failed task cost?
Nothing. The price is held when you create a task and released at once if it fails or expires, and a refused task holds nothing; you pay only when a token is ready.