notion-cost-tuning
Optimize Notion API usage to minimize rate-limit pressure, reduce engineering overhead, and maximize throughput. Use when auditing request volume, eliminating redundant API calls, implementing caching, or restructuring queries for efficiency. Trigger with "notion cost", "notion optimize", "notion API usage", "reduce notion requests", "notion rate limit budget", "notion efficient", "notion caching".
What this skill does
# Notion Cost Tuning
## Overview
The Notion API is **free with every workspace plan** — there is no per-call pricing. The real "cost" is the **3 requests/second rate limit** (per integration token) and engineering time wasted on inefficient patterns. Apply six strategies below to reduce request volume by 80-95%.
**Notion workspace pricing (for context — API access is included at every tier):**
| Plan | Price | API Access | Rate Limit |
|------|-------|------------|------------|
| Free | $0 | Full API | 3 req/sec |
| Plus | $12/user/mo | Full API | 3 req/sec |
| Business | $28/user/mo | Full API | 3 req/sec |
| Enterprise | Custom | Full API | 3 req/sec |
The rate limit is identical across all plans. Optimization is about staying within 3 req/sec, not reducing a bill.
## Prerequisites
- `@notionhq/client` v2.x installed (`npm install @notionhq/client`)
- Integration token from [notion.so/my-integrations](https://www.notion.so/my-integrations)
- Token shared with target pages/databases via the **Connections** menu in Notion
- For queue patterns: `p-queue` v8+ (`npm install p-queue`)
- For caching: `node-cache` or `lru-cache` (`npm install lru-cache`)
## Instructions
### Step 1: Audit Current Request Volume
Before optimizing, measure your baseline. Instrument the Notion client to track every API call by method, endpoint, and timestamp.
```typescript
import { Client } from '@notionhq/client';
interface RequestEntry {
method: string;
endpoint: string;
timestamp: number;
durationMs: number;
}
const requestLog: RequestEntry[] = [];
const notion = new Client({ auth: process.env.NOTION_TOKEN });
// Wrap any Notion call with tracking
async function tracked<T>(
method: string,
endpoint: string,
fn: () => Promise<T>,
): Promise<T> {
const start = Date.now();
try {
return await fn();
} finally {
requestLog.push({
method,
endpoint,
timestamp: start,
durationMs: Date.now() - start,
});
}
}
// Generate audit report
function auditReport() {
const last60s = requestLog.filter(r => r.timestamp > Date.now() - 60_000);
const byMethod = Object.groupBy(last60s, r => r.method);
console.table({
totalAllTime: requestLog.length,
lastMinute: last60s.length,
reqPerSecond: (last60s.length / 60).toFixed(2),
avgLatencyMs: (
last60s.reduce((sum, r) => sum + r.durationMs, 0) / last60s.length
).toFixed(0),
});
// Show hotspots — which methods consume the most budget
for (const [method, entries] of Object.entries(byMethod)) {
console.log(` ${method}: ${entries!.length} calls (${((entries!.length / last60s.length) * 100).toFixed(0)}%)`);
}
}
// Example: track a database query
const results = await tracked('databases.query', `/databases/${dbId}/query`, () =>
notion.databases.query({ database_id: dbId }),
);
// Run report every 60 seconds
setInterval(auditReport, 60_000);
```
**Target:** identify which operations consume > 50% of your request budget. Common culprits are polling loops, page retrieves that duplicate database query data, and unfiltered full-table scans.
### Step 2: Eliminate Redundant Reads and Reduce Payload Size
Three high-impact patterns to cut reads immediately:
**Pattern A: Stop retrieving pages you already have from database queries.** Database query results include all properties — a separate `pages.retrieve` is redundant unless you need blocks.
```typescript
// WASTEFUL: 2 requests per page (query + retrieve)
const { results } = await notion.databases.query({ database_id: dbId });
for (const page of results) {
const full = await notion.pages.retrieve({ page_id: page.id }); // redundant!
processPage(full);
}
// EFFICIENT: 1 request total — properties are already in query results
const { results } = await notion.databases.query({ database_id: dbId });
for (const page of results) {
processPage(page); // same properties, no extra request
}
```
**Pattern B: Use `filter_properties` to reduce response size.** When you only need specific properties, pass their IDs to shrink the payload by 60-90%.
```typescript
// First, discover property IDs (one-time setup)
const db = await notion.databases.retrieve({ database_id: dbId });
console.log(
Object.entries(db.properties).map(([name, prop]) => `${name}: ${prop.id}`),
);
// Output: ["Status: abc1", "Assignee: def2", "Due Date: ghi3", ...]
// Then query with only the properties you need
const { results } = await notion.databases.query({
database_id: dbId,
filter_properties: ['abc1', 'def2'], // Only Status and Assignee
});
// Response is 60-90% smaller — faster network, faster parsing
```
**Pattern C: Use `last_edited_time` to fetch only changes since last sync.**
```typescript
async function getChangesSince(dbId: string, sinceISO: string) {
return notion.databases.query({
database_id: dbId,
filter: {
timestamp: 'last_edited_time',
last_edited_time: { after: sinceISO },
},
sorts: [{ timestamp: 'last_edited_time', direction: 'descending' }],
page_size: 100,
});
}
// Incremental sync: only fetch what changed
let lastSync = new Date().toISOString();
async function syncLoop() {
const changes = await getChangesSince(dbId, lastSync);
if (changes.results.length > 0) {
console.log(`${changes.results.length} pages modified since ${lastSync}`);
await processChanges(changes.results);
lastSync = new Date().toISOString();
}
}
// 1-5 requests/minute instead of re-fetching entire database each time
```
### Step 3: Cache, Batch, and Replace Polling
**Caching:** Most Notion data is read-heavy. Cache database query results and page content with TTL-based invalidation.
```typescript
import { LRUCache } from 'lru-cache';
const pageCache = new LRUCache<string, any>({
max: 500,
ttl: 5 * 60 * 1000, // 5-minute TTL
});
async function getCachedPage(pageId: string) {
const cached = pageCache.get(pageId);
if (cached) return cached; // 0 API requests
const page = await notion.pages.retrieve({ page_id: pageId });
pageCache.set(pageId, page);
return page;
}
// Cache database queries by filter hash
const queryCache = new LRUCache<string, any>({
max: 100,
ttl: 2 * 60 * 1000, // 2-minute TTL for queries
});
async function cachedQuery(dbId: string, filter: any) {
const key = `${dbId}:${JSON.stringify(filter)}`;
const cached = queryCache.get(key);
if (cached) return cached;
const result = await notion.databases.query({
database_id: dbId,
filter,
page_size: 100,
});
queryCache.set(key, result);
return result;
}
```
**Batching writes:** The Notion API has no true batch endpoint, but `blocks.children.append` accepts up to 100 blocks per call.
```typescript
import PQueue from 'p-queue';
// Rate-limited queue: respects 3 req/sec
const queue = new PQueue({ concurrency: 3, interval: 1000, intervalCap: 3 });
// BAD: 100 page creates = 100 sequential requests (~34 seconds at 3/sec)
for (const item of items) {
await notion.pages.create({
parent: { database_id: dbId },
properties: toProperties(item),
});
}
// BETTER: 100 page creates via queue = 100 requests but 3x faster (~34 sec → 34 sec but concurrent)
await Promise.all(
items.map(item =>
queue.add(() =>
notion.pages.create({
parent: { database_id: dbId },
properties: toProperties(item),
}),
),
),
);
// BEST for content: batch blocks into single append calls (100 blocks = 1 request)
const blocks = items.map(item => ({
type: 'paragraph' as const,
paragraph: {
rich_text: [{ type: 'text' as const, text: { content: item.text } }],
},
}));
// Chunk into groups of 100 (API limit per call)
for (let i = 0; i < blocks.length; i += 100) {
await queue.add(() =>
notion.blocks.children.append({
block_id: parentPageId,
children: blocks.slice(i, i + 100),
}),
);
}
```
**Replace polling with webhooks:** Polling a single database every 10 seconds costs 360 requests/hour (3600s / 10s interval). WebRelated in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only — no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.