Juicebox SDK Patterns
Singleton Client
let instance: JuiceboxClient | null = null;
export function getClient(): JuiceboxClient {
if (!instance) instance = new JuiceboxClient({ apiKey: process.env.JUICEBOX_API_KEY });
return instance;
}
Batch Search with Dedup
async function batchSearch(queries: string[]): Promise<Profile[]> {
const seen = new Set<string>();
const all: Profile[] = [];
for (const q of queries) {
const r = await client.search({ query: q, limit: 20 });
for (const p of r.profiles) {
if (!seen.has(p.linkedin_url)) { seen.add(p.linkedin_url); all.push(p); }
}
}
return all;
}
Error Wrapper
async function safeCall<T>(fn: () => Promise<T>): Promise<T | null> {
try { return await fn(); }
catch (e: any) {
if (e.status === 429) { await new Promise(r => setTimeout(r, 5000)); return fn(); }
return null;
}
}
Resources
Next Steps
Apply in juicebox-core-workflow-a.