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