Python Captcha Solver

Solve image captchas in Python with 3 lines of code. FastCaptcha's Python captcha solver returns the answer in 0.3–0.7 seconds — just use the requests library, no proprietary SDK needed.

Python Captcha Solver — Quick Start

No pip install of proprietary packages — just requests

Install

pip install requests

Basic Solve

import requests

response = requests.post(
    "https://fastcaptcha.org/api/v1/ocr/",
    headers={"X-API-Key": "YOUR_API_KEY"},
    files={"image": open("captcha.png", "rb")}
)

result = response.json()
print(result["text"])           # "XK92B"
print(result["processing_time"]) # 0.31

Solve from URL

import requests
from io import BytesIO

# Download captcha image from URL
img_url = "https://example.com/captcha.png"
img_data = requests.get(img_url).content

# Solve it
response = requests.post(
    "https://fastcaptcha.org/api/v1/ocr/",
    headers={"X-API-Key": "YOUR_API_KEY"},
    files={"image": ("captcha.png", BytesIO(img_data))}
)
print(response.json()["text"])  # "XK92B"

API Response

{
  "success": true,
  "text": "XK92B",
  "confidence": 0.97,
  "processing_time": 0.31,
  "credits_remaining": 2850
}

Python Captcha Solving Use Cases

Real Python examples for common captcha solving scenarios

Selenium + Python

from selenium import webdriver
from selenium.webdriver.common.by import By
import requests

driver = webdriver.Chrome()
driver.get("https://example.com/login")

# Find and screenshot the captcha
captcha_img = driver.find_element(By.ID, "captcha-img")
captcha_img.screenshot("captcha.png")

# Solve with FastCaptcha
res = requests.post(
    "https://fastcaptcha.org/api/v1/ocr/",
    headers={"X-API-Key": "YOUR_KEY"},
    files={"image": open("captcha.png", "rb")}
)
captcha_text = res.json()["text"]

# Fill in the captcha field
driver.find_element(By.ID, "captcha-input").send_keys(captcha_text)

Requests + BeautifulSoup

import requests
from bs4 import BeautifulSoup
from io import BytesIO

session = requests.Session()
page = session.get("https://example.com/form")
soup = BeautifulSoup(page.text, "html.parser")

# Get captcha image URL
captcha_url = soup.find("img", {"class": "captcha"})["src"]
img = session.get(captcha_url).content

# Solve it
res = requests.post(
    "https://fastcaptcha.org/api/v1/ocr/",
    headers={"X-API-Key": "YOUR_KEY"},
    files={"image": ("c.png", BytesIO(img))}
)
captcha_answer = res.json()["text"]

# Submit form with solved captcha
session.post("https://example.com/submit", data={
    "captcha": captcha_answer,
    "username": "user"
})

Batch Processing

import requests
from pathlib import Path
from concurrent.futures import ThreadPoolExecutor

API_KEY = "YOUR_KEY"
ENDPOINT = "https://fastcaptcha.org/api/v1/ocr/"

def solve_captcha(image_path):
    with open(image_path, "rb") as f:
        res = requests.post(
            ENDPOINT,
            headers={"X-API-Key": API_KEY},
            files={"image": f}
        )
    return image_path.name, res.json()["text"]

# Solve 10 captchas in parallel (~0.7s total)
captcha_files = list(Path("captchas/").glob("*.png"))
with ThreadPoolExecutor(max_workers=10) as pool:
    results = dict(pool.map(solve_captcha, captcha_files))

print(results)  # {"cap1.png": "ABC", "cap2.png": "XYZ", ...}

Error Handling

import requests

def solve_captcha(image_path, api_key, retries=2):
    """Solve captcha with retry logic."""
    for attempt in range(retries + 1):
        try:
            res = requests.post(
                "https://fastcaptcha.org/api/v1/ocr/",
                headers={"X-API-Key": api_key},
                files={"image": open(image_path, "rb")},
                timeout=10
            )
            res.raise_for_status()
            data = res.json()
            if data.get("success"):
                return data["text"]
        except requests.RequestException as e:
            if attempt == retries:
                raise
    return None

text = solve_captcha("captcha.png", "YOUR_KEY")
print(f"Solved: {text}")

Python Captcha Solver FAQ

Use pip install requests, POST your captcha image to https://fastcaptcha.org/api/v1/ocr/ with your X-API-Key header. Get back the solved text in 0.3–0.7 seconds. No other libraries needed.

Yes. Screenshot the captcha element with Selenium, send to FastCaptcha's API, type the result into the input field. Full example is shown above in the Selenium section.

Any Python version that supports the requests library — Python 2.7+ and Python 3.6+. The API is plain HTTP so any version works.

Yes. Sign up and get 100 free credits instantly — no credit card needed. Each credit = one captcha solve.

Start Solving Captchas in Python Today

Get your API key free. 100 credits. No credit card.