Keywords Extractor
The /keywords_extractor
endpoint extracts the most significant keywords from any text. It works by removing the common words like 'and', 'of', 'the' etc. and focuses on only the important words.
Method: POST
To make a request, send the required parameters with the authorization header to the /keywords_extractor
endpoint, via the POST
method.
Parameters
This endpoint accepts three parameters – text
, max_keywords
, and show_frequency
.
text
is the text from which the keywords should be extracted.max_keywords
is the number of keywords which should be returned. By default it is 5.show_frequency
is the boolean which determines whether or not to show the frequency of the words. For default it isfalse
.
Responses
The success response includes a data
object with a keywords
array. If show_frequency
is true, keywords contains objects with keywords and their frequencies. Otherwise, it contains only keyword strings.
Example response, when show_frequency
is true
:
{
"status": "success",
"data": {
"source_text": "The cats gathered in the alley, where the cats always came when the moon was high. The black cat, the leader of the cats, sat atop a wooden crate, watching the other cats with sharp, glowing eyes. The smaller cats played with a piece of string, while the older cats lounged on the warm stones, their tails flicking lazily. This was the cats\u2019 place, where the cats shared stories, hunted together, and kept each other safe. For the cats, the alley wasn\u2019t just a hiding spot, but their home.",
"keywords": [
"cats",
"alley",
"gathered",
"always",
"when"
]
},
"message": "Keyword extraction was successful."
}
When show_frequency
is false
:
{
"status": "success",
"data": {
"source_text": "The cats gathered in the alley, where the cats always came when the moon was high. The black cat, the leader of the cats, sat atop a wooden crate, watching the other cats with sharp, glowing eyes. The smaller cats played with a piece of string, while the older cats lounged on the warm stones, their tails flicking lazily. This was the cats\u2019 place, where the cats shared stories, hunted together, and kept each other safe. For the cats, the alley wasn\u2019t just a hiding spot, but their home.",
"keywords": [
{
"word": "cats",
"frequency": 8
},
{
"word": "alley",
"frequency": 2
},
{
"word": "gathered",
"frequency": 1
},
{
"word": "always",
"frequency": 1
},
{
"word": "when",
"frequency": 1
}
]
},
"message": "Keyword extraction was successful."
}
And as usual, with the usual structure, the error response looks like as follows:
{
"status": "error",
"error": {
"code": "MISSING_PARAMETER",
"message": "'text' parameter is required and must be a non-empty string.",
"details": "Ensure the request body includes a valid 'text' field with content."
}
}
Notes
This endpoint is also, at a earlier stage and will be updated in the future.