# API

## Parse PDF

### Create Synchronization Job

"Synchronization" mean that you can receive results immediately after a request is completed

{% hint style="info" %}
Replace `{{API_TOKEN}}` with your actual token.
{% endhint %}

**Example Request:**

{% tabs %}
{% tab title="Curl" %}
```bash
curl -X POST 'https://api.netmind.ai/inference-api/agent/v1/parse-pdf' \
--header 'Authorization: Bearer {{API_TOKEN}}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "url": "https://netmind-public-files.s3.us-west-2.amazonaws.com/test.pdf",
    "format": "json"
}'
```
{% endtab %}

{% tab title="Python" %}
```python
import requests
import json

url = "https://test.api.netmind.ai/inference-api/agent/v1/parse-pdf"

payload = json.dumps({
   "url": "https://netmind-public-files.s3.us-west-2.amazonaws.com/test.pdf",
   "format": "json"
})
headers = {
   'Authorization': 'Bearer {{API_TOKEN}}',
   'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```
{% endtab %}
{% endtabs %}

**Example Response:**

```json
[
    {
        "id": "0eKSDqCl",
        "version": "1.0.1",
        "page": 1,
        "seq_no": 1,
        "sentence": "FABSA: An aspect-based sentiment analysis dataset of user reviews",
        "type": "title",
        "text_location": {
            "location": [
                [
                    37,
                    629,
                    427,
                    613
                ]
            ],
            "location_raw": [
                [
                    37,
                    164,
                    427,
                    180
                ]
            ]
        },
        "info": {}
    },
    ...
]
```

### Create Asynchronous Job

"Asynchronous"  mean that you need to obtain results through another request (Get Job)

{% hint style="info" %}
Replace `{{API_TOKEN}}` with your actual token.
{% endhint %}

**Example Request:**

{% tabs %}
{% tab title="Curl" %}
```bash
curl -X POST 'https://api.netmind.ai/inference-api/agent/v1/parse-pdf/async' \
--header 'Authorization: Bearer {{API_TOKEN}}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "url": "https://netmind-public-files.s3.us-west-2.amazonaws.com/test.pdf",
    "format": "json"
}'
```
{% endtab %}

{% tab title="Python" %}
```python

import requests
import json

url = "https://api.netmind.ai/inference-api/agent/v1/parse-pdf/async"

payload = json.dumps({
   "url": "https://netmind-public-files.s3.us-west-2.amazonaws.com/test.pdf",
   "format": "json"
})
headers = {
   'Authorization': 'Bearer {{API_TOKEN}}',
   'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)
```
{% endtab %}
{% endtabs %}

**Example Response:**

```json
{
    "task_id":"1a9e46e...2a9fb",
    "status":"PENDING"
}
```

### Get Job

{% hint style="info" %}
Replace `{{API_TOKEN}}` with your actual token.

Replace `{{TASK_ID}}` with "task\_id" you got from previous step.
{% endhint %}

**Example Request:**

{% tabs %}
{% tab title="Curl" %}
```bash
curl -X GET 'https://api.netmind.ai/inference-api/agent/v1/parse-pdf/async/{{TASK_ID}}' \
--header 'Authorization: Bearer {{API_TOKEN}}'
```
{% endtab %}

{% tab title="Python" %}
```python
import requests

url = "https://api.netmind.ai/inference-api/agent/v1/parse-pdf/async/{{TASK_ID}}"

payload={}
headers = {
   'Authorization': 'Bearer {{API_TOKEN}}'
}

response = requests.request("GET", url, headers=headers, data=payload)

print(response.text)
```
{% endtab %}
{% endtabs %}

**Example Response:**

```json
[
    {
        "id": "0eKSDqCl",
        "version": "1.0.1",
        "page": 1,
        "seq_no": 1,
        "sentence": "FABSA: An aspect-based sentiment analysis dataset of user reviews",
        "type": "title",
        "text_location": {
            "location": [
                [
                    37,
                    629,
                    427,
                    613
                ]
            ],
            "location_raw": [
                [
                    37,
                    164,
                    427,
                    180
                ]
            ]
        },
        "info": {}
    },
    ...
]
```
