Paraphraser API Documentation
Description:
Kafkai's Paraphraser API allows users to input text and receive paraphrased text in Japanese or their chosen language. This guide explains how to use the API, from your first request to interpreting the response. You can submit text in English or your preferred language, and we'll provide a paraphrased version in the same or your desired language.
How to Use the Paraphraser API
Authentication:
Before you can use the Paraphraser API, you need to authenticate your requests. You must include your authentication token in the request headers.
The API Offers Two HTTP Methods:
POST
: To submit text for paraphrasing.GET
: To retrieve paraphrased text using a Unique Identifier (UID).
Paraphrase Text
Endpoint: https://kafkai.io/api/v1.0/paraphraser-api/
HTTP Method: POST
How the API Works
When you want to paraphrase a piece of text, follow these steps:
-
Compose Your Request: Start by creating your request. Within the request body, insert the text you want to paraphrase. This text can be in any language.
{ "source_text": "Insert your text here.", "output_lang": "ja" }
source_text
: Place the text you want to paraphrase in this field.output_lang
: If you have a preferred language for the paraphrased text (e.g., "ja" for Japanese), specify it here.
-
Submit Your Request: Once you've structured your request, send it as a POST request to our
https://kafkai.io/api/v1.0/paraphraser-api/
endpoint. -
Receive the Paraphrased Text: After processing your request, we will provide you with the paraphrased text. The paraphrased text will convey the same meaning as the original text but with different wording.
Retrieve Paraphrased Text
Endpoint: https://kafkai.io/api/v1.0/paraphraser-api/{uid}/
UID Example: ab337bc4-00fb-47d6-af20-b6e02de86116
HTTP Method: GET
Retrieving Paraphrased Text
To retrieve paraphrased text, use the following endpoint:
- Replace
{uid}
(https://kafkai.io/api/v1.0/paraphraser-api/**ab337bc4-00fb-47d6-af20-b6e02de86116**/) in the URL with the Unique Identifier (UID) of the paraphrased content you wish to retrieve.
Practical Example
Example of Request and Response (Input and Output)
POST Request Example
Here is an example of paraphrasing a text about technology. Please note that this is a randomly selected text on the subject.
Python Example (POST Request):
import requests
import json
url = "https://kafkai.io/api/v1.0/paraphraser-api/"
headers = {
"Authorization": "Token <your-api-key>",
"Content-Type": "application/json",
}
data = {
"source_text": "Technology is the good thing to happen to me.",
"output_lang": "ja"
}
response = requests.post(url, headers=headers, data=json.dumps(data))
paraphrase_result = response.json()
print(paraphrase_result)
cURL Request (POST Request):
curl -X POST https://kafkai.io/api/v1.0/paraphraser-api/ \
-H "Authorization: Token <your-api-key>" \
-d '{
"source_text": "Technology is the good thing to happen to me.",
"output_lang": "ja"
}'
Response (POST Request - Paraphrased Text):
{
"uid": "ab337bc4-00fb-47d6-af20-b6e02de86116",
"source_text": "Technology is the good thing to happen to me.",
"source_lang": "en",
"time": "2023-09-17T12:34:56Z",
"output_text": "私にとって、技術は良いことです。",
"output_lang": "ja"
}
GET Request Example
To retrieve paraphrased text, initiate a GET request with the following endpoint:
Python Example (GET Request):
import requests
url = "https://kafkai.io/api/v1.0/paraphraser-api/d9a4cca5-fdb8-482e-a972-9da4de19738f/"
headers = {
"Authorization": "Token <your-api-key>"
}
response = requests.get(url, headers=headers)
paraphrase_result = response.json()
print(paraphrase_result)
cURL Request (GET Request):
curl -H "Authorization: Token <your-api-key>" https://kafkai.io/api/v1.0/paraphraser-api/d9a4cca5-fdb8-482e-a972-9da4de19738f/
Response (GET Request - Paraphrased Text):
{
"uid": "ab337bc4-00fb-47d6-af20-b6e02de86116",
"source_text": "Technology is the good thing to happen to me.",
"source_lang": "en",
"time": "2023-09-17T12:34:56Z",
"output_text": "私にとって、技術は良いことです。",
"output_lang": "ja"
}
Notes
- Input text can be in any language.
- Use the
output_lang
parameter to specify your desired language for the paraphrased text. - The
time
indicates when the paraphrased text was created.