PHPackages                             sharpapi/laravel-invoice-parser - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. sharpapi/laravel-invoice-parser

ActiveLibrary[API Development](/categories/api)

sharpapi/laravel-invoice-parser
===============================

AI Invoice Parser for Laravel powered by SharpAPI.com

v1.0.3(1mo ago)1100MITPHPPHP ^8.1

Since Feb 2Pushed 1mo agoCompare

[ Source](https://github.com/sharpapi/laravel-invoice-parser)[ Packagist](https://packagist.org/packages/sharpapi/laravel-invoice-parser)[ Docs](https://github.com/sharpapi/laravel-invoice-parser)[ RSS](/packages/sharpapi-laravel-invoice-parser/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (6)Versions (5)Used By (0)

[![SharpAPI GitHub cover](https://camo.githubusercontent.com/82bb36706c1e71276b3dca4ec9120353bb51c8f22bb62543bf056db5c28da36d/68747470733a2f2f73686172706170692e636f6d2f73686172706170692d6769746875622d6c61726176656c2d62672e6a7067 "SharpAPI Laravel Client")](https://camo.githubusercontent.com/82bb36706c1e71276b3dca4ec9120353bb51c8f22bb62543bf056db5c28da36d/68747470733a2f2f73686172706170692e636f6d2f73686172706170692d6769746875622d6c61726176656c2d62672e6a7067)

Invoice Parser for Laravel with AI-powered SharpAPI
===================================================

[](#invoice-parser-for-laravel-with-ai-powered-sharpapi)

🚀 Leverage AI API to streamline invoice parsing and data extraction in your Accounting &amp; Finance applications.
------------------------------------------------------------------------------------------------------------------

[](#-leverage-ai-api-to-streamline-invoice-parsing-and-data-extraction-in-your-accounting--finance-applications)

[![Latest Version on Packagist](https://camo.githubusercontent.com/c488e0f78b1a49a11a3817dd239918c9783298b504709ffcc7b249e783a7ed2c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73686172706170692f6c61726176656c2d696e766f6963652d7061727365722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sharpapi/laravel-invoice-parser)[![Total Downloads](https://camo.githubusercontent.com/5d411cdcb5c6d3e9cfe6c19b14d20ec111a90fc8fa0ad1557ec03524955bf15c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73686172706170692f6c61726176656c2d696e766f6963652d7061727365722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sharpapi/laravel-invoice-parser)

Check the details at SharpAPI's [Invoice Parser](https://sharpapi.com/en/catalog/ai/accounting-finance/invoice-parser) page.

---

Requirements
------------

[](#requirements)

- PHP &gt;= 8.1
- Laravel &gt;= 10.48.29

---

Installation
------------

[](#installation)

Follow these steps to install and set up the SharpAPI Laravel Invoice Parser package.

1. Install the package via `composer`:

```
composer require sharpapi/laravel-invoice-parser
```

2. Register at [SharpAPI.com](https://sharpapi.com/) to obtain your API key.
3. Set the API key in your `.env` file:

```
SHARP_API_KEY=your_api_key_here
```

4. **\[OPTIONAL\]** Publish the configuration file:

```
php artisan vendor:publish --tag=sharpapi-invoice-parser
```

---

Key Features
------------

[](#key-features)

- **Automated Invoice Parsing with AI**: Efficiently parse and extract structured information from invoices in various formats, including PDF, TIFF, JPG, and PNG.
- **Comprehensive Data Extraction**: Extracts seller/buyer details, line items, financials, payment information, logistics data, and e-invoice metadata.
- **Consistent Data Format**: Ensures predictable JSON structure for parsed data.
- **Robust Polling for Results**: Polling-based API response handling with customizable intervals.
- **API Availability and Quota Check**: Check API availability and current usage quotas with `ping` and `quota` endpoints.

---

Usage
-----

[](#usage)

You can inject the `InvoiceParserService` class to access parsing functionalities. For best results, especially with batch processing, use Laravel's queuing system to optimize job dispatch and result polling.

### Basic Workflow

[](#basic-workflow)

1. **Dispatch Job**: Send an invoice file to the API using `parseInvoice`, which returns a status URL.
2. **Poll for Results**: Use `fetchResults($statusUrl)` to poll until the job completes or fails.
3. **Process Result**: After completion, retrieve the results from the `SharpApiJob` object returned.

> **Note**: Each job typically takes a few seconds to complete. Once completed successfully, the status will update to `success`, and you can process the results as JSON, array, or object format.

---

### Controller Example

[](#controller-example)

Here is an example of how to use `InvoiceParserService` within a Laravel controller:

```
