Implementing TextIn OCR API: A Developer's Guide

Implementing TextIn OCR API: A Developer's Guide

About TextIn OCR Technology

TextIn is an intelligent optical character recognition (OCR) solution developed by Shanghai HH Technology Co., Ltd., a company with 16 years of specialized experience in the text recognition domain. The platform provides intelligent text recognition engines, products, and cloud services to enterprises, developers, and individual users.

Shanghai HH Technology Co., Ltd. operates as an artificial intelligence and big data technology enterprise focusing on OCR, image processing, natural language processing (NLP), knowledge graphs, and big data mining. Leveraging its proprietary intelligent text recognition and commercial big data technologies, the company offers digital and intelligent products and services to global C-end users and diverse industry B-end clients.

  • Founded in 2006
  • By March 2021, its three flagship applications—CamScanner, CamCard, and Qixinbao—had accumulated over 600 million global downloads across App Store and Google Play
  • Recognized as a Google Top Developer
  • Specializes in OCR, image processing, NLP, knowledge graphs, and big data mining
  • Holder of 111 independent intellectual property invention patents and 38 overseas patents

Getting Started with the API

1. Register on the Official Website

Visit the TextIn platform and complete the registration process using your mobile phone number. After successful registration and login, navigate to the workspace where you'll be granted 100 free API calls for testing purposes.

2. Apply for Public API Access

Access the marketplace section where various recognition APIs are available. This guide focuses on implementing the text recognition API. Select the free trial option to proceed to your workspace, where you'll see the newly provisioned API robot.

3. Utilizing the API

First, record your x-ti-app-id and x-ti-secret-code for authentication purposes. The platform provides detailed API specifications under the API integration section for your selected robot.

Python Implementation Example

Before proceeding, ensure you have Python 3 installed and the requests library added to your environment.

Installation on Windows:
  1. Download Python from the official website (python.org)
  2. Open Command Prompt and navigate to the downloaded installer location
  3. Execute the installation with administrative privileges:
    python-3.x.x-amd64.exe /quiet InstallAllUsers=1 PrependPath=1
  4. Verify installation:
    python --version
  5. Install the requests library:
    pip install requests
Installation on Linux:
  1. Install Python:
    sudo apt install python3
  2. Verify installation:
    python3 --version
  3. Install the requests library:
    pip install requests

After installation, create a Python file and replace the placeholder values with your actual credentials and file path:

import requests
import 
import os

def load_image_file(image_path):
    """Read image file in binary mode"""
    with open(image_path, 'rb') as image_file:
        return image_file.read()

class TextInOCRProcessor:
    def __init__(self, image_path):
        # Retrieve your credentials from "Workspace - Account Settings - Developer Information"
        # The values below are placeholders
        self.app_id = 'your_x_ti_app_id'
        self.secret_code = 'your_x_ti_secret_code'
        self.image_path = image_path
    
    def extract_text(self):
        """Perform OCR on the provided image"""
        api_endpoint = 'https://api.textin.com/ai/service/v2/recognize'
        headers = {}
        
        try:
            image_data = load_image_file(self.image_path)
            headers['x-ti-app-id'] = self.app_id
            headers['x-ti-secret-code'] = self.secret_code
            
            response = requests.post(api_endpoint, data=image_data, headers=headers)
            return response.text
        except Exception as error:
            return str(error)

if __name__ == "__main__":
    # Replace 'sample_image.jpg' with your actual image file path
    ocr_processor = TextInOCRProcessor('sample_image.jpg')
    recognition_result = ocr_processor.extract_text()
    print(recognition_result)

The output displays the recognized text along with positional coordinates for each identified text element in the image.

API Experience and Capabilities

During implementation of the TextIn OCR API, several notable advantages became apparent:

  • Rapid Response Time: The API delivers near-instantaneous responses from image submission to recognition result receipt. This speed significantly enhances workflow continuity, enabling efficient processing of large document volumes without noticeable delays.
  • High Recognition Accuracy: The system demonstrates exceptional accuracy in identifying text from both clear printed documents and challenging handwritten content. This reliability reduces the need for subsequent verification processes, ensuring data integrity for critical business decisions and analytics.
  • Developer-Friendly Implementation: The API offers straightforward integration through simple HTTP requests. Comprehensive documentation and abundant examples allow developers to implement the solution quickly, even without extensive OCR experience.
  • Versatility and Flexibility: Beyond basic text recognition, the API supports multiple languages and document formats. This adaptability makes it suitable for diverse applications, from simple document digitization to complex data extraction and analysis scenarios.

The TextIn OCR API serves as a robust technical foundation for applications requiring text extraction capabilities, combining speed, precision, and ease of implementation to enhance development efficiency and product quality.

Tags: OCR API TextIn python Text Recognition

Posted on Fri, 09 Oct 2026 16:45:29 +0000 by foid025