# Extracting Line Items

## Overview

The goal of this tutorial is show a complete example on extracting line items from a document. This can correspond to table like data, or more complex structured data. To do this we'll be using the following dummy file:

<figure><img src="https://126655343-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2al1MDqAP9Dg9iDRjkWg%2Fuploads%2Fgit-blob-788ff637b9863c69518696df834e5a2132075ab7%2F5abc4f8-0a4be5d5-6ba5-479d-a5d0-f5949262d37f.jpg?alt=media" alt=""><figcaption></figcaption></figure>

The objective is to create an API being able to accurately extract:

* the description of each products,
* the number of units,
* the unit price,
* the total price.

## Create Your Line Items Expense API

1. Log into your [Mindee account](https://platform.mindee.com/login). You'll land on the My APIs page.
2. Click the docTI tab.
3. Click the **Create a new API** button.

<figure><img src="https://126655343-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2al1MDqAP9Dg9iDRjkWg%2Fuploads%2Fgit-blob-f39d5f4f4793b88dab09f8e85433acf1997ba54b%2F85cf77c-Untitled_16.png?alt=media" alt=""><figcaption></figcaption></figure>

* On the Set up your API section, fill in the required information. Give the API a name, a description (optional), and a cover image(optional) and click on Next.

<figure><img src="https://126655343-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2al1MDqAP9Dg9iDRjkWg%2Fuploads%2Fgit-blob-36c46e06a9044d571ac080dd29279e9400d8421a%2Fe062842-image.png?alt=media" alt=""><figcaption></figcaption></figure>

* Next, Define your data model by defining the different items within the Object field.

<figure><img src="https://126655343-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2al1MDqAP9Dg9iDRjkWg%2Fuploads%2Fgit-blob-3858f510f24297ff187d2f5f7cc3444b200b5681%2F6b7472c-Untitled_11.png?alt=media" alt=""><figcaption></figcaption></figure>

* Click on the Object field

<figure><img src="https://126655343-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2al1MDqAP9Dg9iDRjkWg%2Fuploads%2Fgit-blob-fa4dd05cc39925adf00ba1207362c4587fe16780%2F28c2eeb-image.png?alt=media" alt=""><figcaption></figcaption></figure>

* In the popup, click on the button **Add a new item** to to add a new line in your Items definition, then complete each line with a Type, a Field Name and an Example. You can refer to this page to help you complete the form.

<figure><img src="https://126655343-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2al1MDqAP9Dg9iDRjkWg%2Fuploads%2Fgit-blob-24af6a1e4cfc55d695e483736a878c56997da201%2Ffb1962f-image.png?alt=media" alt=""><figcaption></figcaption></figure>

## Use the API

Your API is now ready to be used in your coding environment. Once your first model is deployed you can test it right away with new data.

Hit the **Live interface** button on the sidebar, drag and drop a document. You should see something like this:

<figure><img src="https://126655343-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2al1MDqAP9Dg9iDRjkWg%2Fuploads%2Fgit-blob-bcdc6b40e0a5528471aea004d40239ef3106d75c%2F2f978a6-image.png?alt=media" alt=""><figcaption></figcaption></figure>

Creating the following API Response:

```json
{
  "extras": {},
  "finished_at": "2024-02-05T14:02:23.410000",
  "is_rotation_applied": null,
  "pages": [
    {
      "extras": {},
      "id": 0,
      "orientation": {
        "value": null
      },
      "prediction": {}
    }
  ],
  "prediction": {
    "line_items": [
      {
        "product_description": "ANANAS",
        "quantity": 0.265,
        "total_price": 10.28,
        "unit_price": 38.8
      },
      {
        "product_description": "BAIE DE GOGI",
        "quantity": 0.08,
        "total_price": 5.49,
        "unit_price": 68.6
      }
    ]
  },
  "processing_time": 3,
  "product": {
    "features": [
      "line_items"
    ],
    "name": ****/expense_line_items",
    "type": "generated",
    "version": "1.0"
  },
  "started_at": "2024-02-05T14:02:19.625312"
}
```

You can then click the Documentation button in the sidebar. And follow these [steps ](https://docs.mindee.com/v1/get-started/make-your-first-request#get-your-sample-code)to integrate your API in your application.
