Image to text

Convert image (PNG, JPG) to text

The test function can be used to check whether the image can be recognized correctly.

Object structure

Parameter
Type
Required
Value

api_token

string

yes

Your api key

type_job

string

yes

textcaptcha

body

string

yes

image as base64 encoded (accept png or jpg)

Code example (Python)

import time
import requests

# Creat job
json_data = {
    "api_token": "YOUR_API_KEY",
    "data": {
        "type_job": "textcaptcha",
        "body": "image as base64 encoded"
    }
}
createJob = requests.post("https://betacaptcha.com/api/createJob", json=json_data)

# Get job result
json_data = {
    "api_token": "YOUR_API_KEY",
    "taskid": createJob.json()["taskid"]
}
getJobResult = requests.post("https://betacaptcha.com/api/getJobResult", json=json_data)
if getJobResult.json()["status"] != "running":
    result = getJobResult.json()["result"]
    print(">> Result:", result)

Note

If the image you provide is a file, not base64. You can use the code below to convert from image to base64 format

import base64

def image_to_base64(image_path):
    with open(image_path, "rb") as image_file:
        return base64.b64encode(image_file.read()).decode('utf-8')

image_to_base64('path_to_image.png')

Last updated