@dracoonghost/trndup-sdk 1.4.0 → 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