String Reverse API Documentation¶
Overview¶
The String Reverse API allows developers to reverse text content in multiple ways.
It supports reversing by characters, reversing the order of words, or reversing each word individually.
This API can process text directly from the request body, from a remote file URL, or from a previously uploaded file.
Base URL:
https://api.apidatatools.com/string-reverse-api
Endpoint (POST)¶
POST https://api.apidatatools.com/string-reverse-api
Headers¶
| Header | Type | Required | Description |
|---|---|---|---|
Content-Type | string | Yes | Must be application/json for body input. |
x-reverse-option | string | Optional | Defines how the text should be reversed. Accepted values: char (default), word-order, each-word. |
x-source-type | string | Optional | Defines input mode. Accepted values: body, url, file. Default is body. |
x-api-key | <API_KEY> | Yes | Your API key for authentication abcd1234xyz |
Accepted File Extensions¶
This tool supports the following file types for URL or file mode: - .txt
Input Example (Body Mode)¶
Hello World
Input Example (URL Mode)¶
{
"url": "https://example.com/sample.txt"
}
Input Example (File Mode)¶
{
"file": "user_uploads/abc123/sample.txt"
}
Example Request¶
Synchronous (Body Input)¶
curl -X POST "https://api.apidatatools.com/string-reverse-api" \
-H "Content-Type: application/json" \
-H "x-reverse-option: word-order" \
-H "x-source-type: body" \
-H "x-api-key: YOUR_API_KEY" \
-d '{"text": "Hello World"}'
Asynchronous (Remote File URL)¶
curl -X POST "https://api.apidatatools.com/string-reverse-api" \
-H "Content-Type: application/json" \
-H "x-reverse-option: char" \
-H "x-api-key: YOUR_API_KEY" \
-H "x-source-type: url" \
-d '{"url": "https://example.com/sample.txt"}'
Asynchronous (Input File)¶
curl -X POST "https://api.apidatatools.com/string-reverse-api" \
-H "Content-Type: application/json" \
-H "x-reverse-option: each-word" \
-H "x-api-key: YOUR_API_KEY" \
-H "x-source-type: file" \
-d '{"file": "user_uploads/abc123/sample.txt"}'
Example Response¶
Successful (Body Mode)¶
{
"status": "success",
"request_id": "req-12345",
"file": "https://downloads.apidatatools.com/apidatatools_convert_abc123.txt",
"preview": "World Hello"
}
Async Job Accepted¶
{
"status": "accepted",
"job_id": "job-98765",
"status_url": "https://api.apidatatools.com/jobs/job-98765",
"request_id": "req-12345"
}
Error Handling¶
| Error Code | HTTP Status | Description | Example |
|---|---|---|---|
INVALID_TEXT | 400 | Input must be a non-empty string. | {"status":"error","error":"INVALID_TEXT","details":{"message":"Input must be a non-empty string."}} |
INVALID_REVERSE_OPTION | 400 | Invalid value for x-reverse-option. | {"status":"error","error":"INVALID_REVERSE_OPTION","details":{"message":"Invalid reverse option: invalid","allowed":["char","each-word","word-order"]}} |
STRING_REVERSE_ERROR | 400 | Failed to reverse string due to internal error. | {"status":"error","error":"STRING_REVERSE_ERROR","details":{"message":"Failed to reverse string."}} |
INVALID_URL | 400 | Provided URL is invalid or missing. | {"status":"error","error":"INVALID_URL","details":{"message":"Missing or invalid 'url'."}} |
URL_UNREACHABLE | 400 | Remote URL could not be reached. | {"status":"error","error":"URL_UNREACHABLE","details":{"message":"Could not reach URL."}} |
URL_NOT_OK | 400 | Remote URL did not return HTTP 200. | {"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_EXTENSION | 400 | File extension not supported. | {"status":"error","error":"INVALID_FILE_EXTENSION","details":{"message":"Invalid or unsupported file extension."}} |
INVALID_FILE | 400 | Missing or invalid file path. | {"status":"error","error":"INVALID_FILE","details":{"message":"Missing or invalid 'file'."}} |
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 (URL or file mode), use the following endpoint:
GET https://api.apidatatools.com/jobs/{job_id}
Example Status Response for Async¶
Queued¶
{
"job_id": "job-98765",
"status": "queued",
"created_at": 1710000000,
"updated_at": 1710000000,
"message": "Your job is being processed.",
"retry_after": 2
}
Success¶
{
"job_id": "job-98765",
"status": "success",
"created_at": 1710000000,
"updated_at": 1710000100,
"result": {
"status": "success",
"request_id": "req-12345",
"file": "https://downloads.apidatatools.com/apidatatools_convert_abc123.txt",
"preview": "dlroW olleH"
}
}
Failed¶
{
"job_id": "job-98765",
"status": "failed",
"created_at": 1710000000,
"updated_at": 1710000100,
"error": {
"code": "INVALID_FILE_EXTENSION",
"message": "Invalid or unsupported file extension.",
"details": {
"message": "Invalid or unsupported file extension."
}
}
}
Notes for Developers¶
- The API supports three modes: body, url, and file.
- Body mode executes synchronously and returns the reversed text immediately.
- URL and File modes create asynchronous jobs and return a job ID for status tracking.
- For asynchronous operations, use the
status_urlprovided in the response to poll job status. - The output file is stored securely and accessible via a temporary URL.
- Ensure the
x-reverse-optionheader is correctly set to control reversal behavior. - Supported reversal options:
char: Reverse all characters.word-order: Reverse the order of words.each-word: Reverse each word individually.- The preview field in the response contains the first 100 KB of the reversed text for quick inspection.