PRODUCTDEMO

  • OCR Results
  • JSON Results

                

API Document

1. The image is a base64 stream
Interface address: https://flyocr.com/api/v2/recogInvoiveBase64.do
Interface call method: post
Interface receiving parameter:
Serial number name type required Instructions
1 img String Yes Uploaded file (base64 stream of pictures)
2 key String Yes User ocrKey
3 token String Yes Authorization token
3 timestamp String Yes Yes The number of seconds with timestamp January 1 1970 00:00:00 GMT until now
5 typeId Integer Yes Recognition type:20090
6 cutImage Integer No Default to 0 does not return cropping image 1 returns
2. The image is in file format
Interface address: https://flyocr.com/api/v2/recogInvoive.do
Interface call method: post
Interface receiving parameter:
Serial number name type required Instructions
1 file MultipartFile Yes Uploaded file (The field name of the uploaded file must be "file")
2 key String Yes User ocrKey
3 token String Yes Authorization token
4 timestamp String Yes timestamp is the number of seconds from January 1 1970 00:00:00 GMT to the present
5 typeId Integer Yes Recognition type:20090
6 cutImage Integer No Default to 0 does not return cropping image 1 returns
3. Sample code
  • Java
  • Python
  • Javascript
  • PHP
  • C#
  • C++
  • GO
  • Node.js
  • IOS
  • Android

//dependency:okio-1.14.0,shiro-core-1.4.0,okhttp-3.11.0
import okhttp3.MultipartBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import org.apache.shiro.crypto.hash.Md5Hash;
import java.io.IOException;
import java.time.Instant;

public class Test {

    public static void main(String[] args) throws IOException {

        String key = "M***********g";
        String secret = "3***********6";

        long timestamp = Instant.now().toEpochMilli();
        String token = new Md5Hash(key + "+" + timestamp + "+" + secret).toString();

        RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM)
                .addFormDataPart("img", "/9j")
                .addFormDataPart("key", key)
                .addFormDataPart("token", token)
                .addFormDataPart("timestamp", String.valueOf(timestamp))
                .addFormDataPart("typeId", "20090")
                .build();
        Request request = new Request.Builder()
                .url("https://flyocr.com/api/v2/recogInvoiveBase64.do")
                .method("POST", body)
                .build();
        OkHttpClient client = new OkHttpClient();
        Response response = client.newCall(request).execute();
        System.out.println(response.body().string());
    }
}

import requests
import hashlib
import time

def generate_token(key, timestamp, secret):
    hash_string = f"{key}+{timestamp}+{secret}"
    return hashlib.md5(hash_string.encode()).hexdigest()

def make_request():
    key = "M***********g"
    secret = "3***********6"
    timestamp = int(time.time() * 1000)
    token = generate_token(key, timestamp, secret)

    files = {
        'key': (None, key),
        'typeId': (None, '20090'),
        'timestamp': (None, str(timestamp)),
        'token': (None, token),
        'img': (None, "/9j")
    }

    response = requests.post('https://flyocr.com/api/v2/recogInvoiveBase64.do', files=files)
    return response.text

if __name__ == '__main__':
    response_text = make_request()
    print(response_text)

const crypto = require('crypto');
const FormData = require('form-data');
const $ = require('jquery');

var key = "M***********g";
var secret = "3***********6";
var timestamp = Date.now();

var token = crypto.createHash('md5').update(key + "+" + timestamp + "+" + secret).digest('hex');

var form = new FormData();
form.append("key", key);
form.append("typeId", "20090");
form.append("timestamp", String(timestamp));
form.append("token", token);
form.append("img", "/9j");

var settings = {
 "url": "https://flyocr.com/api/v2/recogInvoiveBase64.do",
 "method": "POST",
 "timeout": 0,
 "processData": false,
 "mimeType": "multipart/form-data",
 "contentType": false,
 "data": form,
 "success": function(response) {
     console.log(response);
 },
 "error": function(xhr, status, error) {
     console.error(status, error);
 }
};

$.ajax(settings);

<?php
$key = "M***********g";
$secret = "3***********6";
$timestamp = time();
$token = md5($key . '+' . $timestamp . '+' . $secret);

$data = array(
    'key' => $key,
    'typeId' => '20090',
    'timestamp' => $timestamp,
    'token' => $token,
    'img' => '/9j'
);

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://flyocr.com/api/v2/recogInvoiveBase64.do",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => $data,
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
?>

using System;
using System.IO;
using System.Net.Http;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;

public class Test
{
    public static async Task Main(string[] args)
    {
        string key = "M***********g";
        string secret = "3***********6";
        long timestamp = DateTimeOffset.Now.ToUnixTimeMilliseconds();

        using (var md5 = MD5.Create())
        {
            string rawData = key + "+" + timestamp + "+" + secret;
            byte[] inputBytes = Encoding.UTF8.GetBytes(rawData);
            byte[] hashBytes = md5.ComputeHash(inputBytes);

            var sb = new StringBuilder();
            foreach (var t in hashBytes)
            {
                sb.Append(t.ToString("X2"));
            }
            string token = sb.ToString();

            using (var client = new HttpClient())
            {
                using (var content = new MultipartFormDataContent())
                {
                    content.Add(new StringContent(key), "key");
                    content.Add(new StringContent("20090"), "typeId");
                    content.Add(new StringContent(timestamp.ToString()), "timestamp");
                    content.Add(new StringContent(token), "token");
                    content.Add(new StringContent("/91"), "img");

                    string url = "https://flyocr.com/api/v2/recogInvoiveBase64.do";
                    var response = await client.PostAsync(url, content);

                    string responseString = await response.Content.ReadAsStringAsync();
                    Console.WriteLine(responseString);
                }
            }
        }
    }
}

#include <iostream>
#include <sstream>
#include <string>
#include <curl/curl.h>
#include <openssl/md5.h>
#include <iomanip>
#include <chrono>

std::string getMd5Hash(const std::string& data) {
    unsigned char result[MD5_DIGEST_LENGTH];
    MD5(reinterpret_cast<const unsigned char*>(data.c_str()), data.size(), result);

    std::ostringstream sout;
    sout << std::hex << std::setfill('0');
    for (auto c : result) {
        sout << std::setw(2) << static_cast<int>(c);
    }

    return sout.str();
}

int main() {
    CURL* curl;
    CURLcode res;

    std::string key = "M***********g";
    std::string secret = "3***********6";
    auto timestamp = std::chrono::duration_cast<std::chrono::milliseconds>(
        std::chrono::system_clock::now().time_since_epoch()
    ).count();
    std::string token = getMd5Hash(key + "+" + std::to_string(timestamp) + "+" + secret);

    std::string data = "key=" + key + "&typeId=2×tamp=" +
                       std::to_string(timestamp) + "&token=" + token +
                       "&img=/9j";

    curl = curl_easy_init();
    if (curl) {
        curl_easy_setopt(curl, CURLOPT_URL, "https://flyocr.com/api/v2/recogInvoiveBase64.do");
        curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data.c_str());

        res = curl_easy_perform(curl);
        if (res != CURLE_OK) {
            std::cerr << "curl_easy_perform() failed: " << curl_easy_strerror(res) << '\n';
        }
        curl_easy_cleanup(curl);
    }

    return 0;
}

package main

import (
    "bytes"
    "crypto/md5"
    "fmt"
    "io"
    "mime/multipart"
    "net/http"
    "time"
)

func main() {
    key := "M***********g"
    secret := "3***********6"
    timestamp := time.Now().UnixNano() / int64(time.Millisecond)
    tokenData := fmt.Sprintf("%s+%d+%s", key, timestamp, secret)

    h := md5.New()
    _, _ = io.WriteString(h, tokenData)
    token := fmt.Sprintf("%x", h.Sum(nil))

    body := &bytes.Buffer{}
    writer := multipart.NewWriter(body)

    _ = writer.WriteField("key", key)
    _ = writer.WriteField("typeId", "20090")
    _ = writer.WriteField("timestamp", fmt.Sprintf("%d", timestamp))
    _ = writer.WriteField("token", token)
    _ = writer.WriteField("img", "/9j")

    writer.Close()

    req, err := http.NewRequest("POST", "https://flyocr.com/api/v2/recogInvoiveBase64.do", body)
    if err != nil {
        fmt.Println("Error creating request:", err)
        return
    }
    req.Header.Set("Content-Type", writer.FormDataContentType())

    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        fmt.Println("Error sending request:", err)
        return
    }
    defer resp.Body.Close()

    respBody, err := io.ReadAll(resp.Body)
    if err != nil {
        fmt.Println("Error reading response:", err)
        return
    }

    fmt.Println("Response:", string(respBody))
}

const crypto = require('crypto');
const fetch = require('node-fetch');
const FormData = require('form-data');

const key = "M***********g";
const secret = "3***********6";

const timestamp = Date.now();
const token = crypto
  .createHash('md5')
  .update(`++`)
  .digest('hex');

const form = new FormData();
form.append('key', key);
form.append('typeId', '20090');
form.append('timestamp', timestamp.toString());
form.append('token', token);
form.append('img', '/9j');

fetch('https://flyocr.com/api/v2/recogInvoiveBase64.do', {
  method: 'POST',
  body: form
})
.then(response => response.text())
.then(console.log);

import Foundation
import Alamofire

func MD5(string: String) -> String {
    let length = Int(CC_MD5_DIGEST_LENGTH)
    let messageData = string.data(using:.utf8)!
    var digestData = Data(count: length)

    _ = digestData.withUnsafeMutableBytes { digestBytes -> UInt8 in
        messageData.withUnsafeBytes { messageBytes -> UInt8 in
            if let messageBytesBaseAddress = messageBytes.baseAddress,
                let digestBytesBlindMemory = digestBytes.bindMemory(to: UInt8.self).baseAddress {
                let messageLength = CC_LONG(messageData.count)
                CC_MD5(messageBytesBaseAddress, messageLength, digestBytesBlindMemory)
            }
            return 0
        }
    }
    return digestData.map { String(format: "%02hhx", $0) }.joined()
}

let key = "M***********g"
let secret = "3***********6"
let timestamp = "\(Int(Date().timeIntervalSince1970 * 1000))"
let token = MD5(string: "\(key)+\(timestamp)+\(secret)")

let parameters: [String: String] = [
    "key": key,
    "token": token,
    "timestamp": timestamp,
    "typeId": "20090",
    "img": "/9j"
]

AF.upload(multipartFormData: { multipartFormData in
    for (key, value) in parameters {
        multipartFormData.append(value.data(using: .utf8)!, withName: key)
    }
}, to: "https://flyocr.com/api/v2/recogInvoiveBase64.do")
.response { response in
    debugPrint(response)
}

import java.io.IOException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.concurrent.TimeUnit;

import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;

public class MyClass {

    public static void main(String[] args) {
        String key = "M***********g";
        String secret = "3***********6";

        long timestamp = System.currentTimeMillis();
        String tokenString = key + "+" + timestamp + "+" + secret;
        String token = md5(tokenString);

        RequestBody requestBody = new MultipartBody.Builder()
                .setType(MultipartBody.FORM)
                .addFormDataPart("key", key)
                .addFormDataPart("typeId", "20090")
                .addFormDataPart("timestamp", Long.toString(timestamp))
                .addFormDataPart("token", token)
                .addFormDataPart("img", "/91")
                .build();

        Request request = new Request.Builder()
                .url("https://flyocr.com/api/v2/recogInvoiveBase64.do")
                .post(requestBody)
                .build();

        OkHttpClient client = new OkHttpClient.Builder()
                .connectTimeout(30, TimeUnit.SECONDS)
                .writeTimeout(30, TimeUnit.SECONDS)
                .readTimeout(30, TimeUnit.SECONDS)
                .build();

        try {
            Response response = client.newCall(request).execute();
            System.out.println(response.body().string());
            response.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static String md5(String s) {
        try {
            MessageDigest digest = MessageDigest.getInstance("MD5");
            digest.update(s.getBytes());
            byte messageDigest[] = digest.digest();

            StringBuilder hexString = new StringBuilder();
            for (byte aMessageDigest : messageDigest) {
                String h = Integer.toHexString(0xFF & aMessageDigest);
                while (h.length() < 2)
                    h = "0" + h;
                hexString.append(h);
            }
            return hexString.toString();
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
        return "";
    }
}
More API Introduction

PRODUCTFEATURES

APPLICATIONSCENARIOS

Invoices Management

Our Invoices OCR Recognition API interface can enter relevant VAT deduction voucher through OCR recognition technology when companies are deducting input tax, and check the tax amount of input invoices automatically to keep the invoice tax amount consistent.

Enterprise Fee Control System

Our invoices OCR identification technology can realize automation like the bill upload, verification, storage so as to help enterprises to improve the monitoring of expense flow, and reduce the cost of enterprise management expense control and supervision.

Employee Reimbursement Process

Our Invoices Recognition OCR API interface can be integrated into corporate financial system and CRM system, extract invoice information in seconds, support invoice inspection, reduce the burden on financial personnel, effectively avoid fiscal and tax risks, and reduce costs and increasing efficiency for enterprises.

Contact +86 173 1063 0901 Please leave your email

Intelligent Recognition

News|Blog

Stay in touch with FlyOCR

Please log in to experienceJump to login after 3 seconds

OK Cancel
Loading...
Operation verification
x

Fill in order with that colorThe same color verification code

Stay in touch with FlyOCR

Sign up to emails about FlyOCR news, product updates, and more.