Skip to content

CSV to HTML API Documentation

Overview

The CSV to HTML API converts CSV data into a formatted HTML table.
It supports direct text input, remote file URLs, and uploaded files.
The output is a downloadable .html file containing a complete HTML document with a styled table.

Base URL:
https://api.apidatatools.com/csv-to-html-api


Endpoint (POST)

POST https://api.apidatatools.com/csv-to-html-api


Headers

Header Type Required Description
x-api-key string Yes API Key for authentication
x-source-type string No Input source type: body, url, or file (default: body)
x-has-header string No Set to 0, false, or no if the CSV has no header row
x-delimiter string No Custom delimiter (e.g., ,, ;, \t) Default ,

Accepted File Extensions

Mode Allowed Extensions
URL / File Upload .txt, .csv, .log

Input Example (Body Mode)

Header:

x-source-type: body
x-api-key: YOUR_API_KEY
Content-Type: text/plain

Body:

name,age,city
Alice,30,New York
Bob,25,London


Input Example (URL Mode)

Header:

x-source-type: url
x-api-key: YOUR_API_KEY
Content-Type: application/json

Body:

{
  "url": "https://example.com/sample.csv"
}


Input Example (File Mode)

Header:

x-source-type: file
x-api-key: YOUR_API_KEY
Content-Type: application/json

Body:

{
  "file": "user_uploads/upl_12345abc/sample.csv"
}


Example Request

Synchronous (Body Input)

curl -X POST "https://api.apidatatools.com/csv-to-html-api" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "x-source-type: body" \
  -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-to-html-api" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "x-source-type: url" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com/sample.csv"}'

Asynchronous (Input File)

curl -X POST "https://api.apidatatools.com/csv-to-html-api" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "x-source-type: file" \
  -H "Content-Type: application/json" \
  -d '{"file": "user_uploads/upl_12345abc/sample.csv"}'

Example Response

Successful (Body Mode)

Status: 200 OK

{
  "status": "success",
  "request_id": "b7e2f9a0-1234-4f6b-9a8d-abc123456789",
  "file": "https://downloads.apidatatools.com/apidatatools_convert_abcdef1234567890.html",
  "preview": "<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"utf-8\"><title>CSV to HTML Table</title>..."
}

Async Job Accepted

Status: 202 Accepted

{
  "status": "accepted",
  "job_id": "a1b2c3d4-e5f6-7890-abcd-1234567890ef",
  "status_url": "https://api.apidatatools.com/jobs/a1b2c3d4-e5f6-7890-abcd-1234567890ef",
  "request_id": "b7e2f9a0-1234-4f6b-9a8d-abc123456789"
}


Error Handling

Error Code HTTP Status Description Example
INVALID_CSV 400 CSV content is empty or malformed {"status":"error","error":"INVALID_CSV","details":{"message":"Empty CSV input."}}
CSV_TO_HTML_CONVERSION_FAILED 400 Failed to convert CSV to HTML {"status":"error","error":"CSV_TO_HTML_CONVERSION_FAILED","details":{"message":"Conversion error"}}
INVALID_BODY_ENCODING 400 Failed to decode body {"status":"error","error":"INVALID_BODY_ENCODING","details":{"message":"Failed to base64-decode request body."}}
EMPTY_BODY 400 Missing body content {"status":"error","error":"EMPTY_BODY","details":{"message":"Request body is empty."}}
INVALID_URL 400 Invalid or missing URL {"status":"error","error":"INVALID_URL","details":{"message":"Missing or invalid 'url'."}}
URL_UNREACHABLE 400 URL cannot be reached {"status":"error","error":"URL_UNREACHABLE","details":{"message":"Could not reach URL"}}
URL_NOT_OK 400 URL returned non-200 status {"status":"error","error":"URL_NOT_OK","details":{"message":"URL returned HTTP 404, expected 200."}}
INVALID_FILE 400 Invalid file path {"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":"Extension '.exe' is not allowed"}}
FILE_TOO_LARGE 413 File exceeds plan limit {"status":"error","error":"FILE_TOO_LARGE","details":{"message":"File exceeds plan limit."}}
PAYLOAD_TOO_LARGE 413 Body exceeds plan limit {"status":"error","error":"PAYLOAD_TOO_LARGE","details":{"message":"Request body exceeds limit."}}
UNKNOWN_FUNCTION 404 Invalid endpoint {"status":"error","error":"UNKNOWN_FUNCTION","details":{"message":"Unsupported API endpoint."}}
INTERNAL_ERROR 500 Unexpected server error {"status":"error","error":"INTERNAL_ERROR","details":{"message":"Failed to process your request"}}

Async Job Status

Endpoint:
GET https://api.apidatatools.com/jobs/{job_id}

Response Examples:

Queued or Processing

{
  "job_id": "a1b2c3d4-e5f6-7890-abcd-1234567890ef",
  "status": "queued",
  "message": "Your job is being processed.",
  "retry_after": 2,
  "created_at": 1712345678,
  "updated_at": 1712345678
}

Completed Successfully

{
  "job_id": "a1b2c3d4-e5f6-7890-abcd-1234567890ef",
  "status": "success",
  "created_at": 1712345678,
  "updated_at": 1712345690,
  "result": {
    "status": "success",
    "request_id": "b7e2f9a0-1234-4f6b-9a8d-abc123456789",
    "file": "https://downloads.apidatatools.com/apidatatools_convert_abcdef1234567890.html",
    "preview": "<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"utf-8\">..."
  }
}

Failed Job

{
  "job_id": "a1b2c3d4-e5f6-7890-abcd-1234567890ef",
  "status": "failed",
  "created_at": 1712345678,
  "updated_at": 1712345690,
  "error": {
    "code": "INVALID_CSV",
    "message": "Failed to parse CSV.",
    "details": {
      "message": "Error tokenizing data"
    }
  }
}

Notes for Developers

  • The API supports three input modes:
  • body: Direct CSV text (synchronous)
  • url: Remote CSV file (asynchronous job)
  • file: Uploaded CSV file (asynchronous job)
  • For asynchronous jobs, use the status_url to poll job progress.
  • The output file is stored temporarily and accessible via the returned download URL.
  • The HTML output includes a minimal document structure and inline CSS for readability.
  • When x-has-header is disabled, column names are auto-generated as column_1, column_2, etc.