---
title: "Captcha Solver | ScreenshotAPI.net Docs"
slug: "/docs/renderScreenshot/captcha"
description: "Solve a text-in-image captcha before the screenshot. Name the picture and the text box with CSS selectors. Growth and Business add 3 credits when solve_captcha is on and the capture succeeds."
---

# Captcha

`solve_captcha=true` solves a captcha made of text drawn in a picture, then takes the screenshot. Name the picture and the text box with CSS selectors, such as `#captcha-img` or `img.captcha`.

You can also name the button to click after the answer is typed, a control that loads a new picture, and an element that shows a wrong-answer message. The solver tries again while that message is still visible. The default is 3 tries. You can set 1 to 5.

This reads text inside an image. A checkbox challenge, or a challenge that asks you to select pictures such as traffic lights, is outside this solver. The attempt waits up to 60 seconds.

The solver is on Growth and Business. It adds 3 credits when solve_captcha is on and the capture succeeds. See [Plans and credits](https://www.screenshotapi.net/docs/plans). A proxy can make a challenge less likely, but it does not type the answer. That is covered on the [proxy](https://www.screenshotapi.net/docs/proxy) page.

## Parameters

| Parameter | Required | Values | What it does |
| --- | --- | --- | --- |
| `solve_captcha` | Yes | `true` or `false` | Turn the solver on. |
| `captcha_image` | Yes | CSS selector | The captcha picture. |
| `captcha_input` | Yes | CSS selector | The box the answer is typed into. |
| `captcha_submit` | No  | CSS selector | Clicked after the answer is typed. |
| `captcha_error` | No  | CSS selector | A visible message here means the guess was rejected. |
| `captcha_refresh` | No  | CSS selector | Clicked to load a new picture before the next try. |
| `captcha_retries` | No  | `1` to `5` | How many guesses to make. Default is 3. |
| `ocr_model` | No  | `mini-ocr-v1` or `ocr-v1` | Which recognition model to use. Default is `mini-ocr-v1`. |

## Errors

*   400 when `solve_captcha=true` and `captcha_image` or `captcha_input` is missing.
*   400 when `captcha_retries` is not a whole number from 1 to 5.
*   400 when `captcha_image` matches no element.
*   400 when `ocr_model` is not `mini-ocr-v1` or `ocr-v1`.
*   422 when every guess was rejected, or the picture had no readable text.
*   500 when the solver cannot run. Try again, or contact support if it keeps happening.
*   502 when the solver does not answer, or the wait times out.

## Example

```js

const axios = require("axios");

let config = {
	method: "get",
	maxBodyLength: Infinity,
	url: "https://shot.screenshotapi.net/v3/screenshot?token=TOKEN&url=https%3A%2F%2Fexample.com%2Flogin&solve_captcha=true&captcha_image=%23captcha-img&captcha_input=%23captcha-input&captcha_submit=%23login-button",
	headers: { }
};

axios.request(config).then((response) => {
	console.log(JSON.stringify(response.data));
}.catch((error) => {
	console.log(error);
});
```

```php

<?php
	$client = new http.Client;
	$request = new http.Client.Request;
	$request->setRequestUrl("https://shot.screenshotapi.net/v3/screenshot?token=TOKEN&url=https%3A%2F%2Fexample.com%2Flogin&solve_captcha=true&captcha_image=%23captcha-img&captcha_input=%23captcha-input&captcha_submit=%23login-button");
	$request->setRequestMethod("GET");
	$request->setOptions(array());

	$client->enqueue($request)->send();
	$response = $client->getResponse();
	echo $response->getBody();
?>
```

```go

package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {
	url := "https://shot.screenshotapi.net/v3/screenshot?token=TOKEN&url=https%3A%2F%2Fexample.com%2Flogin&solve_captcha=true&captcha_image=%23captcha-img&captcha_input=%23captcha-input&captcha_submit=%23login-button"
	method := "GET"

	client := &http.Client { }
	req, err := http.NewRequest(method, url, nil)

	if err != nil {
		fmt.Println(err)
		return
	}

	res, err := client.Do(req)
	if err != nil {
		fmt.Println(err)
		return
	}

	defer res.Body.Close()
	body, err := io.ReadAll(res.Body)
	if err != nil {
		fmt.Println(err)
		return
	}

	fmt.Println(string(body))
}
```

```java

OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder().url("https://shot.screenshotapi.net/v3/screenshot?token=TOKEN&url=https%3A%2F%2Fexample.com%2Flogin&solve_captcha=true&captcha_image=%23captcha-img&captcha_input=%23captcha-input&captcha_submit=%23login-button"
	.method("GET", body)
	.build();
Response response = client.newCall(request)
	.execute();
```

```py

import requests

url = "https://shot.screenshotapi.net/v3/screenshot?token=TOKEN&url=https%3A%2F%2Fexample.com%2Flogin&solve_captcha=true&captcha_image=%23captcha-img&captcha_input=%23captcha-input&captcha_submit=%23login-button"
payload = {}
headers = {}

response = requests.request("GET", url, headers, data=payload)
print(response.text)
```

```ruby

require "uri"
require "net/http"

url = URI("https://shot.screenshotapi.net/v3/screenshot?token=TOKEN&url=https%3A%2F%2Fexample.com%2Flogin&solve_captcha=true&captcha_image=%23captcha-img&captcha_input=%23captcha-input&captcha_submit=%23login-button")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Get.new(url)

response = https.request(request)
puts response.read_body
```

```json
{
  "url": "https://example.com/login",
  "solve_captcha": true,
  "captcha_image": "#captcha-img",
  "captcha_input": "#captcha-input",
  "captcha_submit": "#login-button",
  "captcha_refresh": "#captcha-reload",
  "captcha_error": ".captcha-error",
  "captcha_retries": 3
}
```
