Product Line Item Extraction

Taggun's Product Line Item Extraction feature captures detailed information about individual products or services on a receipt or invoice.

How It Works

TAGGUN's AI-powered OCR technology identifies and extracts individual line items from receipts and invoices, providing details such as:

  • Product or Service Name
  • Quantity
  • Unit Price
  • Total Price
  • Product Code

Compatible Endpoints

The productLineItems feature is available only on the verbose endpoints:


Note if you are using Receipt Validation APIs:

All endpoints in the Receipt Validation API support the productLineItems feature.


Enabling Line Item Extraction

To use line item extraction, set the extractLineItems parameter to true in your API request:

curl --request POST \
  --url https://api.taggun.io/api/receipt/v1/verbose/file \
  --header 'accept: application/json' \
  --header 'apikey: YOUR_API_KEY' \ # UPDATE To Your API Key
  --header 'content-type: multipart/form-data' \
  --form 'file=@/path/to/your/receipt.jpg' \ # UPDATE To Your File Path
  --form 'extractLineItems=true'

 

Remember to replace YOUR_API_KEY with your actual API key and update the file path to your receipt image.


Understanding the Response

The extracted line items are found in the productLineItems array inside the entities object of the response. Each line item contains:


Default Line Item Data Fields

FieldTypeDescriptionAccess Path
Product/Service NameStringThe name of the itementities.productLineItems[].data.name.data
QuantityNumberHow many of the item were purchasedentities.productLineItems[].data.quantity.data
Unit PriceNumberThe price of a single itementities.productLineItems[].data.unitPrice.data
Total PriceNumberThe total price for this line itementities.productLineItems[].data.totalPrice.data


Custom Line Item Data Fields

This feature must be enabled to access these fields. If you need assistance, please contact [email protected].

FieldTypeDescriptionAccess Path
SKUStringA unique identifier for the product, if available.entities.productLineItems[].data.sku.data
Item NumberStringUnique item number as provided on the receipt, if availableentities.productLineItems[].data.itemNumber.data
Discount AmountNumberDiscount applied to the itementities.productLineItems[].data.discountAmount.data
CategoryStringItem category or classificationentities.productLineItems[].data.category.data

Additional Line Item Properties

FieldDescription
dataDetailed information about the item
textThe raw text detected for this line item
indexThe position of this item in the list
confidenceLevelA measure of how confident the system is about the extracted information. Learn more here.
regionsThe location of the text on the image (coordinates not shown in examples for readability)

Response Body

You can find productLineItems inside the entities object

{
  "entities": {
    "productLineItems": [
      {
        "data": {
          "name": {
            "data": "",
            "regions": [],
            "text": ""
          },
          "quantity": {
            "data": null,
            "regions": [],
            "text": ""
          },
          "unitPrice": {
            "data": null,
            "regions": [],
            "text": ""
          },
          "totalPrice": {
            "data": null,
            "regions": [],
            "text": ""
          }
        },
        "confidenceLevel": null,
        "text": "",
        "index": null,
        "regions": []
      }
    ]
  }
}

Example


Receipt with Line Items

Request includes: --form 'extractLineItems=true'


Response

{
  "productLineItems": [
    {
      "data": {
        "quantity": {
          "data": 1,
          "regions": [],
          "text": "1"
        },
        "unitPrice": {
          "data": 8,
          "regions": [],
          "text": "8.00"
        },
        "totalPrice": {
          "data": 8,
          "regions": [],
          "text": "8.00"
        },
        "name": {
          "data": "Sparkling Mineral Water - San Pellegrino 1ltr",
          "regions": [],
          "text": "Sparkling Mineral Water - San Pellegrino 1ltr"
        }
      },
      "confidenceLevel": 0.65,
      "text": "- San Pellegrino 1ltr",
      "index": 13,
      "regions": []
    },
    {
      "data": {
        "quantity": {
          "data": 1,
          "regions": [],
          "text": "1"
        },
        "unitPrice": {
          "data": 6,
          "regions": [],
          "text": "6.00"
        },
        "totalPrice": {
          "data": 6,
          "regions": [],
          "text": "6.00"
        },
        "name": {
          "data": "Flat white - Almond Milk - Decaf",
          "regions": [],
          "text": "Flat white - Almond Milk - Decaf"
        }
      },
      "confidenceLevel": 0.65,
      "text": "- Almond Milk",
      "index": 15,
      "regions": []
    },
    {
      "data": {
        "quantity": {
          "data": 1,
          "regions": [],
          "text": "1"
        },
        "unitPrice": {
          "data": 5,
          "regions": [],
          "text": "5.00"
        },
        "totalPrice": {
          "data": 5,
          "regions": [],
          "text": "5.00"
        },
        "name": {
          "data": "Long Black",
          "regions": [],
          "text": "Long Black"
        }
      },
      "confidenceLevel": 0.65,
      "text": "1 x Long Black $5.00",
      "index": 17,
      "regions": []
    },
    {
      "data": {
        "quantity": {
          "data": 2,
          "regions": [],
          "text": "2"
        },
        "unitPrice": {
          "data": 9,
          "regions": [],
          "text": "9.00"
        },
        "totalPrice": {
          "data": 18,
          "regions": [],
          "text": "18.00"
        },
        "name": {
          "data": "Fresh juice - Orange",
          "regions": [],
          "text": "Fresh juice - Orange"
        }
      },
      "confidenceLevel": 0.65,
      "text": "1 x Fresh juice $10.00",
      "index": 26,
      "regions": []
    },
    {
      "data": {
        "quantity": {
          "data": 1,
          "regions": [],
          "text": "1"
        },
        "unitPrice": {
          "data": 22.5,
          "regions": [],
          "text": "22.50"
        },
        "totalPrice": {
          "data": 22.5,
          "regions": [],
          "text": "22.50"
        },
        "name": {
          "data": "Healthy greens - Add Poached Egg",
          "regions": [],
          "text": "Healthy greens - Add Poached Egg"
        }
      },
      "confidenceLevel": 0.65,
      "text": "- Add Poached Egg",
      "index": 21,
      "regions": []
    },
    {
      "data": {
        "quantity": {
          "data": 1,
          "regions": [],
          "text": "1"
        },
        "unitPrice": {
          "data": 21.5,
          "regions": [],
          "text": "21.50"
        },
        "totalPrice": {
          "data": 21.5,
          "regions": [],
          "text": "21.50"
        },
        "name": {
          "data": "Chilli Scrambled Eggs with Mushrooms",
          "regions": [],
          "text": "Chilli Scrambled Eggs with Mushrooms"
        }
      },
      "confidenceLevel": 0.65,
      "text": "1 x Chilli Scrambled Eggs with",
      "index": 22,
      "regions": []
    },
    {
      "data": {
        "quantity": {
          "data": 1,
          "regions": [],
          "text": "1"
        },
        "unitPrice": {
          "data": 25,
          "regions": [],
          "text": "25.00"
        },
        "totalPrice": {
          "data": 25,
          "regions": [],
          "text": "25.00"
        },
        "name": {
          "data": "Healthy greens - Add Marinated Tofu",
          "regions": [],
          "text": "Healthy greens - Add Marinated Tofu"
        }
      },
      "confidenceLevel": 0.65,
      "text": "- Add Marinated Tofu",
      "index": 25,
      "regions": []
    },
    {
      "data": {
        "quantity": {
          "data": 1,
          "regions": [],
          "text": "1"
        },
        "unitPrice": {
          "data": 10,
          "regions": [],
          "text": "10.00"
        },
        "totalPrice": {
          "data": 10,
          "regions": [],
          "text": "10.00"
        },
        "name": {
          "data": "Fresh juice - Apple - Orange - Carrot - Ginger - Beetroot",
          "regions": [],
          "text": "Fresh juice - Apple - Orange - Carrot - Ginger - Beetroot"
        }
      },
      "confidenceLevel": 0.65,
      "text": "1 x Fresh juice $10.00",
      "index": 26,
      "regions": []
    },
    {
      "data": {
        "quantity": {
          "data": 1,
          "regions": [],
          "text": "1"
        },
        "unitPrice": {
          "data": 5,
          "regions": [],
          "text": "5.00"
        },
        "totalPrice": {
          "data": 5,
          "regions": [],
          "text": "5.00"
        },
        "name": {
          "data": "Serve of Grilled halloumi",
          "regions": [],
          "text": "Serve of Grilled halloumi"
        }
      },
      "confidenceLevel": 0.65,
      "text": "x Serve of Grilled halloumi $5.00",
      "index": 32,
      "regions": []
    }
  ]
}

Note: X-Y coordinates have been removed from regions for readability in this example.


Snapshot from Taggun's online demo


Product Categorisation

In addition to line item extraction, Taggun offers product categorisation capabilities. This feature automatically categorises products based on their names, helping streamlined reporting and shopping basket insights.

For example, items such as "Flat White" can be categorised under "Beverages," while "Chilli Scrambled Eggs with Mushrooms" could fall under "Food."

Learn more about Product Categorisation here.


Conclusion

Taggun's Product Line Item Extraction streamlines business reporting by accurately capturing detailed data from receipts and invoices. With easy integration and dedicated support at [email protected], it's a powerful tool for enhancing financial analysis.