OCR ImageToText
WARNING
Create the task with the createTask.
This interface does not need to obtain the results separately, will synchronously return the image recognition results!
Create Task
Create the task with the createTask.
Task Object Structure
Note that this type of task returns the task execution result directly after createTask, rather than getting it asynchronously through getTaskResult.
Properties | Type | Required | Description |
---|---|---|---|
type | String | Required | ImageToTextTask |
body | String | Required | base64 encoded content of the image (no newlines) (no data:image/*********; base64, content |
module | String | Optional | Specifies the module. Currently, the supported modules are common and queueit |
score | Float | Optional | 0.8 ~ 1 , Identify the matching degree. If the recognition rate is not within the range, no deduction |
case | Boolean | Optional | Case sensitive or not |
Independent module support
- mtcaptcha
- dell
- queueit
- amazon
- amazon-gif
- web-de-login
- web-de-register
- web-de-imap
- common
Example request
json
POST https://api.capsolver.com/createTask
Host: api.capsolver.com
Content-Type: application/json
{
"clientKey": "YOUR_API_KEY",
"task":{
"type":"ImageToTextTask",
"module":"queueit", // ocr single image model,
"body": "/9j/4AAQSkZJRgABA......" # base64 encoded image
}
}
Example response
json
{
"errorId": 0,
"errorCode": "",
"errorDescription": "",
"status": "ready",
"solution": {
"text": "44795sds"
},
"taskId": "2376919c-1863-11ec-a012-94e6f7355a0b",
}
Use SDK Request
python
#pip install --upgrade capsolver
#export CAPSOLVER_API_KEY='...'
import capsolver
# capsolver.api_key = "..."
img_path = os.path.join(Path(__file__).resolve().parent,"queue-it.jpg")
with open(img_path,'rb') as f:
solution = capsolver.solve({
"type":"ImageToTextTask",
"module":"queueit",
"body": "/9j/4AAQSkZJRgABA......"
})
print(solution)
golang
package main
import (
"fmt"
capsolver_go "github.com/capsolver/capsolver-go"
"log"
)
func main() {
// first you need to install sdk
//go get github.com/capsolver/capsolver-go
//export CAPSOLVER_API_KEY='...' or
//capSolver := CapSolver{apiKey:"..."}
capSolver := capsolver_go.CapSolver{}
solution, err := capSolver.Solve(map[string]any{
"type": "ImageToTextTask",
"module": "queueit",
"body": "/9j/4AAQSkZJRgABA......",
})
if err != nil {
log.Fatal(err)
return
}
fmt.Println(solution)
}