Skip to main content

Extract receipt / invoice/ orders data from your gmail .

Project description

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

Features

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

Installation

To install the Receiptor package, use pip:

pip install receiptor

Usage

1. Import required modules

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.

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.

3. Initialize the Receiptor object

obj = Receiptor()

4. Set up Gmail access token

Obtain a Gmail access token through the OAuth2 flow. Store this token securely.

access_token = "Your_Gmail_access_token_here"

5. Fetch and process receipt data

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

{
"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

{
"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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

receiptor-1.1.1.tar.gz (44.6 kB view details)

Uploaded Source

Built Distribution

receiptor-1.1.1-py3-none-any.whl (47.2 kB view details)

Uploaded Python 3

File details

Details for the file receiptor-1.1.1.tar.gz.

File metadata

  • Download URL: receiptor-1.1.1.tar.gz
  • Upload date:
  • Size: 44.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.8

File hashes

Hashes for receiptor-1.1.1.tar.gz
Algorithm Hash digest
SHA256 181a14ba1de68c6032f35fb782831ee230e391e71c1186041f3b5a3b78b47fb6
MD5 cda092b96ec84f4a2fd7d9a50130494f
BLAKE2b-256 ec9a8113aec6a372ef2563356086094a5ce713bfdfd40de3aef8d83177d608f5

See more details on using hashes here.

File details

Details for the file receiptor-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: receiptor-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 47.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.8

File hashes

Hashes for receiptor-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3aac2e2aedd6fe3cd7b4536972a16761e5cbe7fd33d20a1cd0c31da857d04f17
MD5 0e38fbebd7203f4b695415d656edfa3a
BLAKE2b-256 1e81ec2603ee2c8134f296f7c82dad90d30b9814f799cfdf83b70c1b722697fe

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page