Batch processing is a powerful feature that allows you to process multiple items at once, significantly improving efficiency. This section provides a comprehensive reference to the batch processing API.

Overview

The batch processing API enables you to submit a list of items to be processed in bulk. This is particularly useful for tasks such as data validation, transformation, and analysis.

Usage

To use the batch processing API, you need to send a POST request to /api/batch_process. The request should include a JSON payload with the list of items to be processed.

{
  "items": [
    {
      "id": "123",
      "data": "example data 1"
    },
    {
      "id": "456",
      "data": "example data 2"
    }
  ]
}

Response

The API will return a JSON response with the results of the batch processing. Each item in the response corresponds to an item in the request.

{
  "items": [
    {
      "id": "123",
      "result": "success"
    },
    {
      "id": "456",
      "result": "error"
    }
  ]
}

Error Handling

If an error occurs during batch processing, the API will return an error response with a detailed description of the issue.

{
  "error": "Invalid input data"
}

Additional Resources

For more information on batch processing, please refer to our Batch Processing Guide.

Example

Here's an example of how to use the batch processing API in a web application:

fetch('/api/batch_process', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    "items": [
      {
        "id": "123",
        "data": "example data 1"
      },
      {
        "id": "456",
        "data": "example data 2"
      }
    ]
  })
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));

Batch Processing Example