From flexport-pack
Optimizes Flexport API costs using webhooks instead of polling, max pagination, smart caching TTLs, and usage monitoring. For logistics apps with high API volume.
How this skill is triggered — by the user, by Claude, or both
Slash command
/flexport-pack:flexport-cost-tuningThis skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
Reduce Flexport API costs by minimizing unnecessary calls. Key strategies: use webhooks instead of polling, cache aggressively, maximize page sizes, and batch operations.
Reduce Flexport API costs by minimizing unnecessary calls. Key strategies: use webhooks instead of polling, cache aggressively, maximize page sizes, and batch operations.
// BAD: Polling every 5 minutes (288 API calls/day per shipment)
setInterval(async () => {
const shipment = await flexport(`/shipments/${id}`);
if (shipment.data.status !== lastStatus) updateDB(shipment);
}, 5 * 60 * 1000);
// GOOD: Webhook-driven (0 API calls — Flexport pushes updates)
app.post('/webhooks/flexport', (req, res) => {
const event = req.body;
if (event.type === 'shipment.milestone') {
updateDB(event.data); // Only processes real changes
}
res.sendStatus(200);
});
// Savings: 100 shipments * 288 calls/day = 28,800 calls/day eliminated
// BAD: Default pagination (per=25)
// 1000 shipments = 40 API calls
// GOOD: Max pagination (per=100)
// 1000 shipments = 10 API calls (75% reduction)
const shipments = await flexport('/shipments?per=100&page=1');
| Data Type | Change Frequency | Cache TTL | Impact |
|---|---|---|---|
| Products | Rarely | 1 hour | ~95% fewer calls |
| Shipment list | Every few hours | 5 minutes | ~90% fewer calls |
| Shipment detail | On milestones | Until webhook | ~99% fewer calls |
| Purchase orders | Daily | 15 minutes | ~85% fewer calls |
| Freight invoices | Monthly | 1 hour | ~95% fewer calls |
// Track API call volume per endpoint
const apiMetrics = new Map<string, { count: number; lastReset: Date }>();
function trackAPICall(endpoint: string) {
const key = endpoint.split('?')[0]; // Strip query params
const metric = apiMetrics.get(key) || { count: 0, lastReset: new Date() };
metric.count++;
apiMetrics.set(key, metric);
}
// Report daily usage
function reportUsage() {
console.log('=== Flexport API Usage ===');
for (const [endpoint, { count }] of apiMetrics) {
console.log(` ${endpoint}: ${count} calls`);
}
}
per=100 on all list endpointsFor architecture design, see flexport-reference-architecture.
npx claudepluginhub jeremylongshore/claude-code-plugins-plus-skills --plugin flexport-packOptimizes Flexport API performance for logistics data using max pagination, LRU caching, p-queue parallel requests, and webhook invalidation.
Creates, edits, and optimizes skills for Claude Code, including drafting, evaluating with test prompts, iterating on performance, and improving skill descriptions for better triggering accuracy.