Skip to main content Início Criadores jeremylongshore tons-of-skills-marketplace maintainx-cost-tuning
maintainx-cost-tuning Optimize MaintainX API usage for cost efficiency.
Use when managing API costs, optimizing request volume,
or implementing cost-effective integration patterns with MaintainX.
Trigger with phrases like "maintainx cost", "maintainx billing",
"reduce maintainx usage", "maintainx api costs", "maintainx optimization".
Ir para a instalação Skills Marketplace Descubra e explore skills de IA criadas pela comunidade.
Instalar com Codex ou Claude Copie este prompt, cole no Codex, Claude ou outro assistente e deixe que ele revise a página da skill e instale para você.
Copiar promptMostrar detalhes do prompt Um comando direto ignora o prompt de revisão. Verifique a origem antes de executá-lo.
npx skills add https://github.com/jeremylongshore/tons-of-skills-marketplace --skill maintainx-cost-tuningO comando permanece em uma só linha. Role horizontalmente para revisá-lo antes de copiar.
Prefere uma cópia local? Baixe os arquivos disponíveis atualmente no SkillsMP.
Baixar Zip Baixando... Mais deste repositório langchain-deploy-integration Deploy a LangChain 1.0 / LangGraph 1.0 app to Cloud Run, Vercel, or LangServe correctly — with timeouts sized for chain length, cold-start mitigation, SSE anti-buffering headers, and Secret Manager over .env. Use when prepping a first production deploy, debugging a stream that hangs behind a proxy, or diagnosing p99 latency spikes. Trigger with "langchain deploy", "langchain cloud run", "langchain vercel python", "langchain langserve", or "langchain docker".
langchain-langgraph-agents Build a correct LangGraph 1.0 ReAct agent with create_react_agent — typed tools, error propagation, recursion caps, and stop conditions that actually stop. Use when writing a first tool-calling agent, migrating from AgentExecutor or initialize_agent, or diagnosing an agent that loops on vague prompts. Trigger with "langgraph agent", "create_react_agent", "langgraph tool calling", "AgentExecutor migration", or "agent loop cost".
langchain-langgraph-human-in-loop Build LangGraph 1.0 human-in-the-loop approval flows with interrupt_before /
interrupt_after and Command(resume=...) — JSON-serializable state, clean
resume semantics, and UI wiring for approval decisions. Use when adding an
approval gate before an expensive tool call, wiring a Slack/web UI for agent
approvals, or debugging a graph that crashes on interrupt.
Trigger with "langgraph human in loop", "langgraph interrupt_before",
"langgraph approval flow", "Command resume", "langgraph HITL".
Explorador de arquivos
2 arquivos name maintainx-cost-tuning description Optimize MaintainX API usage for cost efficiency.
Use when managing API costs, optimizing request volume,
or implementing cost-effective integration patterns with MaintainX.
Trigger with phrases like "maintainx cost", "maintainx billing",
"reduce maintainx usage", "maintainx api costs", "maintainx optimization".
allowed-tools Read, Write, Edit, Bash(npm:*) version 1.11.0 license MIT author Jeremy Longshore <jeremy@intentsolutions.io> tags ["saas","maintainx","api","cost-optimization"] compatibility Designed for Claude Code
MaintainX Cost Tuning
Overview
Reduce MaintainX API request volume and optimize costs through caching, webhook-driven sync, request batching, and smart polling strategies.
Prerequisites
MaintainX integration deployed and working
Redis or in-memory cache available
Baseline API usage metrics
Instructions
Step 1: Request Volume Tracking
class ApiUsageTracker {
private counts : Map <string , number > = new Map ();
private startTime = Date .now ();
record (endpoint : string ) {
const key = endpoint.split ('?' )[0 ];
this .counts .set (key, (this .counts .get (key) || 0 ) + 1 );
}
report ( ) {
const elapsed = (Date .now () - this .startTime ) / 1000 / 60 ;
console .log (`\n=== API Usage Report (${elapsed.toFixed( )} min) ===` );
sorted = [... . . ()]. ( b[ ] - a[ ]);
( [endpoint, count] sorted) {
rate = (count / elapsed). ( );
. ( );
}
. ( );
}
}
tracker = ();
( tracker. (), );
1
const
this
counts
entries
sort
(a, b ) =>
1
1
for
const
of
const
toFixed
1
console
log
` ${endpoint} : ${count} calls (${rate} /min)`
console
log
` TOTAL: ${[...this .counts.values()].reduce((a, b) => a + b, 0 )} calls`
export
const
new
ApiUsageTracker
setInterval
() =>
report
600_000
Step 2: Response Caching
interface CacheEntry <T> {
data : T;
expiresAt : number ;
}
class CachedMaintainXClient {
private cache = new Map <string , CacheEntry <any >>();
private client : MaintainXClient ;
private ttl : Record <string , number > = {
'/users' : 300 ,
'/locations' : 300 ,
'/assets' : 120 ,
'/workorders' : 30 ,
'/teams' : 600 ,
};
constructor (client : MaintainXClient ) {
this .client = client;
}
async get<T>(endpoint : string , params ?: any ): Promise <T> {
const cacheKey = `${endpoint} :${JSON .stringify(params || {})} ` ;
const cached = this .cache .get (cacheKey);
if (cached && cached.expiresAt > Date .now ()) {
console .log (`[CACHE HIT] ${endpoint} ` );
return cached.data ;
}
const basePath = '/' + endpoint.split ('/' ).filter (Boolean )[0 ];
const ttlSec = this .ttl [basePath] || 60 ;
const data = await this .client .request ('GET' , endpoint, undefined , params);
this .cache .set (cacheKey, {
data,
expiresAt : Date .now () + ttlSec * 1000 ,
});
tracker.record (endpoint);
return data as T;
}
invalidate (pattern : string ) {
for (const key of this .cache .keys ()) {
if (key.startsWith (pattern)) {
this .cache .delete (key);
}
}
}
}
Step 3: Webhook-Driven Sync (Replace Polling) Polling every 30 seconds costs thousands of requests/day per endpoint. Webhooks reduce this to near zero.
setInterval (async () => {
const { workOrders } = await client.getWorkOrders ({ status : 'OPEN' });
await syncToLocalDb (workOrders);
}, 30_000 );
app.post ('/webhooks/maintainx' , async (req, res) => {
const { event, data } = req.body ;
if (event === 'workorder.updated' || event === 'workorder.created' ) {
await upsertWorkOrder (data);
}
res.status (200 ).json ({ ok : true });
});
Cost savings : From thousands of daily polling requests to ~50 req/day (webhook-driven deltas only).
Step 4: Smart Polling with Conditional Requests When webhooks are not available, reduce unnecessary fetches:
async function smartPoll (client : MaintainXClient , state : { lastModified?: string } ) {
const response = await client.getWorkOrders ({
updatedAtGte : state.lastModified || new Date (0 ).toISOString (),
limit : 100 ,
});
if (response.workOrders .length === 0 ) {
console .log ('No changes since last poll' );
return [];
}
state.lastModified = new Date ().toISOString ();
return response.workOrders ;
}
Step 5: Request Deduplication
const inFlight = new Map <string , Promise <any >>();
async function deduplicatedGet (client : MaintainXClient , endpoint : string ): Promise <any > {
if (inFlight.has (endpoint)) {
return inFlight.get (endpoint)!;
}
const promise = client.request ('GET' , endpoint);
inFlight.set (endpoint, promise);
try {
return await promise;
} finally {
inFlight.delete (endpoint);
}
}
Output
API usage tracking with per-endpoint request counts
Response caching with resource-specific TTLs
Webhook-driven sync replacing expensive polling loops
Smart polling with updatedAtGte filter for change detection
Request deduplication preventing concurrent identical calls
Error Handling Issue Cause Solution Stale cache data TTL too long for volatile resources Reduce TTL for /workorders to 15-30s Webhook delivery failures Endpoint down or unreachable Fall back to polling with longer interval Cache memory growth No eviction policy Set max cache size, use LRU eviction Duplicate webhook events MaintainX retries Deduplicate by event ID (see webhooks skill)
Resources
Next Steps For architecture patterns, see maintainx-reference-architecture.
Examples Redis-based cache for production :
import Redis from 'ioredis' ;
const redis = new Redis (process.env .REDIS_URL );
async function cachedGet (key : string , ttlSec : number , fetcher : () => Promise <any > ) {
const cached = await redis.get (key);
if (cached) return JSON .parse (cached);
const data = await fetcher ();
await redis.setex (key, ttlSec, JSON .stringify (data));
return data;
}
const workOrders = await cachedGet (
'maintainx:workorders:open' ,
30 ,
() => client.getWorkOrders ({ status : 'OPEN' }),
);