ReText.AI paraphrase API documentation
Introduction
The ReText.AI API provides the ability to paraphrase text using modern natural language processing methods. This API allows you to send a request with text and receive its paraphrased version.
Main functions
- Text paraphrasing
- Receiving the paraphrase result by unique task identifier
API endpoints
1. Paraphrase task creation
URL: https://api.retext.ai/public/api/process
Method: POST
Headers:
- Content-type: application/json
Body:
{
"method": "paraphrase",
"api_token": "YOUR_API_TOKEN",
"text": "Text to be paraphrased"
}
Example of request:
curl -X POST "https://api.retext.ai/public/api/process" -H "Content-type: application/json" --data '{
"method": "paraphrase",
"api_token": "YOUR_API_TOKEN",
"text": "Figma tried to solve four key problems. First, the interface should not distract from the ideas the designer is working on. Second, it should remain intuitive even with a variety of functions."
}' | jq
Example of response:
{
"data": {
"taskId": "ab43428b-8cc8-4785-a4f3-ccfb7bd8a60c"
},
"status": "ok"
}
2. Checking the task status and getting the result
URL: https://api.retext.ai/public/api/check
Method: GET
Query parameters:
- taskId - unique task identifier from the response of first step
Example of request:
curl "https://api.retext.ai/public/api/check?taskId=ab43428b-8cc8-4785-a4f3-ccfb7bd8a60c" | jq
Example of response:
{
"data": {
"ready": true,
"result": "Figma aimed to address four significant issues. Firstly, the interface must avoid distracting from the designer's ideas. Thirdly, while it has many functions, it must remain intuitive."
},
"status": "ok"
}
Example of API usage in Python
import aiohttp import asyncio API_URL_PROCESS = "https://api.retext.ai/public/api/process" API_URL_CHECK = "https://api.retext.ai/public/api/check" API_TOKEN = "YOUR_API_TOKEN" async def paraphrase_text(text): async with aiohttp.ClientSession() as session: # Step 1: Send the request to paraphrase async with session.post(API_URL_PROCESS, json={ "method": "paraphrase", "api_token": API_TOKEN, "text": text, }) as response: response_data = await response.json() task_id = response_data["data"]["taskId"] # Step 2: Check status and get result paraphrased_text = None while True: async with session.get(API_URL_CHECK, params={"taskId": task_id}) as response: response_data = await response.json() if response_data["data"]["ready"]: paraphrased_text = response_data["data"]["result"] break await asyncio.sleep(1) # wait before repeat
return paraphrased_text # Sample text_to_paraphrase = "Figma tried to solve four key problems. First, the interface should not distract from the ideas the designer is working on. Second, it should remain intuitive even with a variety of functions." result = asyncio.run(paraphrase_text(text_to_paraphrase)) print("Paraphrased text:", result)
This example demonstrates how you can use the text paraphrase API in Python.