Files

30 lines
743 B
TypeScript
Raw Permalink Normal View History

2026-05-29 13:35:09 -05:00
import { SocialhoseClient, SocialhoseError } from '@socialhose/api';
const socialhose = new SocialhoseClient({
apiKey: process.env.SOCIALHOSE_API_KEY!,
});
try {
const campaigns = await socialhose.getCampaigns();
const campaignId = campaigns[0]?.id;
const mentions = await socialhose.getMentions({
campaign_ids: campaignId,
content_search: 'hospital',
ordering: '-published_at',
});
console.log({
campaigns: campaigns.length,
mentionCount: mentions.count,
firstMention: mentions.results[0]?.url,
});
} catch (error) {
if (error instanceof SocialhoseError) {
console.error({ status: error.status, path: error.path, body: error.body });
process.exitCode = 1;
} else {
throw error;
}
}