ID Card FR OCR

Mindee’s ID Card France OCR API uses deep learning to automatically, accurately, and instantaneously parse your ID card details. In under a second, the API extracts a set of data from your PDFs or photos of ID cards, including:

  • Nationality

  • Card Access Number

  • Document Number

  • Given Names

  • Surname

  • Alternate Name

  • Date of Birth

  • Place of Birth

  • Gender

  • Expiry Date

  • Image Orientation

  • MRZ Line 1

  • MRZ Line 2

  • MRZ Line 3

  • Date of Issue

  • Issuing Authority

  • Document Type

  • Document Sides

The ID Card France OCR API supports the new and old format for all people in France. The ID cards of 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. You'll need a French ID card. You can use one of the sample documents provided below.

  2. Access your Identity Card API by clicking on the Carte nationale d'Identité 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, documents

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

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

# Parse the Carte Nationale d'Identité by passing the appropriate type
result = input_doc.parse(documents.fr.TypeIdCardV1)

# 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 the ID Card details.

API Response

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

{
  "api_request": {
    "error": {},
    "resources": [
      "document"
    ],
    "status": "success",
    "status_code": 201,
    "url": "https://api.mindee.net/v2/products/mindee/idcard_fr/v2/predict"
  },
  "document": {
    "id": "07f38b63-189e-49d4-a07b-bdc0f49a8135",
    "name": "sample_Id_Card.jpg",
    "n_pages": 1,
    "is_rotation_applied": true,
    "inference": {
      "started_at": "2023,-05-06T16:37:28",
      "finished_at": "2023-05-06T16:37:29",
      "processing_time": 1.755,
      "pages": [
        {
          "id": 0,
          "orientation": {"value": 0},
          "prediction": { .. },
          "extras": {}
        }
      ],
      "prediction": { .. },
      "extras": {}
    }
  }
}

You can find the prediction within the prediction key found in two locations:

  • 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 IdD Card object using all the pages.

  • In document > inference > pages[ ] > prediction for page-level predictions: it gives the prediction for each page independently. With images, there is only one element on this array, but with PDFs, you can find the extracted data for each PDF page.

Each predicted field may contain one or several values:

  • a confidence score

  • a polygon highlighting the information location

  • a page_id where the information was found (document level only)

{
    "extras": {},
    "finished_at": "2023-08-01T08:03:02.691624",
    "is_rotation_applied": true,
    "pages": [
        {
            "extras": {},
            "id": 0,
            "orientation": {"value": 0},
            "prediction": {
                "alternate_name": {
                    "confidence": 0.51,
                    "polygon": [
                        [0.393, 0.648],
                        [0.722, 0.648],
                        [0.722, 0.682],
                        [0.393, 0.682]
                    ],
                    "value": "usage NOM D'USAGE"
                },
                "authority": {
                    "confidence": 0,
                    "polygon": [],
                    "value": null
                },
                "birth_date": {
                    "confidence": 0.99,
                    "polygon": [
                        [0.749, 0.491],
                        [0.929, 0.491],
                        [0.929, 0.525],
                        [0.749, 0.525]
                    ],
                    "value": "1990-07-13"
                },
                "birth_place": {
                    "confidence": 0.99,
                    "polygon": [
                        [0.394, 0.562],
                        [0.485, 0.562],
                        [0.485, 0.598],
                        [0.394, 0.598]
                    ],
                    "value": "PARIS"
                },
                "card_access_number": {
                    "confidence": 0.99,
                    "polygon": [
                        [0.745, 0.805],
                        [0.959, 0.805],
                        [0.959, 0.857],
                        [0.745, 0.857]
                    ],
                    "value": "546497"
                },
                "document_number": {
                    "confidence": 0.99,
                    "polygon": [
                        [0.385, 0.718],
                        [0.687, 0.718],
                        [0.687, 0.768],
                        [0.385, 0.768]
                    ],
                    "value": "D2H6862M2"
                },
                "document_side": {
                    "confidence": 1,
                    "value": "RECTO"
                },
                "document_type": {
                    "confidence": 1,
                    "value": "NEW"
                },
                "expiry_date": {
                    "confidence": 0.88,
                    "polygon": [
                        [0.749, 0.724],
                        [0.933, 0.724],
                        [0.933, 0.759],
                        [0.749, 0.759]
                    ],
                    "value": "2030-02-11"
                },
                "gender": {
                    "confidence": 0.99,
                    "polygon": [
                        [0.396, 0.487],
                        [0.417, 0.487],
                        [0.417, 0.52],
                        [0.396, 0.52]
                    ],
                    "value": "F"
                },
                "given_names": [
                    {
                        "confidence": 0.74,
                        "polygon": [
                            [
                                0.398,
                                0.362
                            ],
                            [
                                0.62,
                                0.362
                            ],
                            [
                                0.62,
                                0.401
                            ],
                            [
                                0.398,
                                0.401
                            ]
                        ],
                        "value": "Maëlis-gaëlle"
                    },
                    {
                        "confidence": 0.99,
                        "polygon": [
                            [
                                0.635,
                                0.363
                            ],
                            [
                                0.727,
                                0.363
                            ],
                            [
                                0.727,
                                0.398
                            ],
                            [
                                0.635,
                                0.398
                            ]
                        ],
                        "value": "Marie"
                    }
                ],
                "issue_date": {
                    "confidence": 0,
                    "polygon": [],
                    "value": null
                },
                "mrz1": {
                    "confidence": 0,
                    "polygon": [],
                    "value": null
                },
                "mrz2": {
                    "confidence": 0,
                    "polygon": [],
                    "value": null
                },
                "mrz3": {
                    "confidence": 0,
                    "polygon": [],
                    "value": null
                },
                "nationality": {
                    "confidence": 0.99,
                    "polygon": [
                        [0.501, 0.487],
                        [0.566, 0.487],
                        [0.566, 0.522],
                        [0.501, 0.522]
                    ],
                    "value": "FRA"
                },
                "orientation": {
                    "confidence": 0.99,
                    "degrees": 0
                },
                "surname": {
                    "confidence": 0.84,
                    "polygon": [
                        [0.396, 0.236],
                        [0.558, 0.236],
                        [0.558, 0.275],
                        [0.396, 0.275]
                    ],
                    "value": "MARTIN"
                }
            }
        }
    ],
    "prediction": {
        "alternate_name": {
            "confidence": 0.51,
            "page_id": 0,
            "polygon": [
                [0.393, 0.648],
                [0.722, 0.648],
                [0.722, 0.682],
                [0.393, 0.682]
            ],
            "value": "usage NOM D'USAGE"
        },
        "authority": {
            "confidence": 0,
            "page_id": null,
            "polygon": [],
            "value": null
        },
        "birth_date": {
            "confidence": 0.99,
            "page_id": 0,
            "polygon": [
                [0.749, 0.491],
                [0.929, 0.491],
                [0.929, 0.525],
                [0.749, 0.525]
            ],
            "value": "1990-07-13"
        },
        "birth_place": {
            "confidence": 0.99,
            "page_id": 0,
            "polygon": [
                [0.394, 0.562],
                [0.485, 0.562],
                [0.485, 0.598],
                [0.394, 0.598]
            ],
            "value": "PARIS"
        },
        "card_access_number": {
            "confidence": 0.99,
            "page_id": 0,
            "polygon": [
                [0.745, 0.805],
                [0.959, 0.805],
                [0.959, 0.857],
                [0.745, 0.857]
            ],
            "value": "546497"
        },
        "document_number": {
            "confidence": 0.99,
            "page_id": 0,
            "polygon": [
                [0.385, 0.718],
                [0.687, 0.718],
                [0.687, 0.768],
                [0.385, 0.768]
            ],
            "value": "D2H6862M2"
        },
        "document_side": {
            "confidence": 1,
            "value": "RECTO"
        },
        "document_type": {
            "confidence": 1,
            "value": "NEW"
        },
        "expiry_date": {
            "confidence": 0.88,
            "page_id": 0,
            "polygon": [
                [0.749, 0.724],
                [0.933, 0.724],
                [0.933, 0.759],
                [0.749, 0.759]
            ],
            "value": "2030-02-11"
        },
        "gender": {
            "confidence": 0.99,
            "page_id": 0,
            "polygon": [
                [0.396, 0.487],
                [0.417, 0.487],
                [0.417, 0.52],
                [0.396, 0.52]
            ],
            "value": "F"
        },
        "given_names": [
            {
                "confidence": 0.74,
                "page_id": 0,
                "polygon": [
                    [0.398, 0.362],
                    [0.62, 0.362],
                    [0.62, 0.401],
                    [0.398, 0.401]
                ],
                "value": "Maëlis-gaëlle"
            },
            {
                "confidence": 0.99,
                "page_id": 0,
                "polygon": [
                    [0.635, 0.363],
                    [0.727, 0.363],
                    [0.727, 0.398],
                    [0.635, 0.398]
                ],
                "value": "Marie"
            }
        ],
        "issue_date": {
            "confidence": 0,
            "page_id": null,
            "polygon": [],
            "value": null
        },
        "mrz1": {
            "confidence": 0,
            "page_id": null,
            "polygon": [],
            "value": null
        },
        "mrz2": {
            "confidence": 0,
            "page_id": null,
            "polygon": [],
            "value": null
        },
        "mrz3": {
            "confidence": 0,
            "page_id": null,
            "polygon": [],
            "value": null
        },
        "nationality": {
            "confidence": 0.99,
            "page_id": 0,
            "polygon": [
                [0.501, 0.487],
                [0.566, 0.487],
                [0.566, 0.522],
                [0.501, 0.522]
            ],
            "value": "FRA"
        },
        "surname": {
            "confidence": 0.84,
            "page_id": 0,
            "polygon": [
                [0.396, 0.236],
                [0.558, 0.236],
                [0.558, 0.275],
                [0.396, 0.275]
            ],
            "value": "MARTIN"
        }
    },
    "processing_time": 1.272,
    "product": {
        "features": [
            "nationality",
            "card_access_number",
            "document_number",
            "given_names",
            "surname",
            "alternate_name",
            "birth_date",
            "birth_place",
            "gender",
            "expiry_date",
            "orientation",
            "mrz1",
            "mrz2",
            "mrz3",
            "issue_date",
            "authority",
            "document_type",
            "document_side"
        ],
        "name": "mindee/idcard_fr",
        "type": "standard",
        "version": "2.0"
    },
    "started_at": "2023-08-01T08:03:01.419255"
}

Detailed Field Information

Depending on the field type specified, additional attributes can be extracted from the ID card object. Using the above ID card example the following are the basic fields that can be extracted.

Nationality

  • nationality: The nationality is classified, issued in a three-letter code following the ISO 3166-1 format.

{
  "nationality": {
                    "confidence": 0.99,
                    "polygon": [
                        [0.501, 0.487],
                        [0.566, 0.487],
                        [0.566, 0.522],
                        [0.501, 0.522]
                    ],
                    "value": "FRA"
                }
}

Card Access Number

  • card_access_number: Unique CAN of the document. There is no associated field name for this number on the card itself.

{
  "card_access_number": {
                    "confidence": 0.99,
                    "polygon": [
                        [0.745, 0.805],
                        [0.959, 0.805],
                        [0.959, 0.857],
                        [0.745, 0.857]
                    ],
                    "value": "546497"
                }
}

Document Number

  • document_number: The unique ID number of the document which is likewise titled.

{
  "document_number": {
                    "confidence": 0.99,
                    "polygon": [
                        [0.385, 0.718],
                        [0.687, 0.718],
                        [0.687, 0.768],
                        [0.385, 0.768]
                    ],
                    "value": "D2H6862M2"
                }
}

Given Names

  • given_names: The given Name(s) of the card holder. If there are several names, they are all output as in the following example:

{
  "given_names": [
                    {
                        "confidence": 0.74,
                        "polygon": [
                            [
                                0.398,
                                0.362
                            ],
                            [
                                0.62,
                                0.362
                            ],
                            [
                                0.62,
                                0.401
                            ],
                            [
                                0.398,
                                0.401
                            ]
                        ],
                        "value": "Maëlis-gaëlle"
                    },
    {
                        "confidence": 0.99,
                        "polygon": [
                            [
                                0.635,
                                0.363
                            ],
                            [
                                0.727,
                                0.363
                            ],
                            [
                                0.727,
                                0.398
                            ],
                            [
                                0.635,
                                0.398
                            ]
                        ],
                        "value": "Marie"
                    }
}

Surname

  • surname: The last name of the document holder. f there are several surnames, all surnames are output together.

{
  "surname": {
                    "confidence": 0.84,
                    "polygon": [
                        [0.396, 0.236],
                        [0.558, 0.236],
                        [0.558, 0.275],
                        [0.396, 0.275]
                    ],
                    "value": "MARTIN"
                }
}

Alternate Name

  • alternate_name: The alternate name of the document holder. The same rules apply as for the other names.

{
  "alternate_name": {
                    "confidence": 0.51,
                    "polygon": [
                        [0.393, 0.648],
                        [0.722, 0.648],
                        [0.722, 0.682],
                        [0.393, 0.682]
                    ],
                    "value": "usage NOM D'USAGE"
                }
}

Date Of Birth

  • date_of_birth: The ISO formatted date of birth of the document holder in the ISO 8601 format.

{
  "birth_date": {
                    "confidence": 0.99,
                    "polygon": [
                        [0.749, 0.491],
                        [0.929, 0.491],
                        [0.929, 0.525],
                        [0.749, 0.525]
                    ],
                    "value": "1990-07-13"
                }
}

Place Of Birth

  • place_of_birth: The Place of Birth of the Document holder.

{
  "birth_place": {
            "confidence": 0.99,
            "polygon": [
                [0.394, 0.562],
                [0.485, 0.562],
                [0.485, 0.598],
                [0.394, 0.598]
            ],
            "value": "PARIS"
        }
}

Gender

  • gender: Output in a code consisting of one letter representing the gender of the document owner.

{
  "gender": {
                    "confidence": 0.99,
                    "polygon": [
                        [0.396, 0.487],
                        [0.417, 0.487],
                        [0.417, 0.52],
                        [0.396, 0.52]
                    ],
                    "value": "F"
                }
}

Expiry Date

  • expiry_date: The ISO formatted date of expiry of the document in the ISO 8601 format.

{
  "expiry_date": {
                    "confidence": 0.88,
                    "polygon": [
                        [0.749, 0.724],
                        [0.933, 0.724],
                        [0.933, 0.759],
                        [0.749, 0.759]
                    ],
                    "value": "2030-02-11"
                }
}

Image Orientation

  • image_orientation: Classification indicating the possible rotation of the image. Possible values are:

    • 0

    • 90

    • 270 Images with a rotation of 180 degrees are not supported.

{
  "orientation": {
                    "confidence": 0.99,
                    "degrees": 0
                }
}

MRZ Line 1

  • mrz_line_1: The extraction of the Machine Readable Zone, first line.

{
  "mrz1": {
            "confidence": 0.98,
            "polygon": [
                [0.024, 0.694],
                [0.968, 0.694],
                [0.968, 0.747],
                [0.024, 0.747]
            ],
            "value": "IDFRAX4RTBPFW46<<<<<<<<<<<<<<<"
        }
}

MRZ Line 2

  • mrz_line_2: The extraction of the Machine Readable Zone, second line.

{
  "mrz2": {
            "confidence": 0.96,
            "polygon": [
                [0.024, 0.77],
                [0.992, 0.77],
                [0.992, 0.824],
                [0.024, 0.824]
            ],
            "value": "9007138F3002119FRA<<<<<<<<<<<6"
        }
}

MRZ Line 3

  • mrz_line_3: The extraction of the Machine Readable Zone, third line.

{
  "mrz3": {
            "confidence": 0.91,
            "polygon": [
                [0.024, 0.848],
                [0.997, 0.848],
                [0.997, 0.902],
                [0.024, 0.902]
            ],
            "value": "MARTIN<<MAELYS<GAELLE<MARIE<<<"
        }
}

Date Of Issue

  • date_of_issue: The ISO formatted date of issue of the document in the ISO 8601 format.

{
  "issue_date": {
                    "confidence": 0.99,
                    "polygon": [
                        [0.417, 0.093],
                        [0.584, 0.093],
                        [0.584, 0.131],
                        [0.417, 0.131]
                    ],
                    "value": "2020-02-12"
                }
}

Issuing Authority

  • issuing_authority: The responsible authority for issuing the document.

{
  "authority": {
                    "confidence": 0,
                    "polygon": [],
                    "value": null
                }
}

Document Type

  • document_type: Classification indicating which version of the ID card it is.

    • NEW - the issued version from 2021

    • OLD - the issued version from 1988 - 2021

{
  "document_type": {
                    "confidence": 1,
                    "value": "NEW"
                }
}

Document Sides

  • document_sides: Classification indicating which version of the ID card it is.

    • RECTO - the front side

    • VERSO - the back side

{
  "document_side": {
                    "confidence": 1,
                    "value": "RECTO"
                }
}

Last updated

Was this helpful?