SDK Examples
Complete, copy-paste-ready code for common tasks.
Browse Providers
import { StudioClient } from '@yapture/studio-sdk';
const client = new StudioClient();
// List all providers
const all = await client.browse.list();
console.log(`${all.total} providers found`);
// Filter by specialty
const devShops = await client.browse.list({ specialty: 'DEVELOPMENT' });
// Featured only
const featured = await client.browse.featured({ limit: 5 });
// Single provider profile
const foobar = await client.browse.get('foobar-studio');
console.log(foobar.headline); // "Design. Build. Ship." Submit Provider Interest
import { StudioClient } from '@yapture/studio-sdk';
const client = new StudioClient();
const result = await client.interest.submit({
fullName: 'Jamie Chen',
email: 'jamie@foobar.studio',
companyName: 'Foobar Studio',
specialties: ['DEVELOPMENT', 'DESIGN', 'DEVOPS'],
description: 'Full-stack design and dev agency with 12 years experience.',
portfolioLinks: [
'https://foobar.studio/portfolio',
'https://github.com/foobar-studio',
],
turnstileToken: 'cf-token-from-widget',
});
console.log(result.message);
// "Interest submitted. Check your email to verify." Update Your Listing
import { StudioClient } from '@yapture/studio-sdk';
const client = new StudioClient({
apiKey: process.env.YAPTURE_STUDIO_API_KEY,
});
// Update specific fields
await client.providers.update('foobar-studio', {
headline: 'Design. Build. Ship. Scale.',
description: 'Now offering dedicated retainer plans.',
specialties: ['DEVELOPMENT', 'DESIGN', 'DEVOPS'],
websiteUrl: 'https://foobar.studio',
});
// Toggle visibility
await client.providers.unpublish('foobar-studio');
// ... later
await client.providers.publish('foobar-studio'); Manage Team Members
import { StudioClient } from '@yapture/studio-sdk';
const client = new StudioClient({
apiKey: process.env.YAPTURE_STUDIO_API_KEY,
});
// List current members
const members = await client.members.list('foobar-studio');
console.log(`${members.length} team members`);
// Invite someone
const newMember = await client.members.invite('foobar-studio', {
email: 'morgan@foobar.studio',
role: 'MEMBER',
});
console.log(`Invited ${newMember.inviteEmail}`);
// Remove a member
await client.members.remove('foobar-studio', newMember.id); Fetch Relationships
import { StudioClient } from '@yapture/studio-sdk';
const client = new StudioClient({
apiKey: process.env.YAPTURE_STUDIO_API_KEY,
});
// Full fetch of all relationships
const relationships = await client.relationships.list();
console.log(`${relationships.providers.length} providers`);
console.log(`${relationships.clients.length} clients`);
// List all provider slugs (used in DSL tokens)
for (const p of relationships.providers) {
console.log(`#$yap:studio:${p.slug} → ${p.name}`);
}
// List all client slugs
for (const c of relationships.clients) {
console.log(`#$yap:studio:client:${c.slug} → ${c.name}`);
} Incremental Sync and Caching
import { StudioClient } from '@yapture/studio-sdk';
import type { StudioRelationshipCache, StudioRelationshipEntry } from '@yapture/studio-sdk';
const client = new StudioClient({
apiKey: process.env.YAPTURE_STUDIO_API_KEY,
});
// In-memory cache (swap with localStorage, SQLite, etc.)
let cache: StudioRelationshipCache | null = null;
function mergeEntries(
existing: StudioRelationshipEntry[],
updates: StudioRelationshipEntry[],
): StudioRelationshipEntry[] {
const map = new Map(existing.map(e => [e.slug, e]));
for (const entry of updates) {
map.set(entry.slug, entry);
}
return Array.from(map.values());
}
async function refresh() {
if (!cache) {
cache = await client.relationships.list();
} else {
const delta = await client.relationships.sync(cache.lastSyncedAt);
cache = {
providers: mergeEntries(cache.providers, delta.providers),
clients: mergeEntries(cache.clients, delta.clients),
lastSyncedAt: delta.lastSyncedAt,
};
}
return cache;
}
// Initial load
await refresh();
// Periodic sync every 5 minutes
setInterval(refresh, 5 * 60 * 1000); Error Handling
import { StudioClient, StudioApiError } from '@yapture/studio-sdk';
const client = new StudioClient({
apiKey: process.env.YAPTURE_STUDIO_API_KEY,
});
try {
await client.providers.update('foobar-studio', {
headline: 'New tagline',
});
} catch (err) {
if (err instanceof StudioApiError) {
switch (err.status) {
case 401:
console.error('Invalid API key');
break;
case 403:
console.error('Provider not approved');
break;
case 400:
console.error('Validation error:', err.body);
break;
default:
console.error(`API error ${err.status}: ${err.message}`);
}
} else {
throw err;
}
} Local Development
import { StudioClient } from '@yapture/studio-sdk';
// Point at your local admin backend
const client = new StudioClient({
apiKey: process.env.YAPTURE_STUDIO_API_KEY,
baseUrl: 'http://localhost:5175',
});
// Everything works the same
const providers = await client.browse.list();
console.log(providers);