Summarizer API Documentation
Description:
The API allows authenticated users to submit articles for summarization. It accepts text as input, summarizes the content, and provides summarized text in Japanese or the user's requested language. In this documentation, we'll walk you through every step of using the Kafkai API, from making your first authenticated API request to getting the response data. Simply, you can submit an English article, and we will provide you with a concise summary in either English or your preferred language.
Endpoint: https://kafkai.io/api/v1.0/summarizer-api/
Authentication
Notes:
- Authentication is essential to access the Summarizer API. You need to include your API token in the headers of your requests.
To access the Summarizer API, you need to include your API token in the headers of your requests.
Headers:
Authorization
(string): Set this header to include your API token in the following format:Token <your_api_key>
.
Example:
curl -X POST https://kafkai.io/api/v1.0/summarizer-api/ -H "Authorization: Token <your_api_key>"
Summarize an Article (POST Method)
HTTP Method: POST
How the API Works
Notes:
- To summarize an article, follow these steps.
- The POST method is used to create a new summary request.
- You provide input parameters like
source_text
andoutput_lang
. - The API responds with a summary of the article.
To summarize an article, follow these steps:
-
Compose Your Request: Create a POST request with the following parameters in the request body:
source_text
(string): The article you want to summarize in English.output_lang
(string): Your preferred language for the summary (optional). If not specified, the summary will be in English.
Example:
curl -X POST https://kafkai.io/api/v1.0/summarizer-api/ -d '{
"source_text": "Insert your article here.",
"output_lang": "ja"
}' -H "Authorization: Token <your_api_key>"
- Receive the Summary: After processing your request, we will provide you with a concise summary of the article. This summary is designed to capture the key points and highlights of the original article, facilitating a quick grasp of the main ideas and insights.
Retrieve a Summarized Article (GET Method)
HTTP Method: GET
Retrieving a Summarized Article
Notes:
- The GET method is used to retrieve an existing summary.
- You provide the
uid
parameter to specify which summary to retrieve. - The API responds with the details of the requested summary.
To retrieve a summarized article, use the following endpoint:
- Replace
{uid}
in the URL with the Unique Identifier (UID) of the article you wish to retrieve.
Example:
curl -X GET https://kafkai.io/api/v1.0/summarizer-api/{uid}/ -H "Authorization: Token <your_api_key>"
Practical Example
POST Request Example
Notes:
- Here is an example of an authenticated POST request for summarizing an English article regarding technology in Asia.
- The CURL command sends a POST request to create the summary with the authorization token included in the headers.
- The Python script demonstrates the same with the token in the headers.
Python Example (POST Request):
import requests
import json
url = "https://kafkai.io/api/v1.0/summarizer-api/"
headers = {
"Authorization": "Token <your_api_key>",
"Content-Type": "application/json",
}
data = {
"source_text": "Asia's technology sector is booming, with rapid advancements in AI, 5G, and more.",
"output_lang": "ja"
}
response = requests.post(url, headers=headers, data=json.dumps(data))
summary_result = response.json()
print(summary_result)
cURL Request (POST Request):
curl -X POST https://kafkai.io/api/v1.0/summarizer-api/ \
-H "Authorization: Token <your_api_key>" \
-d '{
"source_text": "Asia's technology sector is booming, with rapid advancements in AI, 5G, and more.",
"output_lang": "ja"
}'
GET Request Example
Notes:
- In this scenario, we retrieve the summary result by specifying the
uid
parameter with the authorization token included. - The CURL command sends a GET request to access the summary.
- The Python script demonstrates the same with the token in the headers.
Python Example (GET Request):
import requests
url = "https://kafkai.io/api/v1.0/summarizer-api/d9a4cca5-fdb8-482e-a972-9da4de19738f/"
headers = {
"Authorization": "Token <your_api_key>"
}
response = requests.get(url, headers=headers)
summary_result = response.json()
print(summary_result)
cURL Request (GET Request):
curl -H "Authorization: Token <your_api_key>" https://kafkai.io/api/v1.0/summarizer-api/d9a4cca5-fdb8-482e-a972-9da4de19738f/
Response (GET Request - Summarized Technology Article):
{
"uid": "ab337bc4-00fb-47d6-af20-b6e02de86116",
"source_text": "Asia's technology sector is booming, with rapid advancements in AI, 5G, and more.",
"source_lang": "en",
"time": "2023-09-11T12:34:56",
"output_text": "アジアのテクノロジー分野はAI、5Gなどの急速な進歩により急成長している。",
"output_lang": "ja"
}
Notes
- Input text should be in English or any language of your choice.
- You can specify your desired language for the summary using the
output_lang
parameter. - Summarized text will be provided in the requested language or in English if no language is specified.
- The time indicates when the summary was created.