US Mail OCR

Mindee’s US Mail OCR API uses deep learning to automatically, accurately, and instantaneously parse your documents details. In a few seconds, the API extracts a set of data from your PDFs or photos of US mails, including:

  • Sender Name

  • Sender Address

  • Recipient Names

  • Recipient Addresses

The US Mail OCR API supports documents from the US. The documents from other nationalities and states are not supported with this model.

Set up the API

Create an API key

To begin using the Mindee V1 OCR API, your first step is to create your V1 API key.

  1. To test your API, you can use the sample document provided below.

  2. Access your US Mail OCR by clicking on the corresponding product card in the Document Catalog

  3. From the left navigation, go to documentation > API Reference, you'll find sample code in popular languages and command line.

from mindee import Client, product, AsyncPredictResponse

# Init a new client
mindee_client = Client(api_key="my-api-key-here")

# Load a file from disk
input_doc = mindee_client.source_from_path("/path/to/the/file.ext")

# Load a file from disk and enqueue it.
result: AsyncPredictResponse = mindee_client.enqueue_and_parse(
    product.us.UsMailV2,
    input_doc,
)

# Print a brief summary of the parsed data
print(result.document)
  • Replace my-api-key-here with your new API key, or use the select an API key feature and it will be filled automatically.

  • Copy and paste the sample code of your desired choice in your application, code environment, terminal etc.

  • Replace /path/to/the/file.ext with the path to your input document.

  1. Run your code. You will receive a JSON response with your document details.

API Response

Here is the full JSON response you get when you call the API:

{
    "api_request": {
        "error": {},
        "resources": [
            "document",
            "job"
        ],
        "status": "success",
        "status_code": 200,
        "url": "https://api.mindee.net/v1/products/mindee/us_mail/v2/documents/eb4c9ccc-a20c-46de-9f75-fd6fdc5115ec"
    },
    "document": {
        "id": "eb4c9ccc-a20c-46de-9f75-fd6fdc5115ec",
        "inference": {
            "extras": {},
            "finished_at": "2024-10-30T14:54:19.789000",
            "is_rotation_applied": true,
            "pages": [
                {
                    "extras": {},
                    "id": 0,
                    "orientation": {
                        "value": 0
                    },
                    "prediction": {}
                }
            ],
            "prediction": {
                "recipient_addresses": [
                    {
                        "city": "Detroit",
                        "complete": "1234 Market Street PMB 4321, Detroit, Michigan 12345",
                        "is_address_change": false,
                        "postal_code": "12345",
                        "private_mailbox_number": "4321",
                        "state": "MI",
                        "street": "1234 Market Street"
                    }
                ],
                "recipient_names": [
                    {
                        "value": "Jane Doe"
                    }
                ],
                "sender_address": {
                    "city": "Dallas",
                    "complete": "54321 Elm Street, Dallas, Texas 54321",
                    "postal_code": "54321",
                    "state": "TX",
                    "street": "54321 Elm Street"
                },
                "sender_name": {
                    "value": "zed"
                }
            },
            "processing_time": 3.072,
            "product": {
                "features": [
                    "sender_name",
                    "sender_address",
                    "recipient_names",
                    "recipient_addresses"
                ],
                "name": "mindee/us_mail",
                "type": "standard",
                "version": "2.0"
            },
            "started_at": "2024-10-30T14:54:16.506000"
        },
        "n_pages": 1,
        "name": "US-mail-sample.jpg"
    },
    "job": {
        "available_at": "2024-10-30T14:54:19.799000",
        "error": {},
        "id": "02e29373-20fe-4a92-8245-7edc9d4ca8e5",
        "issued_at": "2024-10-30T14:54:16.506000",
        "status": "completed"
    }
}

You can find the prediction within the prediction key found in document > inference > prediction for document-level predictions: it contains the different fields extracted at the document level, meaning that for multi-pages PDFs, we reconstruct a single object using all the pages.

Detailed Field Information

Using the above document example the following are the basic fields that can be extracted.

Sender Name

  • sender_name: The name of the sender.

{
  "sender_name": {
    "value": "zed"
  }
}

Sender Address

  • sender_address: The address of the sender.

    • complete: The complete address of the sender.

    • street: The street of the sender's address.

    • city: The city of the sender's address.

    • state: Second part of the ISO 3166-2 code, consisting of two letters indicating the US State.

    • postal_code: The postal code of the sender's address.

{
  "sender_address": {
    "city": "Dallas",
    "complete": "54321 Elm Street, Dallas, Texas 54321",
    "postal_code": "54321",
    "state": "TX",
    "street": "54321 Elm Street"
  }
}

Recipient Names

  • recipient_names: The names of the recipients.

{
  "recipient_names": [
    {
      "value": "Jane Doe"
    }
  ]
}

Recipient Addresses

  • recipient_address: The address of the recipients.

    • complete: The complete address of the recipient.

    • street: The street of the recipient’s address.

    • city: The city of the recipient’s address.

    • state: Second part of the ISO 3166-2 code, consisting of two letters indicating the US State.

    • postal_code: The postal code of the recipient’s address.

{
  "recipient_addresses": [
    {
      "city": "Detroit",
      "complete": "1234 Market Street PMB 4321, Detroit, Michigan 12345",
      "is_address_change": false,
      "postal_code": "12345",
      "private_mailbox_number": "4321",
      "state": "MI",
      "street": "1234 Market Street"
    }
  ]
}

Last updated

Was this helpful?