CSV Remove Duplicates API¶
Overview¶
Remove duplicate rows from CSV text or a CSV file. Body mode processes the request synchronously. URL and pre-uploaded file modes create an asynchronous job.
Endpoint¶
POST https://api.apidatatools.com/csv-remove-duplicates-api
Authentication¶
Include your API key in the x-api-key header:
x-api-key: YOUR_API_KEY
Input modes¶
Select the input mode with x-source-type:
body— submit CSV text for synchronous processing. This is the default.url— provide a URL to a CSV file. Processing is asynchronous.file— provide a pre-uploaded file’s storage key. Processing is asynchronous.
Headers¶
Header names are case-insensitive.
| Header | Type | Required | Default / values | Description |
|---|---|---|---|---|
x-api-key | String | Yes | Your API key | Authenticates the request. |
x-source-type | String | No | body; values: body, url, file | Selects the input mode. |
Accepted file extensions¶
For URL and file modes, the accepted extensions are .txt, .csv, and .log.
Request body¶
Body mode¶
Send raw CSV text as the request body. The request body must not be empty.
URL mode¶
Send a JSON object with a url property containing the file’s HTTP or HTTPS URL:
{
"url": "https://example.com/input.csv"
}
File mode¶
Send a JSON object with a file property containing the exact storage key returned by the upload workflow:
{
"file": "S3_KEY_RETURNED_BY_THE_UPLOAD_WORKFLOW"
}
curl examples¶
Body mode¶
curl -X POST "https://api.apidatatools.com/csv-remove-duplicates-api" \
-H "x-api-key: YOUR_API_KEY" \
--data-raw $'name,city\nAva,Paris\nAva,Paris\nNoah,Rome'
URL mode¶
curl -X POST "https://api.apidatatools.com/csv-remove-duplicates-api" \
-H "x-api-key: YOUR_API_KEY" \
-H "x-source-type: url" \
--data-raw '{"url":"https://example.com/input.csv"}'
File mode¶
curl -X POST "https://api.apidatatools.com/csv-remove-duplicates-api" \
-H "x-api-key: YOUR_API_KEY" \
-H "x-source-type: file" \
--data-raw '{"file":"S3_KEY_RETURNED_BY_THE_UPLOAD_WORKFLOW"}'
Success responses¶
Synchronous body mode¶
A synchronous file-producing result returns HTTP 200 with request_id, status, file, and preview:
{
"request_id": "REQUEST_ID",
"status": "success",
"file": "https://downloads.apidatatools.com/OUTPUT_FILE",
"preview": "OUTPUT_PREVIEW"
}
A synchronous data-producing result returns HTTP 200 with request_id, status, and preview. In that response, preview is serialized JSON text:
{
"request_id": "REQUEST_ID",
"status": "success",
"preview": "{\n \"example\": \"data\"\n}"
}
The available source does not specify which synchronous result form this tool returns.
Asynchronous URL and file modes¶
A successfully accepted job returns HTTP 202:
{
"status": "accepted",
"job_id": "JOB_ID",
"status_url": "https://api.apidatatools.com/jobs/JOB_ID",
"request_id": "REQUEST_ID"
}
Async job status¶
Poll the status URL returned when the job is accepted:
GET https://api.apidatatools.com/jobs/{job_id}
Include x-api-key on status requests:
curl -X GET "https://api.apidatatools.com/jobs/JOB_ID" \
-H "x-api-key: YOUR_API_KEY"
The status response includes request_id, job_id, status, created_at, and updated_at. The timestamps are Unix timestamps. When updated_at is not available, it uses the creation timestamp.
Queued or processing¶
For statuses other than success or failed, the response includes message and retry_after:
{
"request_id": "REQUEST_ID",
"job_id": "JOB_ID",
"status": "queued",
"created_at": 1710000000,
"updated_at": 1710000000,
"message": "Your job is being processed.",
"retry_after": 2
}
The status value reflects the job’s current status, such as queued or processing.
Success¶
A successful job response includes result, which contains the job output:
{
"request_id": "REQUEST_ID",
"job_id": "JOB_ID",
"status": "success",
"created_at": 1710000000,
"updated_at": 1710000010,
"result": {
"status": "success",
"file": "https://downloads.apidatatools.com/OUTPUT_FILE",
"preview": "OUTPUT_PREVIEW"
}
}
Failed¶
A failed job response includes an error object:
{
"request_id": "REQUEST_ID",
"job_id": "JOB_ID",
"status": "failed",
"created_at": 1710000000,
"updated_at": 1710000010,
"error": {
"code": "ERROR_CODE",
"message": "Error message",
"details": {
"message": "Error message"
}
}
}
A failed job is reported in the status response; polling it is distinct from an HTTP error response.
Error handling¶
HTTP error responses use this envelope:
{
"status": "error",
"error": "ERROR_CODE",
"request_id": "REQUEST_ID",
"details": {
"message": "Error message"
}
}
Additional fields may appear in details.
| HTTP status | Error code(s) | When it applies |
|---|---|---|
400 | INVALID_SOURCE_TYPE | x-source-type is not body, url, or file. |
400 | INVALID_BODY_ENCODING | The request body cannot be base64-decoded when decoding is requested. |
400 | EMPTY_BODY | The request body is empty. |
400 | INVALID_BODY | An asynchronous request body is not valid JSON or is not a JSON object. |
400 | INVALID_URL | The URL is missing, invalid, or not a valid HTTP(S) URL. |
400 | URL_UNREACHABLE | The URL cannot be reached during the check. |
400 | URL_NOT_OK | The URL check returns a status other than 200 or 206. |
400 | INVALID_FILE | The file reference is missing or invalid. |
400 | FILE_UNAVAILABLE | The referenced file cannot be accessed. |
400 | INVALID_FILE_EXTENSION | The URL or file has an unsupported extension. |
400 | INVALID_JOB_ID, DDB_ERROR, JOB_NOT_FOUND, FORBIDDEN | Job-status lookup errors. These tool errors are returned as HTTP 400 by the status API. |
401 | UNAUTHORIZED | Authentication context is missing. |
404 | USER_NOT_FOUND, UNKNOWN_FUNCTION | The authenticated user or requested endpoint is not found. |
413 | PAYLOAD_TOO_LARGE | The body exceeds the limit for the plan. |
413 | FILE_TOO_LARGE | The URL or uploaded file exceeds the applicable file limit. A worker-detected oversized file appears as a failed job. |
429 | QUOTA_EXCEEDED, RATE_LIMITED | The plan quota is exhausted or the request rate limit is exceeded. |
500 | PLAN_NOT_FOUND | Plan configuration is unavailable. |
500 | CONFIG_ERROR | Asynchronous job configuration is unavailable. |
500 | PLAN_CONFIG_ERROR | The plan’s file-limit configuration is invalid. |
500 | INTERNAL_ERROR | An unexpected processing error occurs. |
Tool processing errors return HTTP 400; the specific error code depends on the failure. Asynchronous processing can also end in a failed job with codes such as INVALID_JOB, DOWNLOAD_FAILED, UPLOAD_FAILED, or INTERNAL_ERROR; retrieve those errors from the job-status response.
Notes¶
- Body mode is synchronous. URL and file modes are asynchronous.
- Body-size and file-size limits, as well as quota and rate limits, depend on your plan. See tool limits.
- Output download URLs are temporary; their retention period depends on your plan.