Glossary
Asynchronous API: start a job now, collect it later
An asynchronous API accepts a request, returns an identifier right away, and lets the client fetch the result once the work is done, instead of holding the connection open until then.
Why not just wait?
Some work takes longer than an HTTP connection comfortably stays open. Proxies and load balancers cut idle connections, mobile networks drop them, and a client blocked on one long call cannot do anything else. Splitting the job into "start" and "check" solves all of that. The server queues the work, the client gets a ticket, and both sides proceed independently.
The create then poll pattern
- The client sends the job. The server validates it and returns an ID.
- The client waits a sensible interval, then asks for the status by ID.
- The server answers "still working", "done, here is the result" or "failed, here is why".
- The client stops polling on done or failed, or when its own deadline passes.
GateSolver follows this exactly. /createTask returns a taskId. /getTaskResult returns status as processing, ready (with solution and cost) or failed. A task still unsolved after 120 seconds is marked failed and costs nothing.
Choosing the interval
Polling too often wastes requests and can hit rate limits; polling too rarely adds latency. Match the interval to how long the job usually takes. For GateSolver, poll every 3 seconds for token tasks (reCAPTCHA, Turnstile, AWS WAF, GeeTest and so on) and every 1 second for image tasks, which finish faster: a text image usually takes under 1 seconds, while a reCAPTCHA v2 token takes under 9 seconds.
import asyncio, httpx
async def collect(client: httpx.AsyncClient, task_id: str, every: float) -> dict:
deadline = asyncio.get_running_loop().time() + 130
while asyncio.get_running_loop().time() < deadline:
await asyncio.sleep(every)
state = (await client.post("https://gatesolver.com/getTaskResult",
json={"clientKey": "YOUR_API_KEY", "taskId": task_id})).json()
if state.get("errorId") or state.get("status") != "processing":
return state
return {"status": "failed", "errorCode": "CLIENT_DEADLINE"}
Using an async sleep means one process can wait on hundreds of tasks at once, which suits a solving API with no cap on concurrent tasks (see concurrency).
Polling versus push
The alternative to polling is push: the server calls a URL you provide when the job finishes (a webhook). Push saves requests but needs a public endpoint on your side, signature checks and retry handling. GateSolver uses polling only; there is no callback option. For jobs that last seconds, polling is simple, works from any machine including ones behind NAT, and keeps all logic in one place.
Handling errors in each phase
Errors at creation (ERROR_ZERO_BALANCE, ERROR_INVALID_TASK_DATA with the missing field named, ERROR_TASK_NOT_SUPPORTED) mean the job never started; fix the input or top up. Errors while polling, such as ERROR_TASKID_INVALID, usually mean a wrong ID. A failed status with ERROR_CAPTCHA_UNSOLVABLE means the work was attempted and did not succeed; you are not charged, and a fresh task is the right response. Network errors while polling are harmless to retry, since checking a status changes nothing (see idempotency).
Common questions
Why do some APIs use create then poll instead of one call?
Long jobs outlast comfortable connection times, and splitting them lets client and server work independently.
How often should I poll getTaskResult?
Every 3 seconds for token tasks and every 1 second for image tasks.
What happens if a task never finishes?
After 120 seconds without a solution, GateSolver marks it failed and does not charge for it.
Does GateSolver support callbacks instead of polling?
No. It works by polling only; there is no callback or webhook option.
Is it safe to retry a getTaskResult call?
Yes. Checking a status changes nothing on the server, so repeats are harmless.
Keep reading
- Task pollingAsking getTaskResult for an answer on a timer: sensible intervals for token and image tasks, and when to give up.
- WebhookPush callbacks where a service calls your URL when something happens, compared with polling, which is how GateSolver delivers results.
- API docscreateTask, getTaskResult, getBalance, error codes and the in.php format.
- TimeoutConnect, read and total timeouts for HTTP calls, plus the separate deadline for an asynchronous task such as a CAPTCHA solve.