Base16 Encoder API Documentation¶
Overview¶
The Base16 Encoder API converts any input text into its Base16 (hexadecimal) representation.
It supports synchronous processing for direct text input and asynchronous processing for remote files or URLs.
The output is a downloadable .txt file containing the encoded text.
Endpoint (POST)¶
POST https://api.apidatatools.com/base16-encoder-api
Headers¶
| Header | Description | Required | Example |
|---|---|---|---|
Content-Type | Defines the input format. Always application/json for body mode. | Yes | application/json |
x-source-type | Specifies input source type: body, url, or file. | Optional | body (default) |
x-api-key | API key for authentication. | Yes | <api_key> |
Accepted File Extensions¶
This tool accepts the following file extensions for URL or file mode:
.txt, .log
Input Example (Body Mode)¶
Hello World
Input Example (URL Mode)¶
{
"url": "https://example.com/sample.txt"
}
Input Example (File Mode)¶
{
"file": "user/uploads/sample.txt"
}
Example Request¶
Synchronous (Body Input)¶
curl -X POST "https://api.apidatatools.com/base16-encoder-api" \
-H "Content-Type: application/json" \
-H "x-source-type: body" \
-H "x-api-key: YOUR_API_KEY" \
-d 'Hello World'
Asynchronous (Remote File URL)¶
curl -X POST "https://api.apidatatools.com/base16-encoder-api" \
-H "Content-Type: application/json" \
-H "x-source-type: url" \
-H "x-api-key: YOUR_API_KEY" \
-d '{"url": "https://example.com/sample.txt"}'
Asynchronous (Input File)¶
curl -X POST "https://api.apidatatools.com/base16-encoder-api" \
-H "Content-Type: application/json" \
-H "x-source-type: file" \
-H "x-api-key: YOUR_API_KEY" \
-d '{"file": "user/uploads/sample.txt"}'
Example Response¶
Successful (Body Mode)¶
{
"status": "success",
"request_id": "c1a2b3d4e5f6",
"file": "https://downloads.apidatatools.com/apidatatools_convert_abc123.txt",
"preview": "48656C6C6F20576F726C64"
}
Async Job Accepted¶
{
"status": "accepted",
"job_id": "job-12345",
"status_url": "https://api.apidatatools.com/jobs/job-12345",
"request_id": "c1a2b3d4e5f6"
}
Error Handling¶
| Error Code | HTTP Status | Description | Example |
|---|---|---|---|
BASE16_ENCODING_FAILED | 400 | Failed to encode input to Base16. | {"status":"error","error":"BASE16_ENCODING_FAILED","details":{"message":"Failed to encode to Base16."}} |
INVALID_BODY_ENCODING | 400 | Body could not be base64-decoded. | {"status":"error","error":"INVALID_BODY_ENCODING","details":{"message":"Failed to base64-decode request body."}} |
EMPTY_BODY | 400 | Request body is empty. | {"status":"error","error":"EMPTY_BODY","details":{"message":"Request body is empty."}} |
PAYLOAD_TOO_LARGE | 413 | Body exceeds plan limit. | {"status":"error","error":"PAYLOAD_TOO_LARGE","details":{"message":"Request body exceeds limit."}} |
INVALID_URL | 400 | URL is missing or invalid. | {"status":"error","error":"INVALID_URL","details":{"message":"Missing or invalid 'url'."}} |
URL_UNREACHABLE | 400 | Could not reach remote URL. | {"status":"error","error":"URL_UNREACHABLE","details":{"message":"Could not reach URL."}} |
URL_NOT_OK | 400 | Remote URL returned non-200 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":"File exceeds plan limit."}} |
INVALID_FILE_EXTENSION | 400 | File extension not allowed. | {"status":"error","error":"INVALID_FILE_EXTENSION","details":{"message":"Invalid or unsupported file extension."}} |
INTERNAL_ERROR | 500 | Unexpected server error. | {"status":"error","error":"INTERNAL_ERROR","details":{"message":"Failed to process your request"}} |
Async Job Status¶
To check the status of an asynchronous job, use the following endpoint:
GET https://api.apidatatools.com/jobs/{job_id}
Example Status Response for Async¶
Queued¶
{
"job_id": "job-12345",
"status": "queued",
"created_at": 1712345678,
"updated_at": 1712345678,
"message": "Your job is being processed.",
"retry_after": 2
}
Success¶
{
"job_id": "job-12345",
"status": "success",
"created_at": 1712345678,
"updated_at": 1712345690,
"result": {
"status": "success",
"request_id": "c1a2b3d4e5f6",
"file": "https://downloads.apidatatools.com/apidatatools_convert_abc123.txt",
"preview": "48656C6C6F20576F726C64"
}
}
Failed¶
{
"job_id": "job-12345",
"status": "failed",
"created_at": 1712345678,
"updated_at": 1712345680,
"error": {
"code": "BASE16_ENCODING_FAILED",
"message": "Failed to encode to Base16.",
"details": {"message": "Invalid input encoding."}
}
}
Notes for Developers¶
- The API supports three input modes:
body,url, andfile. - For asynchronous operations (
urlorfilemode), ajob_idis returned with astatus_urlfor tracking. - The output file is stored securely and accessible via a temporary download link.
- Always include
request_idin your logs for traceability. - Ensure proper file extension validation before submitting URL or file mode requests.
- The preview field contains the first 100 KB of the encoded output for quick inspection.
- Use the Status API to poll job progress until completion.