Tutorial
Document Processing
8 min reading

How to Redact Documents (PDF, JPG, PNG) using Python

Summarize this article with:

In this tutorial, you will learn how to use the Document Redaction API in 5 minutes using Python. Eden AI provides an easy and developer-friendly API that allows you to redact sensitive information from your documents.

What is the Document Redaction API?

__wf_reserved_inherit

Document redaction refers to the process of removing, obscuring, or blanking out sensitive or confidential information from documents.

This could include personal details like names, addresses, social security numbers, financial data, or any other sensitive content that must be protected for privacy or legal reasons.

Getting Started with Document Redaction

Set Up Your Eden AI Account

1. Sign Up: If you don't have an Eden AI account, create a free here. Once you do that you can obtain your API key, which you can use to access Document Redaction.

__wf_reserved_inherit

2. Access the Redaction Feature: Once logged in, go to the document section of the platform.

3. Choose the Redaction feature: Select the Redaction tool. You can also explore other options based on your specific requirements.

How to Implement Document Redaction API using Python?

Eden AI allows you to redact a file from a URL or from a local file.

Redact from a URL


import requests

headers = {"Authorization": "Bearer YOUR_API_TOKEN"}  # Replace with your actual API token

url = "https://api.edenai.run/v2/ocr/anonymization"
json_payload = {
    "providers": "microsoft",
    "file_url": "https://your-file-url.com/document.pdf",  # replace with your file URL
}

response = requests.post(url, json=json_payload, headers=headers)

result = response.json()
print(result)

Redact from a local file


import requests

headers = {"Authorization": "Bearer YOUR_API_TOKEN"}  # Replace with your actual API token

url = "https://api.edenai.run/v2/ocr/anonymization"

with open("path/to/your/document.pdf", "rb") as f:
    files = {"file": f}
    data = {"providers": "microsoft"}
    response = requests.post(url, files=files, data=data, headers=headers)

result = response.json()
print(result)

Example Output


{
  "microsoft": {
    "status": "success",
    "document": {
      "redacted_document": "base64-encoded-pdf-content"
    },
    "redacted_text": [
      {
        "text": "John Doe",
        "type": "PERSON",
        "bounding_boxes": [
          {
            "left": 0.12,
            "top": 0.23,
            "width": 0.15,
            "height": 0.04
          }
        ]
      }
    ],
    "cost": 0.01
  }
}

Why Eden AI is the Best for Document Redaction

Eden AI provides several advantages.

__wf_reserved_inherit

Multiple AI Providers

You can choose between different AI services, helping you compare results for the best performance.

Easy Integration

Simplify development with a single API key that provides access to multiple AI services. Eliminate the hassle of managing separate integrations and accelerate your launch.

Cost Efficiency

Only pay for what you use. No upfront costs, just flexible access to multiple AI services with a single API key.

Conclusion

Document redaction is essential for protecting sensitive information in compliance-heavy environments. Eden AI's Document Redaction API makes it easy to integrate this capability into Python applications with just a few lines of code.

Sign up for free on Eden AI and start redacting documents today!

Similar articles

Tutorial
Generative AI
How to Generate Videos Using Python
9/4/2025
·
Written byTaha Zemmouri
let’s start

Start building with Eden AI

A single interface to integrate the best AI technologies into your products.