Detect Text

Easily detect text in a given image (accessible by a public URL) by making a POST request to the OCR endpoint.

🚧

Note

When using the Try It feature in Readme.io, you might need to generate a new Access Token instead of the provided example as the same might have expired.

OCR Endpoint

https://einsteinocr.netlify.app/.netlify/functions/ocr
curl --request POST \
  --url https://einsteinocr.netlify.app/.netlify/functions/ocr \
  --header 'Content-Type: application/json' \
  --data '{"url":"https://api.einstein.ai/v2/vision/ocr","token":"IFMVSM2CIRJU2Q2WGZITGSBWGRME6URTK5LTKUSXKZBTGTSJIZHUMQKHK5IFGSKEJRKUWU2NIREESN2DIEZFITKBJRGECUSDI5LUUNCTI43EMTCVLJKTORCQLBBFES2RKZLUESZULEZUKVKEKVLFMSCVKJDE4USBJVFFC7COIE","task":"contact","modelId":"OCRModel","sampleLocation":"https://www.asianbusinesscards.com/wp-content/uploads/2019/03/chinese-business-card-translation-samples-walmart-890-eng.jpg"}'

Understanding the Request Body

NodeDescription
urlThis will be a constant and will always be - https://api.einstein.ai/v2/vision/ocr
tokenThe access token obtained from the Token endpoint
taskPossible values include: contact and text when the modelId is OCRModel

Possible values include: table when the modelId is tabulatev2
modelIdPossible values include: OCRModel and tabulatev2
sampleLocationA public URL that holds the image to be used for OCR

📘

Read https://metamind.readme.io/docs/what-is-einstein-ocr for more details

Swagger Schema for OCR Endpoint

Use the below Swagger 2.0 Schema to create an External Service Registration in Salesforce

{
  "swagger": "2.0",
  "info": {
    "title": "Einstein OCR Simplified",
    "description": "Salesforce External Services Compatible Einstein OCR API | Powered by Netlify | Built by www.shrutisridharan.com",
    "version": "1.0.0"
  },
  "host": "einsteinocr.netlify.app",
  "schemes": [
    "https"
  ],
  "paths": {
    "/.netlify/functions/ocr": {
      "post": {
        "consumes": [
          "application/json"
        ],
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "in": "body",
            "name": "req",
            "required": true,
            "schema": {
              "$ref": "#/definitions/req"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Operation",
            "schema": {
              "$ref": "#/definitions/resp"
            }
          }
        }
      }
    }
  },
  "definitions": {
    "req": {
      "type": "object",
      "properties": {
        "url": {
          "type": "string"
        },
        "token": {
          "type": "string"
        },
        "task": {
          "type": "string"
        },
        "modelId": {
          "type": "string"
        },
        "sampleLocation": {
          "type": "string"
        }
      }
    },
    "resp": {
      "type": "object",
      "properties": {
        "statusCode": {
          "type": "number"
        },
        "status": {
          "type": "string"
        },
        "data": {
          "type": "object",
          "properties": {
            "probabilities": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "probability": {
                    "type": "number"
                  },
                  "label": {
                    "type": "string"
                  },
                  "label": {
                    "type": "string"
                  },
                  "attributes": {
                    "type": "object",
                    "properties": {
                      "tag": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
Language
Click Try It! to start a request and see the response here!