receiptor


Namereceiptor JSON
Version 1.1.1 PyPI version JSON
download
home_pageNone
SummaryExtract receipt / invoice/ orders data from your gmail .
upload_time2024-10-15 12:14:10
maintainerNone
docs_urlNone
authorOmkar Malpure
requires_pythonNone
licenseNone
keywords receipts receipt invoice receipts gmail invoice gmail python gmail receipt python gmail invoice receipt gmail data gmail receipt data gmail invoice data invoice gmail data python code for extracting gmail receipt data python code for extracting gmail invoice data processing gmail receipts / invoices handling data in python
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# Receiptor Package

## Overview

Receiptor is a Python package designed to extract receipt, invoice, and order data from a user's Gmail account. It provides an easy-to-use interface for developers to fetch and structure email data, including attachments. The package also includes a feature that uses LLMs (Language Model Models) to structure the extracted data into JSON format.

Github Repository : [Repo](https://github.com/hushh-labs/receiptor)

## Features

- Extract receipt/invoice/order data from Gmail
- Parse email attachments
- Structure extracted data using LLMs

## Installation

To install the Receiptor package, use pip:

```bash
pip install receiptor
```

## Usage

### 1. Import required modules

```python
from receiptor import Receiptor
from receiptor.llm_parser.gpt_4o_mini_parser.gpt_4o_mini import DocumentStructureExtractor
```

### 2. Setup OpenAi Api Keys as follows : 

 Pass the API keys into the function. 

 ```python 

structured_data = DocumentStructureExtractor.structure_document_data(
        raw_text=data.attachments[0].attachment_raw_text
        ,openai_api_key = "" , org_id = ""
    )

 ```
Note : org_id is optional , if you are using any organisation project then you may require this org_id ,
which can be obtained through open ai account dashboard.
For more information you can go through open ai official [documentation](https://platform.openai.com/docs/api-reference/making-requests).


### 3. Initialize the Receiptor object

```python
obj = Receiptor()
```

### 4. Set up Gmail access token

Obtain a Gmail access token through the OAuth2 flow. Store this token securely.
```python
access_token = "Your_Gmail_access_token_here"
```

### 5. Fetch and process receipt data

```python

for data in obj.fetch_receipt_data(access_token=access_token):
    print(data)
    if data.attachments:
        # Print the raw text of the first attachment
        print(data.attachments[0].attachment_raw_text)
        
        # Structure the attachment text using DocumentStructureExtractor
        structured_data = DocumentStructureExtractor.structure_document_data(
            raw_text=data.attachments[0].attachment_raw_text ,openai_api_key = "your api key" , org_id = "org id but this is optional"
        )
        print(structured_data)


```

## Example Output

### Main Data

```json
{
"message_id": "1dsse2342dfs3",
"body": "body text",
"company": "zomato.com",
"attachments": [
"<models.attachment.Attachment object at 0x1040d45c0>",
"<models.attachment.Attachment object at 0x10407b440>",
"<models.attachment.Attachment object at 0x103f90980>"
],
"attachment_extension": "pdf"
}
```
Attachment Raw Text
```
Zomato Food Order: Summary and Receipt

```
Structured Document Data
```json
{
"brand": "brand name",
"total_cost": "189",
"location": "New york",
"purchase_category": "Food",
"brand_category": "Culinary Services",
"Date": "01-01-2024",
"currency": "INR",
"filename": "filename",
"payment_method": null,
"metadata": null
}
```
Contributing
We welcome contributions to the Receiptor package. Please feel free to submit issues, feature requests, or pull requests on our GitHub repository.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Support

Thank you for using Receiptor! We hope this package simplifies your receipt and invoice data extraction process.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "receiptor",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "receipts, receipt, invoice, receipts gmail, invoice gmail, python gmail receipt, python gmail invoice, receipt gmail data, gmail receipt data, gmail invoice data, invoice gmail data, python code for extracting gmail receipt data, python code for extracting gmail invoice data, processing Gmail receipts / invoices, handling data in Python",
    "author": "Omkar Malpure",
    "author_email": "<malpureomkar5@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/ec/9a/8113aec6a372ef2563356086094a5ce713bfdfd40de3aef8d83177d608f5/receiptor-1.1.1.tar.gz",
    "platform": null,
    "description": "\n# Receiptor Package\n\n## Overview\n\nReceiptor is a Python package designed to extract receipt, invoice, and order data from a user's Gmail account. It provides an easy-to-use interface for developers to fetch and structure email data, including attachments. The package also includes a feature that uses LLMs (Language Model Models) to structure the extracted data into JSON format.\n\nGithub Repository : [Repo](https://github.com/hushh-labs/receiptor)\n\n## Features\n\n- Extract receipt/invoice/order data from Gmail\n- Parse email attachments\n- Structure extracted data using LLMs\n\n## Installation\n\nTo install the Receiptor package, use pip:\n\n```bash\npip install receiptor\n```\n\n## Usage\n\n### 1. Import required modules\n\n```python\nfrom receiptor import Receiptor\nfrom receiptor.llm_parser.gpt_4o_mini_parser.gpt_4o_mini import DocumentStructureExtractor\n```\n\n### 2. Setup OpenAi Api Keys as follows : \n\n Pass the API keys into the function. \n\n ```python \n\nstructured_data = DocumentStructureExtractor.structure_document_data(\n        raw_text=data.attachments[0].attachment_raw_text\n        ,openai_api_key = \"\" , org_id = \"\"\n    )\n\n ```\nNote : org_id is optional , if you are using any organisation project then you may require this org_id ,\nwhich can be obtained through open ai account dashboard.\nFor more information you can go through open ai official [documentation](https://platform.openai.com/docs/api-reference/making-requests).\n\n\n### 3. Initialize the Receiptor object\n\n```python\nobj = Receiptor()\n```\n\n### 4. Set up Gmail access token\n\nObtain a Gmail access token through the OAuth2 flow. Store this token securely.\n```python\naccess_token = \"Your_Gmail_access_token_here\"\n```\n\n### 5. Fetch and process receipt data\n\n```python\n\nfor data in obj.fetch_receipt_data(access_token=access_token):\n    print(data)\n    if data.attachments:\n        # Print the raw text of the first attachment\n        print(data.attachments[0].attachment_raw_text)\n        \n        # Structure the attachment text using DocumentStructureExtractor\n        structured_data = DocumentStructureExtractor.structure_document_data(\n            raw_text=data.attachments[0].attachment_raw_text ,openai_api_key = \"your api key\" , org_id = \"org id but this is optional\"\n        )\n        print(structured_data)\n\n\n```\n\n## Example Output\n\n### Main Data\n\n```json\n{\n\"message_id\": \"1dsse2342dfs3\",\n\"body\": \"body text\",\n\"company\": \"zomato.com\",\n\"attachments\": [\n\"<models.attachment.Attachment object at 0x1040d45c0>\",\n\"<models.attachment.Attachment object at 0x10407b440>\",\n\"<models.attachment.Attachment object at 0x103f90980>\"\n],\n\"attachment_extension\": \"pdf\"\n}\n```\nAttachment Raw Text\n```\nZomato Food Order: Summary and Receipt\n\n```\nStructured Document Data\n```json\n{\n\"brand\": \"brand name\",\n\"total_cost\": \"189\",\n\"location\": \"New york\",\n\"purchase_category\": \"Food\",\n\"brand_category\": \"Culinary Services\",\n\"Date\": \"01-01-2024\",\n\"currency\": \"INR\",\n\"filename\": \"filename\",\n\"payment_method\": null,\n\"metadata\": null\n}\n```\nContributing\nWe welcome contributions to the Receiptor package. Please feel free to submit issues, feature requests, or pull requests on our GitHub repository.\nLicense\nThis project is licensed under the MIT License. See the LICENSE file for details.\nSupport\n\nThank you for using Receiptor! We hope this package simplifies your receipt and invoice data extraction process.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Extract receipt / invoice/ orders data from your gmail .",
    "version": "1.1.1",
    "project_urls": null,
    "split_keywords": [
        "receipts",
        " receipt",
        " invoice",
        " receipts gmail",
        " invoice gmail",
        " python gmail receipt",
        " python gmail invoice",
        " receipt gmail data",
        " gmail receipt data",
        " gmail invoice data",
        " invoice gmail data",
        " python code for extracting gmail receipt data",
        " python code for extracting gmail invoice data",
        " processing gmail receipts / invoices",
        " handling data in python"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1e81ec2603ee2c8134f296f7c82dad90d30b9814f799cfdf83b70c1b722697fe",
                "md5": "0e38fbebd7203f4b695415d656edfa3a",
                "sha256": "3aac2e2aedd6fe3cd7b4536972a16761e5cbe7fd33d20a1cd0c31da857d04f17"
            },
            "downloads": -1,
            "filename": "receiptor-1.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0e38fbebd7203f4b695415d656edfa3a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 47186,
            "upload_time": "2024-10-15T12:14:08",
            "upload_time_iso_8601": "2024-10-15T12:14:08.143323Z",
            "url": "https://files.pythonhosted.org/packages/1e/81/ec2603ee2c8134f296f7c82dad90d30b9814f799cfdf83b70c1b722697fe/receiptor-1.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ec9a8113aec6a372ef2563356086094a5ce713bfdfd40de3aef8d83177d608f5",
                "md5": "cda092b96ec84f4a2fd7d9a50130494f",
                "sha256": "181a14ba1de68c6032f35fb782831ee230e391e71c1186041f3b5a3b78b47fb6"
            },
            "downloads": -1,
            "filename": "receiptor-1.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "cda092b96ec84f4a2fd7d9a50130494f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 44564,
            "upload_time": "2024-10-15T12:14:10",
            "upload_time_iso_8601": "2024-10-15T12:14:10.109584Z",
            "url": "https://files.pythonhosted.org/packages/ec/9a/8113aec6a372ef2563356086094a5ce713bfdfd40de3aef8d83177d608f5/receiptor-1.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-15 12:14:10",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "receiptor"
}
        
Elapsed time: 0.65670s