@dracoonghost/trndup-sdk 1.3.26 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -727,6 +727,203 @@ var SocialModule = class {
727
727
  var InsightsModule = class {
728
728
  constructor(client) {
729
729
  this.client = client;
730
+ // =========================================================================
731
+ // INSTAGRAM INSIGHTS
732
+ // =========================================================================
733
+ /**
734
+ * Instagram insights sub-module
735
+ */
736
+ this.instagram = {
737
+ /**
738
+ * Get all Instagram insights in one call
739
+ *
740
+ * Efficient for dashboard display - fetches all insights in parallel.
741
+ *
742
+ * @example
743
+ * ```typescript
744
+ * const all = await client.insights.instagram.getAll({ range: '30d' });
745
+ *
746
+ * // Check which insights are available
747
+ * if (all.data.health.hasData) {
748
+ * console.log(`Health Score: ${all.data.health.data.overall}/100`);
749
+ * }
750
+ *
751
+ * if (all.data.bestPost.hasData) {
752
+ * console.log(`Best Post: ${all.data.bestPost.data.post.caption}`);
753
+ * }
754
+ * ```
755
+ *
756
+ * GET /v1/insights/instagram
757
+ */
758
+ getAll: (params) => {
759
+ const queryParams = new URLSearchParams();
760
+ if (params?.range) queryParams.set("range", params.range);
761
+ const query = queryParams.toString();
762
+ return this.client.get(
763
+ `/v1/insights/instagram${query ? `?${query}` : ""}`
764
+ );
765
+ },
766
+ /**
767
+ * Get Instagram health score
768
+ *
769
+ * Overall account health based on consistency, engagement, growth, and reach.
770
+ * Score ranges from 0-100 with labels: excellent, good, fair, needs_attention, poor.
771
+ *
772
+ * @example
773
+ * ```typescript
774
+ * const health = await client.insights.instagram.getHealthScore({ range: '30d' });
775
+ *
776
+ * if (health.hasData) {
777
+ * console.log(`Score: ${health.data.overall}/100 (${health.data.label})`);
778
+ * console.log(`Consistency: ${health.data.components.consistency.score}`);
779
+ * console.log(`Engagement: ${health.data.components.engagement.score}`);
780
+ * console.log(`Growth: ${health.data.components.growth.score}`);
781
+ * console.log(`Reach: ${health.data.components.reach.score}`);
782
+ * }
783
+ * ```
784
+ *
785
+ * GET /v1/insights/instagram/health
786
+ */
787
+ getHealthScore: (params) => {
788
+ const queryParams = new URLSearchParams();
789
+ if (params?.range) queryParams.set("range", params.range);
790
+ const query = queryParams.toString();
791
+ return this.client.get(
792
+ `/v1/insights/instagram/health${query ? `?${query}` : ""}`
793
+ );
794
+ },
795
+ /**
796
+ * Get best performing post
797
+ *
798
+ * Identifies the top performing post in the period based on engagement rate.
799
+ * Includes analysis of why it worked and comparison to average.
800
+ *
801
+ * @example
802
+ * ```typescript
803
+ * const best = await client.insights.instagram.getBestPost({ range: '30d' });
804
+ *
805
+ * if (best.hasData) {
806
+ * console.log(`Post: ${best.data.post.caption}`);
807
+ * console.log(`Engagement: ${best.data.post.metrics.engagementRate}%`);
808
+ * console.log(`Above average: ${best.data.comparison.vsAverage.engagement}%`);
809
+ * }
810
+ * ```
811
+ *
812
+ * GET /v1/insights/instagram/best-post
813
+ */
814
+ getBestPost: (params) => {
815
+ const queryParams = new URLSearchParams();
816
+ if (params?.range) queryParams.set("range", params.range);
817
+ const query = queryParams.toString();
818
+ return this.client.get(
819
+ `/v1/insights/instagram/best-post${query ? `?${query}` : ""}`
820
+ );
821
+ },
822
+ /**
823
+ * Get posting consistency analysis
824
+ *
825
+ * Analyzes posting frequency patterns and consistency.
826
+ * Identifies best posting days and gaps in schedule.
827
+ *
828
+ * @example
829
+ * ```typescript
830
+ * const consistency = await client.insights.instagram.getConsistency({ range: '90d' });
831
+ *
832
+ * if (consistency.hasData) {
833
+ * console.log(`Posts/week: ${consistency.data.frequency.current.postsPerWeek}`);
834
+ * console.log(`Score: ${consistency.data.consistency.score}/100`);
835
+ * console.log(`Best day: ${consistency.data.patterns.mostActiveDay}`);
836
+ * }
837
+ * ```
838
+ *
839
+ * GET /v1/insights/instagram/consistency
840
+ */
841
+ getConsistency: (params) => {
842
+ const queryParams = new URLSearchParams();
843
+ if (params?.range) queryParams.set("range", params.range);
844
+ const query = queryParams.toString();
845
+ return this.client.get(
846
+ `/v1/insights/instagram/consistency${query ? `?${query}` : ""}`
847
+ );
848
+ },
849
+ /**
850
+ * Get follower quality analysis
851
+ *
852
+ * Measures the quality and engagement of followers.
853
+ * Shows growth metrics and engagement rates.
854
+ *
855
+ * @example
856
+ * ```typescript
857
+ * const quality = await client.insights.instagram.getFollowerQuality({ range: '30d' });
858
+ *
859
+ * if (quality.hasData) {
860
+ * console.log(`Quality: ${quality.data.qualityScore}/100`);
861
+ * console.log(`Engagement rate: ${quality.data.metrics.engagementRate}%`);
862
+ * console.log(`Growth: +${quality.data.growth.netChange} followers`);
863
+ * }
864
+ * ```
865
+ *
866
+ * GET /v1/insights/instagram/follower-quality
867
+ */
868
+ getFollowerQuality: (params) => {
869
+ const queryParams = new URLSearchParams();
870
+ if (params?.range) queryParams.set("range", params.range);
871
+ const query = queryParams.toString();
872
+ return this.client.get(
873
+ `/v1/insights/instagram/follower-quality${query ? `?${query}` : ""}`
874
+ );
875
+ },
876
+ /**
877
+ * Get account momentum
878
+ *
879
+ * Shows current account trajectory: surging, growing, stable, declining, or stalling.
880
+ * Compares recent performance to previous periods.
881
+ *
882
+ * @example
883
+ * ```typescript
884
+ * const momentum = await client.insights.instagram.getMomentum();
885
+ *
886
+ * if (momentum.hasData) {
887
+ * console.log(`Status: ${momentum.data.current.status}`);
888
+ * console.log(`Score: ${momentum.data.current.score}`);
889
+ * console.log(`vs Last Week: ${momentum.data.comparison.vsLastWeek}%`);
890
+ * }
891
+ * ```
892
+ *
893
+ * GET /v1/insights/instagram/momentum
894
+ */
895
+ getMomentum: () => {
896
+ return this.client.get("/v1/insights/instagram/momentum");
897
+ },
898
+ /**
899
+ * Get engagement breakdown
900
+ *
901
+ * Breaks down engagement by type: likes, comments, shares, saves.
902
+ * Identifies engagement style and opportunities.
903
+ *
904
+ * @example
905
+ * ```typescript
906
+ * const engagement = await client.insights.instagram.getEngagement({ range: '30d' });
907
+ *
908
+ * if (engagement.hasData) {
909
+ * console.log(`Total: ${engagement.data.totalEngagement}`);
910
+ * console.log(`Style: ${engagement.data.engagementStyle}`);
911
+ * console.log(`Likes: ${engagement.data.breakdown.likes.percent}%`);
912
+ * console.log(`Comments: ${engagement.data.breakdown.comments.percent}%`);
913
+ * }
914
+ * ```
915
+ *
916
+ * GET /v1/insights/instagram/engagement
917
+ */
918
+ getEngagement: (params) => {
919
+ const queryParams = new URLSearchParams();
920
+ if (params?.range) queryParams.set("range", params.range);
921
+ const query = queryParams.toString();
922
+ return this.client.get(
923
+ `/v1/insights/instagram/engagement${query ? `?${query}` : ""}`
924
+ );
925
+ }
926
+ };
730
927
  }
731
928
  /**
732
929
  * Get cross-platform metrics
@@ -1216,6 +1413,133 @@ var ActivityModule = class {
1216
1413
  }
1217
1414
  };
1218
1415
 
1416
+ // modules/trends.ts
1417
+ var TrendsModule = class {
1418
+ constructor(client) {
1419
+ this.client = client;
1420
+ }
1421
+ /**
1422
+ * List trending topics with optional filters
1423
+ *
1424
+ * @param params - Filter and pagination options
1425
+ * @returns Paginated list of trends sorted by relevance
1426
+ *
1427
+ * @example
1428
+ * ```typescript
1429
+ * // Get top trends
1430
+ * const trends = await sdk.trends.list();
1431
+ *
1432
+ * // Filter by category
1433
+ * const sportsTrends = await sdk.trends.list({ category: 'SPORTS' });
1434
+ *
1435
+ * // Filter by velocity
1436
+ * const viralTrends = await sdk.trends.list({ velocity: 'VIRAL' });
1437
+ *
1438
+ * // Paginate
1439
+ * const page2 = await sdk.trends.list({ limit: 20, offset: 20 });
1440
+ * ```
1441
+ */
1442
+ async list(params = {}) {
1443
+ const queryParams = {};
1444
+ if (params.category) queryParams.category = params.category;
1445
+ if (params.velocity) queryParams.velocity = params.velocity;
1446
+ if (params.status) queryParams.status = params.status;
1447
+ if (params.platform) queryParams.platform = params.platform;
1448
+ if (params.limit) queryParams.limit = params.limit;
1449
+ if (params.offset) queryParams.offset = params.offset;
1450
+ return this.client.get("/v1/trends", queryParams);
1451
+ }
1452
+ /**
1453
+ * Get full details of a specific trend
1454
+ *
1455
+ * @param trendId - The unique trend ID
1456
+ * @returns Full trend details including content ideas and examples
1457
+ *
1458
+ * @example
1459
+ * ```typescript
1460
+ * const trend = await sdk.trends.getById('trend_123');
1461
+ * console.log(trend.contentIdeas);
1462
+ * console.log(trend.topExamples);
1463
+ * ```
1464
+ */
1465
+ async getById(trendId) {
1466
+ return this.client.get(`/v1/trends/${trendId}`);
1467
+ }
1468
+ /**
1469
+ * Get all categories with trend counts
1470
+ *
1471
+ * @returns List of categories and their trend counts
1472
+ *
1473
+ * @example
1474
+ * ```typescript
1475
+ * const categories = await sdk.trends.getCategories();
1476
+ * // [{ category: 'SPORTS', count: 15 }, { category: 'TECH', count: 12 }, ...]
1477
+ * ```
1478
+ */
1479
+ async getCategories() {
1480
+ return this.client.get("/v1/trends/meta/categories");
1481
+ }
1482
+ /**
1483
+ * Get all platforms with trend counts
1484
+ *
1485
+ * @returns List of platforms and their trend counts
1486
+ *
1487
+ * @example
1488
+ * ```typescript
1489
+ * const platforms = await sdk.trends.getPlatforms();
1490
+ * // [{ platform: 'YouTube', count: 25 }, { platform: 'Instagram', count: 18 }, ...]
1491
+ * ```
1492
+ */
1493
+ async getPlatforms() {
1494
+ return this.client.get("/v1/trends/meta/platforms");
1495
+ }
1496
+ /**
1497
+ * Get sync status information
1498
+ *
1499
+ * @returns Current sync status and statistics
1500
+ *
1501
+ * @example
1502
+ * ```typescript
1503
+ * const status = await sdk.trends.getSyncStatus();
1504
+ * console.log(status.lastSyncedAt);
1505
+ * console.log(status.totalTrends);
1506
+ * ```
1507
+ */
1508
+ async getSyncStatus() {
1509
+ return this.client.get("/v1/trends/meta/sync-status");
1510
+ }
1511
+ /**
1512
+ * Get viral trends (velocity = VIRAL)
1513
+ * Convenience method for filtering viral trends
1514
+ *
1515
+ * @param limit - Max results (default: 10)
1516
+ * @returns List of viral trends
1517
+ */
1518
+ async getViral(limit = 10) {
1519
+ return this.list({ velocity: "VIRAL", limit });
1520
+ }
1521
+ /**
1522
+ * Get peaking trends (status = PEAKING)
1523
+ * Convenience method for filtering trends at peak
1524
+ *
1525
+ * @param limit - Max results (default: 10)
1526
+ * @returns List of peaking trends
1527
+ */
1528
+ async getPeaking(limit = 10) {
1529
+ return this.list({ status: "PEAKING", limit });
1530
+ }
1531
+ /**
1532
+ * Get trends for a specific platform
1533
+ *
1534
+ * @param platform - Platform name (e.g., 'YouTube', 'Instagram')
1535
+ * @param limit - Max results (default: 20)
1536
+ * @returns List of trends for the platform
1537
+ */
1538
+ async getByPlatform(platform, limit = 20) {
1539
+ return this.list({ platform, limit });
1540
+ }
1541
+ };
1542
+
1219
1543
  // types.ts
1220
1544
  var YOUTUBE_SCOPES = [
1221
1545
  "openid",
@@ -1243,6 +1567,7 @@ var TrndUpSDK = class extends TrndUpClient {
1243
1567
  this.social = new SocialModule(this);
1244
1568
  this.insights = new InsightsModule(this);
1245
1569
  this.activity = new ActivityModule(this);
1570
+ this.trends = new TrendsModule(this);
1246
1571
  }
1247
1572
  };
1248
1573
  var SDK_VERSION = "1.0.0";