# Keyword Extractor: key phrases from text and pages (YAKE, RAKE) (`examsens.ai/keyword-extractor`) Actor

Extracts ranked key phrases with scores from many texts, web pages or dataset fields, with YAKE or RAKE, stop word lists for 69 languages, phrase length and near duplicate controls. Runs offline inside the actor.

- **URL**: https://apify.com/examsens.ai/keyword-extractor.md
- **Developed by:** [Ed Rayyis](https://apify.com/examsens.ai) (community)
- **Categories:** SEO tools, AI
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 text analyzeds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Keyword Extractor: key phrases from text and pages (YAKE, RAKE)

Pull the key phrases out of many documents at once. Paste texts, send JSON records with your own IDs, list web pages, or point it at an Apify dataset, and get the top phrases of each document, ranked and scored.

### Methods

- YAKE (default) scores each word by its casing, its position, its frequency, how many sentences it appears in, and how varied its neighbors are, then scores phrases of up to 3 words from those. It needs no training data and works on a single document.
- RAKE splits the text at stop words and punctuation into candidate phrases, and scores each phrase by how often its words appear and how many other words they appear with. It favors longer phrases.

Both are written for this actor from their published descriptions and run inside it. No text is sent to any outside service.

### For each document

- `keywords`: the top phrases, best first, each with `keyword` (in its most common capitalization), `score` (the method's raw score: lower is better for YAKE, higher is better for RAKE), `relevance` (1 for the best phrase, smaller for the rest, comparable across both methods), `count` (times the phrase appears) and `words`
- `topKeywords`: the first 10 phrases as plain text
- `language`: the stop word list used, `wordCount`, `textPreview`
- For web pages, `title`. The page title is analyzed together with the main text.
- Every other field of a record you sent, such as your `id`

On the Python Software Foundation's About page, YAKE returns "Python", "Python Software Foundation", "Welcome to Python", "Python Software" and "Python Package Index" among the top phrases.

### Input

- Texts: one document per entry
- Texts with IDs: JSON objects such as `{"id": "review-17", "text": "...", "rating": 5}`
- Web pages: the title and main text of each page. Menus, footers and scripts are left out.
- Apify datasets: each item is one document. The field is found for you (`text`, `markdown`, `content`, `body`, `description`, `article`, `review`, `comment`), or name it.
- Method, language (auto by default), keywords per text (default 20), longest phrase (default 3 words), shortest word (default 3 letters), similar phrase cut off (default 0.9), extra stop words

Stop word lists cover 69 languages, from the spaCy and stopwords-iso projects (both MIT licensed). Auto picks the list that matches the most words of the text. A language written without spaces between words, such as Japanese, is not split into words, so whole sentences come back as phrases. Use it on languages that put spaces between words.

### Output

Dataset: one item per document, in input order. A document that cannot be analyzed gets `ok: false` and an `error`, such as `HTTP 404`, an empty text, or fewer than 3 words. The other documents still run.

### Pricing

Pay per event: one event per document analyzed. A document that fails is not charged. The run stops when it reaches the maximum charge you set.

### Scope and conduct

Each web page is downloaded once. Nothing is stored beyond the run's own storage.

### Support

Questions and problems: the Issues tab on this page. Replies are written by an AI assistant on behalf of the developer and reviewed by the developer.

# Actor input Schema

## `texts` (type: `array`):

One document per entry.

## `items` (type: `array`):

JSON objects with "text" and any other fields, such as an "id". The other fields are copied to the result.

## `urls` (type: `array`):

Pages whose title and main text are analyzed. Menus, footers and scripts are left out.

## `datasetIds` (type: `array`):

Datasets in your account; each item is one document. The text field is found for you (text, markdown, content, body, description, article, review, comment), or set it below.

## `textField` (type: `string`):

Field of each dataset item to read.

## `method` (type: `string`):

YAKE weighs where and how words appear (casing, position, frequency, spread, neighbors) and suits single documents. RAKE splits the text at stop words and punctuation and favors longer phrases.

## `language` (type: `string`):

ISO 639-1 code that picks the stop word list, such as en, de or fr. Auto picks the list that matches the text best.

## `maxKeywords` (type: `integer`):

How many key phrases to return, best first.

## `maxWords` (type: `integer`):

Most words in one key phrase.

## `minWordLength` (type: `integer`):

Words shorter than this are not used in key phrases.

## `dedupThreshold` (type: `string`):

Drop a phrase whose similarity to a better ranked phrase reaches this value, from 0 to 1. 0.9 removes near duplicates such as plural forms; 1 keeps everything.

## `extraStopwords` (type: `array`):

Words that must never start or end a key phrase, added to the language's list, such as your brand name.

## Actor input object example

```json
{
  "texts": [
    "Solar panels convert sunlight into electricity. Rooftop solar panels cut household energy bills, and battery storage keeps the lights on after sunset. Installers size each solar system to the roof area and the household's daily energy use."
  ],
  "method": "yake",
  "language": "auto",
  "maxKeywords": 20,
  "maxWords": 3,
  "minWordLength": 3,
  "dedupThreshold": "0.9"
}
```

# Actor output Schema

## `results` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "texts": [
        "Solar panels convert sunlight into electricity. Rooftop solar panels cut household energy bills, and battery storage keeps the lights on after sunset. Installers size each solar system to the roof area and the household's daily energy use."
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("examsens.ai/keyword-extractor").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "texts": ["Solar panels convert sunlight into electricity. Rooftop solar panels cut household energy bills, and battery storage keeps the lights on after sunset. Installers size each solar system to the roof area and the household's daily energy use."] }

# Run the Actor and wait for it to finish
run = client.actor("examsens.ai/keyword-extractor").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "texts": [
    "Solar panels convert sunlight into electricity. Rooftop solar panels cut household energy bills, and battery storage keeps the lights on after sunset. Installers size each solar system to the roof area and the household'\''s daily energy use."
  ]
}' |
apify call examsens.ai/keyword-extractor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,examsens.ai/keyword-extractor"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/c8uiujMl4eww0mrhN/builds/sL5ooBh0nJqZbPPmS/openapi.json
