CSV View Duplicates API Documentation¶
Overview¶
The CSV View Duplicates API identifies and returns all duplicate rows from a CSV file.
It preserves all occurrences of duplicate rows and maintains the header row if present.
The API supports three input modes:
- Body Mode (direct CSV text in request body)
- URL Mode (remote CSV file via URL)
- File Mode (previously uploaded CSV file reference)
The output is a downloadable CSV file containing only the duplicate rows.
Endpoint (POST)¶
POST https://api.apidatatools.com/csv-view-duplicates-api
Headers¶
| Header | Type | Required | Description |
|---|---|---|---|
x-api-key | string | Yes | Your API key for authentication |
x-source-type | string | No | Input source type: body, url, or file (default: body) |
x-has-header | string | No | Indicates if CSV has a header row (true/false or 1/0) |
x-delimiter | string | No | Custom CSV delimiter (auto-detected if not provided) |
Content-Type | string | Yes | text/plain or application/json depending on mode |
Accepted File Extensions¶
| Mode | Allowed Extensions |
|---|---|
| URL / File | .csv, .txt, .log |
Input Example (Body Mode)¶
Headers
x-source-type: body
x-has-header: true
Content-Type: text/plain
Body
id,name,age
1,John,30
2,Jane,25
3,John,30
4,Jane,25
5,Mark,40
Input Example (URL Mode)¶
Headers
x-source-type: url
Content-Type: application/json
Body
{
"url": "https://example.com/data/sample.csv"
}
Input Example (File Mode)¶
Headers
x-source-type: file
Content-Type: application/json
Body
{
"file": "user_uploads/upl_1234567890abcdef/sample.csv"
}
Example Request¶
Synchronous (Body Input)¶
curl -X POST "https://api.apidatatools.com/csv-view-duplicates-api" \
-H "x-api-key: YOUR_API_KEY" \
-H "x-source-type: body" \
-H "x-has-header: true" \
-H "Content-Type: text/plain" \
-d 'name,age,department
Alice,30,Engineering
Bob,25,Marketing'
Asynchronous (Remote File URL)¶
curl -X POST "https://api.apidatatools.com/csv-view-duplicates-api" \
-H "x-api-key: YOUR_API_KEY" \
-H "x-source-type: url" \
-H "Content-Type: application/json" \
-d '{"url": "https://example.com/data/sample.csv"}'
Asynchronous (Input File)¶
curl -X POST "https://api.apidatatools.com/csv-view-duplicates-api" \
-H "x-api-key: YOUR_API_KEY" \
-H "x-source-type: file" \
-H "Content-Type: application/json" \
-d '{"file": "user_uploads/upl_1234567890abcdef/sample.csv"}'
Example Response¶
Successful (Body Mode)¶
Status Code: 200 OK
{
"status": "success",
"request_id": "b9a1e7f4-1234-4bcd-9aef-56789abcdef0",
"file": "https://downloads.apidatatools.com/apidatatools_convert_abcdef1234567890.csv",
"preview": "id,name,age\n1,John,30\n2,Jane,25\n3,John,30\n4,Jane,25\n"
}
Async Job Accepted (URL or File Mode)¶
Status Code: 202 Accepted
{
"status": "accepted",
"job_id": "job_1234567890abcdef",
"status_url": "https://api.apidatatools.com/jobs/job_1234567890abcdef",
"request_id": "b9a1e7f4-1234-4bcd-9aef-56789abcdef0"
}
Error Handling¶
| Error Code | HTTP Status | Description | Example |
|---|---|---|---|
INVALID_CSV | 400 | CSV content is empty or cannot be parsed | {"status":"error","error":"INVALID_CSV","details":{"message":"CSV content cannot be empty."}} |
CSV_DUPLICATE_DETECTION_FAILED | 400 | Failed to detect duplicates | {"status":"error","error":"CSV_DUPLICATE_DETECTION_FAILED","details":{"message":"Failed to detect duplicates."}} |
INVALID_URL | 400 | Invalid or missing URL in URL mode | {"status":"error","error":"INVALID_URL","details":{"message":"Missing or invalid 'url'."}} |
URL_UNREACHABLE | 400 | Could not reach remote file | {"status":"error","error":"URL_UNREACHABLE","details":{"message":"Could not reach URL"}} |
URL_NOT_OK | 400 | Remote file returned non-200 HTTP status | {"status":"error","error":"URL_NOT_OK","details":{"message":"URL returned HTTP 404, expected 200."}} |
FILE_TOO_LARGE | 413 | File exceeds plan limit | {"status":"error","error":"FILE_TOO_LARGE","details":{"message":"Remote file exceeds plan limit."}} |
INVALID_FILE | 400 | Missing or invalid file reference | {"status":"error","error":"INVALID_FILE","details":{"message":"Missing or invalid 'file'."}} |
INVALID_FILE_EXTENSION | 400 | Unsupported file extension | {"status":"error","error":"INVALID_FILE_EXTENSION","details":{"message":"Invalid or unsupported file extension"}} |
FILE_UNAVAILABLE | 400 | File not found in storage | {"status":"error","error":"FILE_UNAVAILABLE","details":{"message":"Could not access file"}} |
PAYLOAD_TOO_LARGE | 413 | Request body exceeds plan limit | {"status":"error","error":"PAYLOAD_TOO_LARGE","details":{"message":"Request body exceeds limit"}} |
INTERNAL_ERROR | 500 | Unexpected internal error | {"status":"error","error":"INTERNAL_ERROR","details":{"message":"Failed to process your request"}} |
Async Job Status¶
To check the status of an asynchronous job (URL or File mode):
Endpoint:
GET https://api.apidatatools.com/jobs/{job_id}
Headers:
x-api-key: YOUR_API_KEY
Example Status Response for Async¶
Queued / Processing¶
{
"job_id": "job_1234567890abcdef",
"status": "queued",
"message": "Your job is being processed.",
"retry_after": 2
}
Success¶
{
"job_id": "job_1234567890abcdef",
"status": "success",
"created_at": 1712345678,
"updated_at": 1712345690,
"result": {
"status": "success",
"file": "https://downloads.apidatatools.com/apidatatools_convert_abcdef1234567890.csv",
"request_id": "b9a1e7f4-1234-4bcd-9aef-56789abcdef0",
"preview": "id,name,age\n1,John,30\n2,Jane,25\n3,John,30\n4,Jane,25\n"
}
}
Failed¶
{
"job_id": "job_1234567890abcdef",
"status": "failed",
"error": {
"code": "INVALID_CSV",
"message": "Could not parse CSV.",
"details": {"message": "Error tokenizing data"}
}
}
Notes for Developers¶
- When
x-has-headeris false, columns are auto-labeled ascolumn_1,column_2, etc. - The output file is stored temporarily and accessible via a download URL.
- For large files or remote sources, use asynchronous modes (
urlorfile). - Async job results can be retrieved using the Job Status API endpoint.