HTML Encoder API¶
Overview¶
Encode HTML content using the API. Body mode runs synchronously; URL and file modes submit an asynchronous job.
Endpoint¶
| Method | URL |
|---|---|
POST | https://api.apidatatools.com/html-encoder-api |
Authentication¶
Include your API key in the x-api-key header on every request, including job-status requests.
Input modes¶
Select a mode with x-source-type:
body— send the content as raw text. This is the default and runs synchronously.url— submit a URL to a file. Runs asynchronously.file— submit a reference to a pre-uploaded file. Runs asynchronously.
Headers¶
Header names are case-insensitive. Use the documented lowercase spelling.
| Header | Type | Required | Default / values | Description |
|---|---|---|---|---|
x-api-key | String | Yes | — | API key for authentication. |
x-source-type | String | No | Defaults to body; body, url, or file | Selects the input mode. |
Accepted file extensions¶
For URL and file modes, the accepted extensions are .txt and .html.
Request body¶
- Body mode: Send the HTML content as raw text.
- URL mode: Send a JSON object with a
urlstring containing the file URL. - File mode: Send a JSON object with a
filestring containing the exact storage key returned by the upload workflow.
URL and file mode request bodies must be JSON objects.
Examples¶
Body mode¶
curl -X POST 'https://api.apidatatools.com/html-encoder-api' \
-H 'x-api-key: YOUR_API_KEY' \
-H 'x-source-type: body' \
--data-raw '<h1>Hello</h1>'
URL mode¶
curl -X POST 'https://api.apidatatools.com/html-encoder-api' \
-H 'x-api-key: YOUR_API_KEY' \
-H 'x-source-type: url' \
--data '{"url":"https://example.com/input.html"}'
File mode¶
curl -X POST 'https://api.apidatatools.com/html-encoder-api' \
-H 'x-api-key: YOUR_API_KEY' \
-H 'x-source-type: file' \
--data '{"file":"S3_KEY_RETURNED_BY_THE_UPLOAD_WORKFLOW"}'
Success responses¶
Synchronous body mode¶
A successful synchronous request returns HTTP 200. The response includes request_id and status. The remaining fields depend on whether the result is data or a file:
Data result:
{
"request_id": "REQUEST_ID",
"status": "success",
"preview": "SERIALIZED_JSON_RESULT"
}
For data results, preview contains the result serialized as JSON.
File result:
{
"request_id": "REQUEST_ID",
"status": "success",
"file": "https://downloads.apidatatools.com/TEMPORARY_FILE",
"preview": "RESULT_PREVIEW"
}
The file URL is temporary; its retention period depends on your plan.
URL and file modes¶
A successfully submitted asynchronous request 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¶
Check a submitted job with:
curl 'https://api.apidatatools.com/jobs/JOB_ID' \
-H 'x-api-key: YOUR_API_KEY'
The status endpoint returns HTTP 200 when it retrieves the job. Responses include request_id, job_id, status, created_at, and updated_at.
For queued and processing jobs, the response also 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 same shape is used when status is processing.
For a successful job, the response includes result:
{
"request_id": "REQUEST_ID",
"job_id": "JOB_ID",
"status": "success",
"created_at": 1710000000,
"updated_at": 1710000010,
"result": {
"status": "success",
"file": "https://downloads.apidatatools.com/TEMPORARY_FILE",
"preview": "RESULT_PREVIEW"
}
}
For a failed job, the response includes error:
{
"request_id": "REQUEST_ID",
"job_id": "JOB_ID",
"status": "failed",
"created_at": 1710000000,
"updated_at": 1710000010,
"error": {
"code": "ERROR_CODE",
"message": "Description of the error.",
"details": {
"message": "Description of the error."
}
}
}
The error code and additional entries in details depend on the failure.
Error handling¶
Error responses use this envelope:
{
"status": "error",
"error": "ERROR_CODE",
"request_id": "REQUEST_ID",
"details": {
"message": "Description of the error."
}
}
details may contain additional fields. The following HTTP statuses are grounded in the API behavior:
| HTTP status | Error codes | When it applies |
|---|---|---|
400 | INVALID_SOURCE_TYPE, INVALID_BODY_ENCODING, EMPTY_BODY, INVALID_URL, URL_UNREACHABLE, URL_NOT_OK, INVALID_FILE, FILE_UNAVAILABLE, INVALID_FILE_EXTENSION | Invalid mode, body encoding, empty body, or invalid or unavailable URL/file input. |
400 | INVALID_JOB_ID, JOB_NOT_FOUND, FORBIDDEN, DDB_ERROR | Job-status request errors. |
401 | UNAUTHORIZED | Authentication context is missing or invalid. |
404 | USER_NOT_FOUND, UNKNOWN_FUNCTION | User or endpoint was not found. |
413 | PAYLOAD_TOO_LARGE, FILE_TOO_LARGE | The request body or input file exceeds the applicable limit. |
429 | QUOTA_EXCEEDED, RATE_LIMITED | The applicable quota or rate limit was exceeded. |
500 | PLAN_NOT_FOUND, CONFIG_ERROR, PLAN_CONFIG_ERROR, INTERNAL_ERROR | Plan configuration, asynchronous-job configuration, or request processing failed. |
Errors such as INVALID_JOB, DOWNLOAD_FAILED, and UPLOAD_FAILED can appear in a job’s failed status response; they are job failure codes, not HTTP statuses for the status lookup.
Notes¶
- Body-size, file-size, quota, rate, and download-retention limits depend on your plan. See tool limits.
- URL and file mode download URLs are temporary; retention depends on your plan.
- URL mode accepts HTTP or HTTPS URLs. The remote file must use an accepted extension.