SimpleTex DocumentationSimpleTex Documentation
Home
FAQ
API
Tutorials
Blog
Updates
Use now
  • 简体中文
  • English
Home
FAQ
API
Tutorials
Blog
Updates
Use now
  • 简体中文
  • English
  • Description

    • Open Platform Description
  • Platform Authentication

    • Authentication Description
    • UAT Method
    • APP Authentication Method
    • API Response Information
    • Example Code
  • API Capabilities

    • Formula Recognition
    • General Image Recognition
    • Document Image Recognition (PDF Recognition)
    • Other Services

Example Code

  • Python Example Code

UAT Method


import requests
SIMPLETEX_UAT="xxxxx"
api_url="https://server.simpletex.net/xxxxx"  # API endpoint
data = { } # Request parameter data (non-file parameters), fill in as needed, refer to each API's parameter description
header={ "token": SIMPLETEX_UAT } # Authentication information, using UAT method here
file=[("file",("test.png",open("test.png", 'rb')))] # Request file, field name is generally "file"
res = requests.post(api_url, files=file, data=data, headers=header) # Use requests library to upload file
print(json.loads(res.text))

  • Python Example Code

APP Method

import datetime
import json
import requests
from random import Random
import hashlib

SIMPLETEX_APP_ID = "xxxxx"
SIMPLETEX_APP_SECRET = "xxxxxxxxxxxxxxx"

def random_str(randomlength=16):
    str = ''
    chars = 'AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz0123456789'
    length = len(chars) - 1
    random = Random()
    for i in range(randomlength):
        str += chars[random.randint(0, length)]
    return str


def get_req_data(req_data, appid, secret):
    header = {}
    header["timestamp"] = str(int(datetime.datetime.now().timestamp()))
    header["random-str"] = random_str(16)
    header["app-id"] = appid
    pre_sign_string = ""
    sorted_keys = list(req_data.keys()) + list(header)
    sorted_keys.sort()
    for key in sorted_keys:
        if pre_sign_string:
            pre_sign_string += "&"
        if key in header:
            pre_sign_string += key + "=" + str(header[key])
        else:
            pre_sign_string += key + "=" + str(req_data[key])

    pre_sign_string += "&secret=" + secret
    header["sign"] = hashlib.md5(pre_sign_string.encode()).hexdigest()
    return header, req_data


img_file = {"file": open("./image/1.png", 'rb')}
data = { } # Request parameter data (non-file parameters), fill in as needed, refer to each API's parameter description
header, data = get_req_data(data, SIMPLETEX_APP_ID, SIMPLETEX_APP_SECRET)
res = requests.post("https://server.simpletex.net/xxxx", files=img_file, data=data, headers=header)

print(json.loads(res.text))

Last Updated:: 4/25/25, 4:42 PM
Prev
API Response Information