xiaohongshu
xiaohongshu
juicebox-rate-limits
Implement Juicebox rate limiting and backoff. Use when handling API quotas, implementing retry logic, or optimizing request throughput. Trigger with phrases like "juicebox rate limit", "juicebox quota", "juicebox throttling", "juicebox backoff".
Full skill instructions
Understand and implement proper rate limiting handling for Juicebox API.
| Plan | Requests/Min | Requests/Day | Searches/Month |
|---|---|---|---|
| Free | 10 | 100 | 500 |
| Pro | 60 | 5,000 | 25,000 |
| Enterprise | 300 | 50,000 | Unlimited |
// Juicebox returns these headers with every response
interface RateLimitHeaders {
'x-ratelimit-limit': string; // Max requests per window
'x-ratelimit-remaining': string; // Remaining requests
'x-ratelimit-reset': string; // Unix timestamp when limit resets
'retry-after'?: string; // Seconds to wait (only on 429)
}
function parseRateLimitHeaders(headers: Headers) {
return {
limit: parseInt(headers.get('x-ratelimit-limit') || '0'),
remaining: parseInt(headers.get('x-ratelimit-remaining') || '0'),
reset: new Date(parseInt(headers.get('x-ratelimit-reset') || '0') * 1000),
retryAfter: parseInt(headers.get('retry-after') || '0')
};
}
// lib/rate-limiter.ts
export class RateLimiter {
private queue: Array<() => Promise<void>> = [];
private processing = false;
private lastRequestTime = 0;
private minInterval: number;
constructor(requestsPerMinute: number) {
this.minInterval = 60000 / requestsPerMinute;
}
async execute<T>(fn: () => Promise<T>): Promise<T> {
return new Promise((resolve, reject) => {
this.queue.push(async () => {
try {
const result = await fn();
resolve(result);
} catch (error) {
reject(error);
}
});
this.processQueue();
});
}
private async processQueue() {
if (this.processing || this.queue.length === 0) return;
this.processing = true;
while (this.queue.length > 0) {
const now = Date.now();
const elapsed = now - this.lastRequestTime;
if (elapsed < this.minInterval) {
await sleep(this.minInterval - elapsed);
}
const task = this.queue.shift();
if (task) {
this.lastRequestTime = Date.now();
await task();
}
}
this.processing = false;
}
}
// lib/backoff.ts
export async function withExponentialBackoff<T>(
fn: () => Promise<T>,
options: {
maxRetries?: number;
baseDelay?: number;
maxDelay?: number;
} = {}
): Promise<T> {
const { maxRetries = 5, baseDelay = 1000, maxDelay = 60000 } = options;
let lastError: Error;
for (let attempt = 0; attempt < maxRetries; attempt++) {
try {
return await fn();
} catch (error: any) {
lastError = error;
if (error.code === 'RATE_LIMITED') {
const retryAfter = error.retryAfter || 0;
const backoffDelay = Math.min(
baseDelay * Math.pow(2, attempt),
maxDelay
);
const delay = Math.max(retryAfter * 1000, backoffDelay);
console.log(`Rate limited. Retrying in ${delay}ms (attempt ${attempt + 1}/${maxRetries})`);
await sleep(delay);
continue;
}
throw error;
}
}
throw lastError!;
}
// lib/quota-tracker.ts
export class QuotaTracker {
private dailyRequests = 0;
private dailyResetTime: Date;
constructor(private dailyLimit: number) {
this.dailyResetTime = this.getNextMidnight();
}
async checkQuota(): Promise<boolean> {
this.maybeResetDaily();
return this.dailyRequests < this.dailyLimit;
}
recordRequest() {
this.dailyRequests++;
}
getRemainingQuota(): number {
this.maybeResetDaily();
return this.dailyLimit - this.dailyRequests;
}
private maybeResetDaily() {
if (new Date() > this.dailyResetTime) {
this.dailyRequests = 0;
this.dailyResetTime = this.getNextMidnight();
}
}
}
| Scenario | Strategy |
|---|---|
| 429 with Retry-After | Wait exact duration |
| 429 without Retry-After | Exponential backoff |
| Approaching limit | Proactive throttling |
| Daily quota exhausted | Queue for next day |
After rate limit handling, see juicebox-security-basics for security best practices.
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience