Skip to main content

Integrating Didit's OCR API with Python for Document Data Extraction

Learn how to seamlessly integrate Didit's powerful OCR API with Python to extract crucial data from identity documents. This guide covers everything from setting up your environment to processing verification reports, showcasing.

Integrating Didit's OCR API with Python for Document Data Extraction

Contents

In this guide

Jump to the part you need.

Effortless IntegrationDidit's OCR API offers a straightforward, developer-friendly interface for Python, enabling quick integration into existing systems for document data extraction.

Comprehensive Data ExtractionBeyond basic text, Didit's ID Verification extracts a wealth of structured information, including personal details, document specifics, and image quality scores, ensuring thorough data capture.

Robust Verification ReportsThe API provides detailed JSON reports, offering granular insights into the verification status, extracted fields, and authenticity checks, crucial for compliance and risk management.

Scalable and Secure SolutionDidit's modular, AI-native platform ensures that your document data extraction is not only accurate but also scalable and secure, backed by features like Core KYC and no setup fees.

The Power of OCR in Identity Verification

In today's digital landscape, verifying identities accurately and efficiently is paramount for businesses across all sectors. Optical Character Recognition (OCR) technology plays a pivotal role in this, allowing for the automatic extraction of data from identity documents like passports, driver's licenses, and ID cards. This automation not only speeds up the onboarding process but also significantly reduces human error and the potential for fraud. However, not all OCR solutions are created equal. The key lies in finding an API that is robust, accurate, and easy to integrate, providing comprehensive data extraction and verification capabilities.

Didit's ID Verification API is engineered precisely for this challenge. It leverages advanced AI-native algorithms to accurately read and extract information from a wide array of global identity documents. This goes beyond simple text recognition; Didit performs authenticity checks, validates data against known patterns, and provides a structured output that can be directly used in your applications. For developers working with Python, integrating this powerful capability is streamlined and efficient, enabling the creation of sophisticated identity verification workflows with minimal effort.

Getting Started with Didit's Python OCR Integration

Integrating Didit's OCR API with Python is a straightforward process designed for developers. The first step involves authenticating your requests using an API key. Once authenticated, you can send images of identity documents (front and back, if applicable) to the /v3/id-verification/ endpoint. Didit's ID Verification product handles a variety of document types, including Passports, Identity Cards, and Driver's Licenses, and supports common image formats like JPEG, PNG, WebP, TIFF, and PDF, with a maximum file size of 5MB per image.

Beyond basic image submission, the API offers powerful optional parameters. For instance, you can set perform_document_liveness to true to ensure the document being scanned is not a screened copy or has undergone portrait replacement, adding a crucial layer of fraud prevention. You can also define a minimum_age, which automatically declines users under a specified age, a feature particularly useful for scenarios requiring age verification, such as in gaming, alcohol sales, or age-restricted content platforms. This flexibility allows businesses to tailor the verification process to their specific compliance and risk requirements, leveraging Didit's modular architecture.

Understanding the ID Verification Report

Upon successful submission and processing, Didit's ID Verification API returns a comprehensive JSON report. This report is the cornerstone of your identity verification process, providing detailed insights into the extracted data and the overall verification status. The report is structured to be easily parsable and includes several key sections:

  • ID Verification Status: This provides the overall session status (e.g., 'Approved', 'Declined', 'In Review') and specific verification results.
  • Document Details: Information about the verified document, such as document_type (e.g., 'Passport', 'Identity Card'), document_number, and expiration_date.
  • Personal Information: Extracted biographical data including first_name, last_name, date_of_birth, gender, and nationality. Didit also provides age, which is particularly useful for privacy-preserving age estimation scenarios.
  • Document Media: Temporary URLs to captured images and videos, allowing for visual review if necessary. This includes portrait_image, front_image, and back_image.
  • Address Information: Structured address data, including formatted_address and a parsed_address object with fields like city, region, and postal_code, essential for Proof of Address checks.
  • Verification Metadata: Additional details such as date_of_issue, issuing_state, and image quality scores for both front and back images (front_image_quality_score, back_image_quality_score). These scores provide valuable metrics on the clarity and usability of the submitted document images, helping to identify potential issues with the capture process.

This rich, structured data empowers businesses to make informed decisions quickly and to maintain robust audit trails, crucial for compliance and financial crime prevention.

Advanced Features and Best Practices

Didit's OCR API goes beyond simple data extraction. For example, the ImageQualityScore object within the report provides granular metrics like focus_score, brightness_score, resolution_score, and an overall_score. These scores are vital for ensuring the quality of submitted documents, which directly impacts the accuracy of OCR and overall verification reliability. By analyzing these scores, you can implement logic to request better quality images from users if necessary, improving the success rate of verifications.

Another powerful feature is the ability to generate compliance-ready PDF reports for any verification session using the /v3/session/{sessionId}/generate-pdf endpoint. These PDFs include identity decisions, extracted document data, and audit details, simplifying record-keeping and regulatory compliance. Furthermore, the /v3/session/{sessionId}/decision/ endpoint allows you to retrieve full verification session results, including liveness scores, face match results, and current processing status, offering a complete picture of the user's identity verification journey.

When integrating, it's a best practice to handle various API responses and statuses gracefully. For instance, the id_verification.status field can indicate 'Declined' if issues are found, such as an expired document or a failed liveness check. Implementing conditional logic based on these statuses ensures your application can respond appropriately, whether by requesting more information from the user or escalating the case for manual review. Didit's developer-first approach, with instant sandbox access and public documentation, makes it easy to experiment and build resilient integrations.

How Didit Helps

Didit provides an unparalleled solution for document data extraction and identity verification through its AI-native, developer-first platform. Our ID Verification product, powered by advanced OCR, precisely extracts data from global identity documents. Unlike other providers, Didit offers Core KYC with pay-per-use pricing, allowing you to start verifying identities without upfront costs. Our modular architecture means you can seamlessly integrate only the components you need, such as Passive & Active Liveness for fraud prevention, 1:1 Face Match for biometric comparisons, and Proof of Address for comprehensive checks. There are no setup fees, and our pay-per-successful-check model ensures cost-effectiveness. By choosing Didit, you leverage a platform built for global scale, automation over manual review, and structured identity data, all accessible via clean APIs or a no-code Business Console.

Ready to Get Started?

Ready to see Didit in action? Get a free demo today.

Start verifying identities for free with Didit's free tier.

Try it

Try this in the sandbox

Run the check this guide describes, free.

ID Verification

The product this post is about, taken from its topic. Run it free in the sandbox.

$0.15 per checkStart free

Author

Alejandro Rosas

Co-founder and CTO

Alejandro Rosas

Alejandro Rosas

Co-founder and CTO

About Didit

Questions

Blog questions

Who writes the Didit blog?
The Didit team. Guides reviewed by Alberto Rosas, co-founder and CEO, carry his byline. The rest are published as Didit.
Which topics does the blog cover?
Eight topics: ID verification, business verification (KYB), AML, sanctions and compliance, fraud prevention, transaction monitoring and crypto, country guides, agents and developers, and product updates.
Is the blog available in my language?
Yes, in 15 languages: English, Spanish, French, German, Brazilian and European Portuguese, Catalan, Russian, Arabic, Chinese, Japanese, Hindi, Indonesian, Korean and Swahili. Not every post is translated, so each language shows the posts it has.
Where do I find product updates?
In the changelog at /changelog/ and under the Product updates topic.
Are these posts legal advice?
No. Regulation posts explain rules; your legal team decides how they apply.
How do I find posts on one topic?
Open one of the eight topics, or search the blog.
Are posts dated?
Yes. Every post shows when it was published and when it was last updated.
Do posts link to the docs?
Developer posts link to the matching page on docs.didit.me and to the API reference.
Is the blog the same as the docs?
No. The blog explains rules, markets and product changes for a general reader, while docs.didit.me holds the integration guides and the API reference. Developer posts link the matching docs page and the API reference they describe.

Compliance built in

Audited, certified and attested.

We hold the certifications and build each country's rules into your flows, so you can launch anywhere without worrying. Security and Compliance center

  • Regulation encoded into your flows

    Tell us what you do and where. Didit lists the rules that apply to you, with sources, and builds the checks each country needs into one workflow.

  • Ready for AMLR

    Every requirement of the new EU anti-money laundering rules, from checking customers to human review, is already covered by a Didit check.

  • Tested in Spain's Treasury sandbox

    Spain's Treasury published its supervised sandbox report on Didit's NFC plus active liveness onboarding; SEPBLAC took part and valued the added measures positively.

  • Audited, not self-declared

    iBeta Level 1 and Level 2. Liveness tested under ISO/IEC 30107-3.

Compliance assistant

Your obligations · 3 regions

EU · AMLRCustomer due diligence, human reviewCovered
Illinois, Texas, ColoradoExplicit biometric consentCovered
Germany · Youth protectionVerified adults only (JMStV)Covered
Workflow checked. Every obligation is met
  • SOC 2 Type 2
  • ISO 27001
  • iBeta Level 1 and Level 2
  • EU regulator attestation
  • FSM youth protection
  • GDPR
  • EBA remote onboarding
  • MiCA compatible
  • FIDO Alliance member
  • AMLREU AML Regulation ready

Integration · Didit MCP

Run Didit from your own AI agent

Connect Didit to Claude, Cursor, VS Code or ChatGPT and just ask in plain words. Your agent can do anything you can do in the console, with the same permissions you have.

Add to ClaudeChatGPT
Didit Academy · Lesson 04 · Use Didit with MCP
  • Build workflowsDescribe the checks you need. The agent creates and publishes the flow.
  • Run investigationsAsk why a session was declined, review cases, search people and companies.
  • Change rulesCreate payment rules, test them on past data and switch them on.
  • Pull reportsAsk for numbers, exports or the audit log.

Verify your first user today.

Start free

Free sandbox. Credit applies to work-email sign-ups.