An open API service indexing awesome lists of open source software.

https://github.com/datafog/datafog-api

Privacy Engineering for the Generative AI era made available through a REST API
https://github.com/datafog/datafog-api

Last synced: 4 months ago
JSON representation

Privacy Engineering for the Generative AI era made available through a REST API

Awesome Lists containing this project

README

        


DataFog logo


REST API for PII detection and anonymization.


Docker
Discord
codecov

pre-commit

Code style: black

## Overview

datafog-api is a REST API service that lets you detect ('annotate'), and anonymize sensitive information in your data using specialized ML models.

## Getting Started:

### Option 1: Install via Docker (fastest)

The fastest way to get started with datafog-api is to pull the image from Docker:

```sh
docker pull datafog/datafog-api:latest
```

### Option 2: Build from source

Alternatively, you can clone this repository and build the image locally:

```sh
git clone https://github.com/datafog/datafog-api.git
```

```sh
cd datafog-api/
docker build -t datafog-api .
```

### Then, run the Docker container

```sh
docker run -p 8000:8000 -it datafog-api
```

> **NOTE** Change the first 8000 to a new port if there is a conflict.

## Documentation

You can access a user-friendly documentation site by navigating to `127.0.0.1:8000/redoc`

## Example cURL request/responses

### Annotation

Request:

```sh
curl -X POST http://127.0.0.1:8000/api/annotation/default \
-H "Content-Type: application/json" \
-d '{"text": "My name is Peter Parker. I live in Queens, NYC. I work at the Daily Bugle."}'
```

Response:

```sh
{
"entities": [
{"text": "Peter Parker", "start": 11, "end": 23, "type": "PER"},
{"text": "Queens", "start": 35, "end": 41, "type": "LOC"},
{"text": "NYC", "start": 43, "end": 46, "type": "LOC"},
{"text": "the Daily Bugle", "start": 58, "end": 73, "type": "ORG"}
]
}
```

### Anonymization (One-way)

Request:

```sh
curl -X POST http://127.0.0.1:8000/api/anonymize/non-reversible \
-H "Content-Type: application/json" \
-d '{"text": "My name is Peter Parker. I live in Queens, NYC. I work at the Daily Bugle."}'
```

Response:

```sh
{
"text": "My name is [PER]. I live in [LOC], [LOC]. I work at [ORG].",
"entities": [
{"text": "Peter Parker", "start": 11, "end": 23, "type": "PER"},
{"text": "Queens", "start": 35, "end": 41, "type": "LOC"},
{"text": "NYC", "start": 43, "end": 46, "type": "LOC"},
{"text": "the Daily Bugle", "start": 58, "end": 73, "type": "ORG"}
]
}
```

### Anonymization (Reversible)

Coming soon!

## Advanced

### Local Development

```sh
git clone https://github.com/datafog/datafog-api.git
cd datafog-api/
python -m venv myenv
source myenv/bin/activate
cd app
pip install -r requirements-dev.txt
uvicorn main:app
```

> **NOTE** datafog-api requires Python 3.11+. If you require support for other versions, please email us at [email protected].

### Contributors

- sroy9675
- pselvana
- sidmohan0

# License

This software is published under the [MIT
license](https://en.wikipedia.org/wiki/MIT_License).