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

coachlms

v1.0.10

Published

A package to fetch user data using API key authentication

Downloads

80

Readme

Coach LMS API Client

A secure and robust Node.js client for interacting with the Coach LMS API.

Installation

npm install coach-lms-api-client

Usage

const ApiClient = require('coach-lms-api-client');

// Initialize the client
const client = new ApiClient('YOUR_API_KEY', {
    baseURL: 'https://super-admin.coachlms.org/api', // Optional: defaults to this URL
    timeout: 30000,                                   // Optional: default 30 seconds
    maxRetries: 3,                                   // Optional: default 3 retries
    retryDelay: 1000                                // Optional: default 1 second
});

Features

  • Secure API key authentication
  • Automatic retry mechanism with exponential backoff
  • Request/Response interceptors for security headers
  • Input validation and sanitization
  • Comprehensive error handling
  • Request tracking with unique IDs

Available Methods

Organization Structure

getOrganisationCategory()

Get all available organization categories.

const categories = await client.getOrganisationCategory();

getOrgSubcategory(categoryId)

Get subcategories for a specific category.

const subcategories = await client.getOrgSubcategory('categoryId');

getOrgProgram(subcategoryId)

Get programs for a specific subcategory.

const programs = await client.getOrgProgram('subcategoryId');

getOrgProgramCohort(programId)

Get cohorts for a specific program.

const cohorts = await client.getOrgProgramCohort('programId');

Program Structure

getProgramTerm(cohortId)

Get terms for a specific cohort.

const terms = await client.getProgramTerm('cohortId');

getProgramTermSection(termId)

Get sections for a specific term.

const sections = await client.getProgramTermSection('termId');

getCourses(sectionId)

Get courses for a specific section.

const courses = await client.getCourses('sectionId');

User Management

getUsersDetails(userId)

Get details for a specific user.

const userDetails = await client.getUsersDetails('userId');

getUserAssignment(userId)

Get assignments for a specific user.

const assignments = await client.getUserAssignment('userId');

getUserAnnouncements(userId)

Get announcements for a specific user.

const announcements = await client.getUserAnnouncements('userId');

getUserPortfolioDetails(userId)

Get portfolio details for a specific user.

const portfolioDetails = await client.getUserPortfolioDetails('userId');

getUserSessions(userId)

Get all sessions for a specific user.

const sessions = await client.getUserSessions('userId');

Error Handling

The client includes built-in error handling that throws detailed error messages for:

  • API errors (with status codes)
  • Network errors
  • Request errors
try {
    const data = await client.getUsersDetails('userId');
} catch (error) {
    console.error(error.message);
    // Handles: API Error: 404 - User not found
    // Handles: Network Error: Connection timeout
    // Handles: Request Error: Invalid parameters
}

Security Features

  • Automatic request ID generation for tracking
  • Request timestamp headers
  • Input sanitization
  • Content-Type enforcement
  • Client version tracking
  • Configurable timeout
  • Bearer token authentication

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Security Features

Built-in Security Measures

  1. Request Timeout: Default 30-second timeout for all requests
  2. Automatic Retries: Implements exponential backoff strategy for failed requests
  3. Input Sanitization: Removes potentially dangerous characters from input
  4. Request Tracking:
    • Unique request IDs for each API call
    • Request timestamps for audit trails
  5. Secure Headers: Automatically includes security-related headers
  6. Error Handling: Enhanced error reporting with detailed messages

Configuration Options

const client = new ApiClient('your-api-key', {
    baseURL: 'https://api.example.com',
    timeout: 5000,           // Custom timeout in milliseconds
    maxRetries: 3,           // Maximum number of retry attempts
    retryDelay: 1000        // Base delay between retries in milliseconds
});

Best Practices

  1. API Key Security:

    • Never commit API keys to version control
    • Use environment variables for API key storage
    const client = new ApiClient(process.env.API_KEY);
  2. Error Handling:

    try {
        const userData = await client.getUserData({ uuid: 'user-id' });
    } catch (error) {
        if (error.message.includes('API Error: 401')) {
            // Handle authentication errors
        } else if (error.message.includes('Network Error')) {
            // Handle connection issues
        }
    }
  3. Rate Limiting:

    • Implement appropriate delays between requests
    • Handle rate limit responses appropriately