27 lines
692 B
TypeScript
27 lines
692 B
TypeScript
|
|
import { SocialhoseClient } from '@socialhose/api';
|
||
|
|
|
||
|
|
const socialhose = new SocialhoseClient({
|
||
|
|
apiKey: process.env.SOCIALHOSE_API_KEY!,
|
||
|
|
cacheTtlMs: 15 * 60 * 1000,
|
||
|
|
});
|
||
|
|
|
||
|
|
const campaignId = process.argv[2];
|
||
|
|
const term = process.argv[3] ?? 'RSF';
|
||
|
|
|
||
|
|
const stats = await socialhose.getEntityStats(term, campaignId, {
|
||
|
|
revalidateSeconds: 15 * 60,
|
||
|
|
});
|
||
|
|
|
||
|
|
console.log(JSON.stringify({
|
||
|
|
term: stats.term,
|
||
|
|
total: stats.total,
|
||
|
|
exact: stats.exact,
|
||
|
|
sentiment: stats.sentiment,
|
||
|
|
platformMix: stats.platformMix,
|
||
|
|
recent7d: stats.recent7d,
|
||
|
|
prev7d: stats.prev7d,
|
||
|
|
momentumPct: stats.momentumPct,
|
||
|
|
sparkline: stats.sparkline,
|
||
|
|
topUrls: stats.sample.slice(0, 5).map((m) => m.url),
|
||
|
|
}, null, 2));
|