Skip to main content

Squillify development is paused indefinitely. Read why, and discover what this experiment achieved. Read the story

MicroSkills Reference

Keyword Density Score

marketing.keyword_density

ProductionBounded custom (Class B)Deterministicstrictfastv1.0.0
No network

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

Note
Score caller-named terms and phrases against a body of text with a closed, fully published word analyzer.

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

IdempotentRetry safeStreaming supportedFile input supportedRequires external service

Capabilities

analysistext-processing

Cost & billing

Flat rate per invocation

MetercallsBillable onsuccessCost per call2 credits

File handling

Accepts file_refProduces file_refMax input1 MB

How we handle your data

Sensitive input, safe output
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.

Read the Microskill Data Handling Policy

Input schema

FieldTypeRequiredDescription
textstringYesBody to score, 1 through 262144 code points.
keywordsarrayYesFrom 1 through 64 terms or phrases that must stay distinct once analysed.
analyzerobjectNoOptional word analyzer for case folding, unicode form, token pattern, minimum term length, and caller-supplied stopwords; omit it for every published default.
denominatorstringNoWhich token count density divides by; omit it for ANALYZED_TOKENS.
overlapstringNoWhether a phrase consumes matched tokens; omit it for NON_OVERLAPPING_LEFTMOST.

Output schema

FieldTypeRequiredDescription
densityarrayYesOne row per keyword in input order, including keywords that matched nothing.
aggregateobjectYesClosed totals across every keyword: matched tokens, density, percent, and how many keywords matched versus missed.
analysisobjectYesClosed analyser receipt with token counts and the caseFold, unicodeForm, tokenPattern, minTermLength, denominator, and overlap settings actually used.
workobjectYesClosed work receipt with the token comparisons this request was projected to need and the budget it was measured against.

API contract

POST /v1/execute
curl
curl -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"]}}'
Integrations
TypeScript SDK
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

CodeHTTPRetryableDescription
VALIDATION_ERROR400NoThe request payload failed schema validation.
UNAUTHORIZED401NoMissing or invalid API key.
SKILL_NOT_ACCESSIBLE403NoThe API key is not granted access to this skill.
SKILL_NOT_AVAILABLE_FOR_PLAN403NoThis skill is not included in your current plan.
PLAN_ELIGIBILITY_UNAVAILABLE503YesPlan eligibility could not be decided. Retry after backoff.
SKILL_NOT_FOUND404NoThe requested skill or version does not exist.
TENANT_RATE_LIMITED429YesRequest rate limit exceeded. Retry after backoff.
QUOTA_EXCEEDED429YesPlan quota exhausted. Retryable once the quota period resets.
EXECUTION_TIMEOUT504YesExecution exceeded the allowed time budget.
DENSITY_TEXT_INVALID400NoThe request payload failed this skill's input validation.
DENSITY_TEXT_TOO_LARGE429NoA size, quota, rate, or time limit was exceeded.
DENSITY_KEYWORDS_INVALID400NoThe request payload failed this skill's input validation.
DENSITY_KEYWORD_LIMIT_EXCEEDED429NoA size, quota, rate, or time limit was exceeded.
DENSITY_KEYWORD_TOO_LONG429NoA size, quota, rate, or time limit was exceeded.
DENSITY_KEYWORD_EMPTY_AFTER_ANALYSIS400NoThe request payload failed this skill's input validation.
DENSITY_KEYWORD_DUPLICATE400NoThe request payload failed this skill's input validation.
DENSITY_ANALYZER_OPTION_UNSUPPORTED400NoThe skill does not support the requested variant.
DENSITY_STOPWORD_LIMIT_EXCEEDED429NoA size, quota, rate, or time limit was exceeded.
DENSITY_WORK_REFUSED429NoA size, quota, rate, or time limit was exceeded.

Other limits

LimitValue
Recommended inline bytes32 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)

Request bodyjson
{
  "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

Inputjson
{
  "keywords": [
    "crm software",
    "deal"
  ],
  "text": "Our crm software helps teams. The crm software is fast and the crm keeps every deal in one place."
}
Expected outputjson
{
  "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
  }
}
Tip
The phrase matches a run of two tokens, so matchedTokens is twice the occurrence count.

Count overlapping occurrences instead of consuming them

Inputjson
{
  "text": "growth growth growth",
  "keywords": [
    "growth growth"
  ],
  "overlap": "ALL_OCCURRENCES"
}
Expected outputjson
{
  "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
  }
}
Tip
The default consumes matched tokens and would find one; ALL_OCCURRENCES restarts at every position and finds two.
  • 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

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.

Tags

analysisseomarketingstatistics