Keyword Density Score
marketing.keyword_density
Overview
You name the terms; we count them. Each keyword is analysed by the same word analyzer as the text — one normalisation form, one case fold, one of three token patterns, one minimum term length — and a phrase matches a run of tokens rather than a substring, so counting on the page and counting here agree. Every figure comes with what produced it: how the analyzer split your keyword, how many occurrences it found, which denominator the ratio used, and where the first match sits. Choosing which terms matter is a different job and a different skill; this one scores the list you already have.
Every keyword tool reports a percentage and none of them says what it divided by, so two tools disagree about the same page and neither can be checked. Here the analyzer, the denominator, the overlap rule and the rounding are all part of the answer, and the answer comes back with them attached.
Reliability
Fully deterministic: the same text, keywords and analyzer give the same figures under any locale, time zone or default character set. Ratios round half up to four decimals, once, at the last step. A density can exceed 1.0 when a keyword contains a stopword the denominator excluded, and that is reported rather than clamped. Failures, and what to do about each: DENSITY_TEXT_INVALID means the text is empty, or analyses to no tokens at all under the analyzer you chose, so loosen minTermLength or send content; DENSITY_TEXT_TOO_LARGE means the text is past 262144 code points, so split the document and score the parts; DENSITY_KEYWORDS_INVALID means the keyword list is empty or holds something that is not a non-empty string, and the details name the position; DENSITY_KEYWORD_LIMIT_EXCEEDED means more than 64 keywords arrived, so split the list across calls; DENSITY_KEYWORD_TOO_LONG means one keyword is past 128 code points, which is a sentence rather than a phrase, so shorten it; DENSITY_KEYWORD_EMPTY_AFTER_ANALYSIS means a keyword analyses to nothing — punctuation only, or every token below minTermLength — so fix it rather than read a zero that looks like a real absence; DENSITY_KEYWORD_DUPLICATE means two keywords analyse identically, so drop one and the report keeps meaning what it says; DENSITY_ANALYZER_OPTION_UNSUPPORTED means an analyzer property, denominator or overlap value is not one we know, and we never fall back to a default; DENSITY_STOPWORD_LIMIT_EXCEEDED means more than 500 stopwords arrived, so trim the list; DENSITY_WORK_REFUSED means the measured cost of this request is past the budget of eight million token comparisons, and both numbers come back with it, so shorten the text or the keyword list. None of these is worth retrying unchanged.
Context footprint
Returns one small row per keyword plus counters. No part of your text comes back — a match is located by token index. A successful call costs 2 execution credits.
When to use it
When you already know the terms you care about and want figures you can reproduce and defend. Keyword scoring lives here, not under seo.*; pair it with seo.audit_page when you are preparing a page audit.
When you want the terms discovered for you, or you are counting model tokens rather than words.
Scope
Non-goals
- Does not discover which terms matter — text.extract_keywords selects terms, and selecting is a judgement while scoring is arithmetic
- Does not use the model tokenizer: a density over subword pieces matches no number you can reproduce by counting words on a page
- Ships no built-in stopword list, because an English one would quietly move the denominator for text in every other language
- Does not accept a pattern of your own, since one over a quarter of a million characters is a denial-of-service waiting to be sent
- Does not rewrite, summarise or return your text
Properties
Capabilities
Cost & billing
Flat rate per invocation
File handling
How we handle your data
What this means
This skill may receive sensitive content, but it does not target sensitive data and returns only a structured non-sensitive result.
Squillify guarantees
- Runs inside Squillify
- This skill runs inside Squillify.
- Payloads are not sent to an external service by this skill.
- Squillify does not permanently store submitted payloads.
- Telemetry records metadata only, not submitted content.
- Submitted payloads are not used for training.
- Submitted payloads are not reviewed by humans.
- This skill does not target sensitive data.
- The response does not contain submitted content.
Your responsibility
Squillify does not determine whether submitted content is sensitive. Your application is responsible for deciding what data it is allowed to submit. Your application is responsible for securing the response.
Input schema
| Field | Type | Required | Description |
|---|---|---|---|
| text | string | Yes | Body to score, 1 through 262144 code points. |
| keywords | array | Yes | From 1 through 64 terms or phrases that must stay distinct once analysed. |
| analyzer | object | No | Optional word analyzer for case folding, unicode form, token pattern, minimum term length, and caller-supplied stopwords; omit it for every published default. |
| denominator | string | No | Which token count density divides by; omit it for ANALYZED_TOKENS. |
| overlap | string | No | Whether a phrase consumes matched tokens; omit it for NON_OVERLAPPING_LEFTMOST. |
Output schema
| Field | Type | Required | Description |
|---|---|---|---|
| density | array | Yes | One row per keyword in input order, including keywords that matched nothing. |
| aggregate | object | Yes | Closed totals across every keyword: matched tokens, density, percent, and how many keywords matched versus missed. |
| analysis | object | Yes | Closed analyser receipt with token counts and the caseFold, unicodeForm, tokenPattern, minTermLength, denominator, and overlap settings actually used. |
| work | object | Yes | Closed work receipt with the token comparisons this request was projected to need and the budget it was measured against. |
API contract
POST /v1/executecurl -sS -X POST "$BASE/v1/execute" -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' -d '{"skillKey":"marketing.keyword_density","input":{"text":"Our crm software helps teams close deals.","keywords":["crm software"]}}'import { Squillify } from "@squillify/sdk";
const sq = new Squillify({ apiKey: process.env.SQUILLIFY_API_KEY });
const { output } = await sq.execute("marketing.keyword_density", {"keywords":["crm software","deal"],"text":"Our crm software helps teams. The crm software is fast and the crm keeps every deal in one place."});Errors
| Code | HTTP | Retryable | Description |
|---|---|---|---|
| VALIDATION_ERROR | 400 | No | The request payload failed schema validation. |
| UNAUTHORIZED | 401 | No | Missing or invalid API key. |
| SKILL_NOT_ACCESSIBLE | 403 | No | The API key is not granted access to this skill. |
| SKILL_NOT_AVAILABLE_FOR_PLAN | 403 | No | This skill is not included in your current plan. |
| PLAN_ELIGIBILITY_UNAVAILABLE | 503 | Yes | Plan eligibility could not be decided. Retry after backoff. |
| SKILL_NOT_FOUND | 404 | No | The requested skill or version does not exist. |
| TENANT_RATE_LIMITED | 429 | Yes | Request rate limit exceeded. Retry after backoff. |
| QUOTA_EXCEEDED | 429 | Yes | Plan quota exhausted. Retryable once the quota period resets. |
| EXECUTION_TIMEOUT | 504 | Yes | Execution exceeded the allowed time budget. |
| DENSITY_TEXT_INVALID | 400 | No | The request payload failed this skill's input validation. |
| DENSITY_TEXT_TOO_LARGE | 429 | No | A size, quota, rate, or time limit was exceeded. |
| DENSITY_KEYWORDS_INVALID | 400 | No | The request payload failed this skill's input validation. |
| DENSITY_KEYWORD_LIMIT_EXCEEDED | 429 | No | A size, quota, rate, or time limit was exceeded. |
| DENSITY_KEYWORD_TOO_LONG | 429 | No | A size, quota, rate, or time limit was exceeded. |
| DENSITY_KEYWORD_EMPTY_AFTER_ANALYSIS | 400 | No | The request payload failed this skill's input validation. |
| DENSITY_KEYWORD_DUPLICATE | 400 | No | The request payload failed this skill's input validation. |
| DENSITY_ANALYZER_OPTION_UNSUPPORTED | 400 | No | The skill does not support the requested variant. |
| DENSITY_STOPWORD_LIMIT_EXCEEDED | 429 | No | A size, quota, rate, or time limit was exceeded. |
| DENSITY_WORK_REFUSED | 429 | No | A size, quota, rate, or time limit was exceeded. |
Other limits
| Limit | Value |
|---|---|
| Recommended inline bytes | 32 KiB |
Limitations
- Does not discover which terms matter — text.extract_keywords selects terms, and selecting is a judgement while scoring is arithmetic
- Does not use the model tokenizer: a density over subword pieces matches no number you can reproduce by counting words on a page
- Ships no built-in stopword list, because an English one would quietly move the denominator for text in every other language
- Does not accept a pattern of your own, since one over a quarter of a million characters is a denial-of-service waiting to be sent
- Does not rewrite, summarise or return your text
- Working out which keywords a document is about
- Counting model tokens for a context budget
- Ranking documents against a query
How to call
POST /v1/execute (requires authentication)
{
"skillKey": "marketing.keyword_density",
"input": {
"keywords": [
"crm software",
"deal"
],
"text": "Our crm software helps teams. The crm software is fast and the crm keeps every deal in one place."
}
}Examples
Score a phrase and a single term in a product page draft
{
"keywords": [
"crm software",
"deal"
],
"text": "Our crm software helps teams. The crm software is fast and the crm keeps every deal in one place."
}{
"analysis": {
"rawTokenCount": 19,
"analyzedTokenCount": 19,
"stopwordTokenCount": 0,
"distinctTokenCount": 15,
"caseFold": true,
"unicodeForm": "nfkc",
"tokenPattern": "unicode_word",
"minTermLength": 1,
"denominator": "analyzed_tokens",
"overlap": "non_overlapping_leftmost"
},
"aggregate": {
"matchedTokens": 5,
"density": 0.2632,
"percent": 26.3158,
"keywordCount": 2,
"matchedKeywordCount": 2,
"unmatchedKeywordCount": 0
},
"density": [
{
"keyword": "crm software",
"tokens": [
"crm",
"software"
],
"occurrences": 2,
"matchedTokens": 4,
"density": 0.2105,
"percent": 21.0526,
"occurrenceRate": 0.1053,
"firstTokenIndex": 1
},
{
"keyword": "deal",
"tokens": [
"deal"
],
"occurrences": 1,
"matchedTokens": 1,
"density": 0.0526,
"percent": 5.2632,
"occurrenceRate": 0.0526,
"firstTokenIndex": 15
}
],
"work": {
"projected": 57,
"budget": 8000000
}
}Count overlapping occurrences instead of consuming them
{
"text": "growth growth growth",
"keywords": [
"growth growth"
],
"overlap": "ALL_OCCURRENCES"
}{
"analysis": {
"rawTokenCount": 3,
"analyzedTokenCount": 3,
"stopwordTokenCount": 0,
"distinctTokenCount": 1,
"caseFold": true,
"unicodeForm": "nfkc",
"tokenPattern": "unicode_word",
"minTermLength": 1,
"denominator": "analyzed_tokens",
"overlap": "all_occurrences"
},
"aggregate": {
"matchedTokens": 4,
"density": 1.3333,
"percent": 133.3333,
"keywordCount": 1,
"matchedKeywordCount": 1,
"unmatchedKeywordCount": 0
},
"density": [
{
"keyword": "growth growth",
"tokens": [
"growth",
"growth"
],
"occurrences": 2,
"matchedTokens": 4,
"density": 1.3333,
"percent": 133.3333,
"occurrenceRate": 0.6667,
"firstTokenIndex": 0
}
],
"work": {
"projected": 6,
"budget": 8000000
}
}Recommended use cases
- Check how often a target phrase appears in a draft before it is published
- Compare the same keyword list across several pages, using one analyzer so the figures are comparable
- Verify a supplier's keyword report by recomputing it from the published rules
Avoid for
- Working out which keywords a document is about
- Counting model tokens for a context budget
- Ranking documents against a query
Related skills
Composable with
Safety & privacy
- Runs without calling any external service.
- Your payloads are never stored permanently.
- Telemetry captures metadata only — never your payload contents.
- We never train models on your payloads.
- No human reviews your payloads.