npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@dracoonghost/trndup-sdk

v1.5.4

Published

Official TypeScript SDK for TrndUp API with Firebase authentication

Downloads

397

Readme

TrndUp TypeScript SDK

Official TypeScript SDK for the TrndUp API with Firebase authentication support.

Installation

# In your mobile app
npm install file:../trndup-service/src/sdk
# or when published
npm install @dracoonghost/trndup-sdk

Quick Start

import { TrndUpSDK } from '@dracoonghost/trndup-sdk';
import auth from '@react-native-firebase/auth';

// Initialize SDK
const sdk = new TrndUpSDK({
  baseUrl: 'https://api.trndup.app', // or 'http://localhost:3000' for dev
  getToken: async () => {
    const user = auth().currentUser;
    return user ? await user.getIdToken() : null;
  },
  onAuthFailure: () => {
    // Handle auth failure - navigate to login
    console.log('Authentication failed - please log in again');
  },
  debug: __DEV__, // Enable debug logging in development
});

export default sdk;

Usage

Authentication

// Login with Firebase ID token
const result = await sdk.auth.login(firebaseIdToken);
console.log('User:', result.user);

// Get current user
const { user, socialAccounts } = await sdk.auth.getCurrentUser();

// Update profile
await sdk.auth.updateProfile({
  username: 'New Name',
  picture: 'https://...',
});

// Logout
await sdk.auth.logout();

YouTube Analytics

// Check initialization status
const status = await sdk.youtube.getInitStatus();
console.log('Needs init:', status.needsInit);

// Initialize YouTube data
if (status.needsInit) {
  await sdk.youtube.initialize();
}

// Get videos
const { videos, total } = await sdk.youtube.getVideos({
  limit: 20,
  sortBy: 'views',
});

// Get channel metrics
const metrics = await sdk.youtube.getChannelMetrics();
console.log('Subscribers:', metrics.subscriberCount);

// Get health score
const health = await sdk.youtube.getHealthScore({ range: '30d' });
console.log('Score:', health.score, 'Grade:', health.grade);

Instagram Analytics

// Check initialization status
const status = await sdk.instagram.getInitStatus();

// Get posts
const { posts } = await sdk.instagram.getPosts({ limit: 20 });

// Get account metrics
const metrics = await sdk.instagram.getAccountMetrics();
console.log('Followers:', metrics.followersCount);

Social Account Linking

// Link YouTube account
await sdk.social.linkYouTube({
  accessToken: 'ya29.a0...',
  refreshToken: '1//0g...',
});

// Link Instagram account
await sdk.social.linkInstagram({
  accessToken: 'IGQVJ...',
});

// Get connected accounts
const accounts = await sdk.social.getConnectedAccounts();

// Unlink account
await sdk.social.unlinkAccount('youtube');

Cross-Platform Insights

// Get overview
const overview = await sdk.insights.getOverview();
console.log('Total followers:', overview.totalFollowers);

// Get trending content
const trending = await sdk.insights.getTrending();

Error Handling

import { TrndUpApiError, TrndUpNetworkError } from '@dracoonghost/trndup-sdk';

try {
  await sdk.youtube.getVideos();
} catch (error) {
  if (error instanceof TrndUpApiError) {
    console.error('API Error:', error.message);
    console.error('Status:', error.status);
    console.error('Code:', error.code);
    
    if (error.isAuthError()) {
      // Handle authentication error
      console.log('Please log in again');
    }
    
    if (error.isRateLimitError()) {
      // Handle rate limiting
      console.log('Too many requests, please wait');
    }
  } else if (error instanceof TrndUpNetworkError) {
    console.error('Network Error:', error.message);
  } else {
    console.error('Unknown error:', error);
  }
}

Configuration Options

interface TrndUpClientConfig {
  /** Base URL for the API */
  baseUrl: string;
  
  /** Function to get the current Firebase ID token */
  getToken: () => string | null | Promise<string | null>;
  
  /** Called when auth completely fails */
  onAuthFailure?: () => void | Promise<void>;
  
  /** Called on any API error */
  onError?: (error: ApiErrorResponse, endpoint: string) => void;
  
  /** Custom headers to include in all requests */
  defaultHeaders?: Record<string, string>;
  
  /** Request timeout in milliseconds (default: 30000) */
  timeout?: number;
  
  /** Enable debug logging (default: false) */
  debug?: boolean;
}

Type Safety

The SDK is fully typed with TypeScript. All request/response types are available:

import type { Auth, YouTube, Instagram, Social, Insights } from '@dracoonghost/trndup-sdk';

// Use types in your code
const user: Auth.User = await sdk.auth.getCurrentUser();
const videos: YouTube.Video[] = await sdk.youtube.getVideos();

Development

# Build SDK
cd src/sdk
npm install
npm run build

# Watch mode for development
npm run dev

# Type check
npm run type-check

# Link for local development
npm link

# In your mobile app
npm link @dracoonghost/trndup-sdk

License

MIT