GET
/
csv
/
{id}

The CSV to JSON convenience endpoints provides two core endpoints for converting CSV files to JSON. This process is asynchronous, allowing large files to be processed without blocking the client.

Endpoints

  • POST /csv: Upload a CSV file to initiate the conversion. The API responds with a job ID.
  • GET CSV: Poll this endpoint using the job ID to retrieve the JSON data once conversion is complete.

Process

  1. Initiate Conversion (POST /csv):

    • Upload the CSV file.
    • Receive a job ID in the response to poll for the result.
  2. Poll for Completion:

    • Poll the /csv/{id} endpoint every few seconds.
    • Once the conversion is finished, the API will return the JSON data.
Example Usage
/**
   * Converts a CSV file to JSON.
   *
   * @param file The CSV file to convert.
   * @returns A promise that resolves to the JSON data.
   * @throws Error if the file cannot be converted.
   */
  const csvToJson = async (file: File): Promise<any> => {
    try {
      const formData = new FormData()
      formData.append('file', file)

      const initialResponse = await axiosInstance.post<any>(`/csv`, formData, {
        headers: {
          'Content-Type': 'multipart/form-data',
        },
      })

      if (initialResponse.status === 'SUCCESS') {
        return initialResponse.data
      }

      let exit = false
      let data: any[] = []

      while (!exit) {
        await new Promise((resolve) => setTimeout(resolve, 2000))
        const pollResponse = await axiosInstance.get<any>(`/csv/${initialResponse.id}`, {
          headers: {
            'Content-Type': 'application/json',
          },
        })

        if (pollResponse.status === 'SUCCESS') {
          data = pollResponse.data
          exit = true
        }
      }

      return data
    } catch (error) {
      console.error('Error handling the CSV file:', error)
      throw error
    }
  }

Authorizations

Authorization
string
headerrequired

The access token received from the authorization server in the OAuth 2.0 flow.

Path Parameters

id
string
required

Response

200 - application/json
id
string
required

The id of the task

name
string | null

The name of the PDF

status
enum<string>
required

The status of the task

Available options:
QUEUED,
STARTED,
PENDING,
SUCCESS,
FAILURE
type
string
required

The type of the task

created_at
string
required

The date and time this object was created

updated_at
string | null

The date and time this object was last updated

data

The output of the task