Glossary
API: the contract between programs
An API, or application programming interface, is a defined set of requests a program accepts and responses it returns, so other programs can use it without knowing how it works inside.
The idea
An API separates what a component does from how it does it. A sorting function in a library, the system calls of an operating system and a payment service on the internet all expose APIs: a list of operations, the inputs each takes, the outputs it gives and the errors it may raise. As long as that contract holds, the provider can rewrite everything behind it and callers keep working.
Kinds of APIs
- Library APIs: functions and classes you call inside your own process.
- Operating system APIs: files, sockets, processes.
- Browser APIs: DOM, Fetch, storage, the things page scripts can use.
- Web APIs: services reached over HTTP, usually with JSON. When developers say "the API" today they usually mean this kind.
Web APIs come in several styles: REST style resources, RPC style method calls, GraphQL queries and streaming protocols. The GateSolver API is RPC style over HTTPS: each URL is a method (/createTask, /getTaskResult, /getBalance) called with a POST and a JSON body.
What a web API contract spells out
| Part | Question it answers |
|---|---|
| Base URL and endpoints | Where do I send requests? |
| Authentication | How do I prove who I am? Often an API key. |
| Request format | Which fields, types and encodings are accepted? |
| Response format | What comes back on success? |
| Errors | How are failures reported, and which are worth retrying? |
| Limits | How many requests per minute, how large a body? |
| Billing | What costs money, and when? |
For GateSolver, the answers are: base URL https://gatesolver.com; the key goes in the body as clientKey; errors come back as errorId and errorCode; the limit is 600 requests per minute per key; and you are billed only when a task is solved, at that moment, by the price per 1,000 for its type, such as $0.56 for reCAPTCHA v2.
Reading API documentation quickly
Start with the smallest successful call, often a balance or status endpoint, to prove that your key and network work. Then make the main call with the documented example values and compare your response with the documented one. Read the error list before writing retry logic, because it tells you which failures are temporary. Keep a copy of the request and response for your first successful call; it saves time when something breaks later.
Using an API versus scraping a site
When a site offers an official API for the data you need, it is almost always the better route: stable fields, clear terms and no bot checks. Scraping fills the gap when no API exists or it leaves out public data you need. See web scraping vs API for the trade offs. A CAPTCHA solving API sits in between: it is a proper API you call, used to keep a scraper or automation running where the target site has no API of its own.
Common questions
What does API stand for?
Application programming interface: a defined set of operations one program offers to others.
Is every API a web API?
No. Libraries, operating systems and browsers have APIs too. Web APIs are the ones reached over HTTP.
What style is the GateSolver API?
RPC style over HTTPS: each endpoint is a method called with a POST and a JSON body.
Should I use an official API instead of scraping?
When one exists and covers your data, yes. It is more stable and comes with clear terms of use.
What should I test first with a new API?
The smallest call that proves authentication works, such as a balance or status request.
Keep reading
- REST APIThe resource oriented style of web API built on URLs, HTTP methods and status codes, usually exchanging JSON over HTTPS.
- API endpointA specific URL and method an API answers on, plus how endpoints are grouped, versioned and described in documentation.
- CAPTCHA solving APIWhat a solving API does, the createTask and getTaskResult cycle, per-1,000 pricing, and proxyless versus proxy tasks.
- API docscreateTask, getTaskResult, getBalance, error codes and the in.php format.