Getting Started

Check out our GettingStarted Notebook for executable code examplesè

1. Create a new job (extract-document endpoint)

Before sending our request, we need to prepare a few steps:

  • We encoded the invoice PDF to base64 to pass it to our endpoint.

  • We decided on a Shape that describes what we want to extract.

  • We created an API key here.

Command:

curl -X POST "https://waveline.ai/api/v1/extract-document" \
     -H "Content-Type: application/json" \
     -H "Authorization: Bearer $WAVELINE_API_KEY" \
     -d '{
          "fileName": "invoice.pdf",
          "contentType": "application/pdf",
          "base64Content": "RGVhciBSZXNvcnQgQXJvbWEsCgpJ...",
          "shape": [
            {
              "name": "total",
              "type": "number",
              "description": "Total amount due of the invoice",
              "isArray": false
            }
          ]
        }' 

Output:

{
    "id": "a5ecc735-c48e-43ea-a739-d42bfb19edb3",
    "status": "CREATED",
    "type": "extract",
    "result": null,
    "urls": {
        "get": "https://waveline.ai/api/v1/jobs/a5ecc735-c48e-43ea-a739-d42bfb19edb3"
    }
}

In the returned response, we can see the id of the created job. We can now see if the job is still running or already finished by querying the job endpoint with that id. To make things convenient, we already provide this URL in urls["get"].

2. Get the result/status of this job (job endpoint)

We can easily query the jobs current state using another request:

curl "https://waveline.ai/api/v1/jobs/a5ecc735-c48e-43ea-a739-d42bfb19edb3" \
     -H "Authorization: Bearer $WAVELINE_API_KEY"
{
    "id": "a5ecc735-c48e-43ea-a739-d42bfb19edb3",
    "status": "FINISHED",
    "type": "extract",
    "result": {
        "total": 330.75,
     },
    "urls": {
        "get": "https://waveline.ai/api/v1/jobs/a5ecc735-c48e-43ea-a739-d42bfb19edb3"
    }
}

In the status field, we see that the job has finished, which means the result is also present in the result field.

Last updated