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

fshub-api

v4.1.4

Published

TypeScript HTTP API wrapper library for FSHub REST API

Readme

FSHub API

A TypeScript HTTP API wrapper library for the FSHub REST API, providing a clean and type-safe interface for interacting with FSHub's flight simulation community platform.

📑 Table of Contents

🎯 Purpose

This library simplifies integration with the FSHub API by providing:

  • Type Safety: Full TypeScript support with comprehensive type definitions
  • Clean Interface: Simple, intuitive methods for all FSHub API endpoints
  • Error Handling: Built-in error handling and response validation
  • Modern JavaScript: Built with modern ES modules and async/await patterns

🚀 Installation

npm install fshub-api

📋 Prerequisites

  • Node.js 18+
  • A valid FSHub API key (get one from FSHub)

⚙️ Configuration

Optionally. create a .env file in your project root:

FSHUB_API_KEY=your_api_key_here

🔧 Basic Setup

import FSHubApi from 'fshub-api';

const api = new FSHubApi({
    apiKey: process.env.FSHUB_API_KEY,
    // Optional configurations:
    baseURL: 'https://fshub.io/api/v3/', // Default
    timeout: 10000, // Default: 10 seconds
    headers: {} // Additional headers
});

📖 Usage Examples

Pilot Operations

Get Current Pilot

const currentPilot = await api.Pilot_getCurrent();
console.log(`Current pilot: ${currentPilot.name} from ${currentPilot.base}`);

Get All Pilots

const allPilots = await api.Pilot_getAll();
console.log(`Total pilots: ${allPilots.length}`);

Get Specific Pilot

const pilot = await api.Pilot_get(123);
console.log(`Pilot ${pilot.name} is ${pilot.is_online ? 'online' : 'offline'}`);

Get Pilot Statistics

const stats = await api.Pilot_getStats(123);
console.log(`Total flights: ${stats.all_time.total_flights}`);
console.log(`Total hours: ${stats.all_time.total_hours}`);

Get Pilot Flights

// Get all flights
const allFlights = await api.Pilot_getAllFlights(123);

// Get latest flight
const latestFlight = await api.Pilot_getLatestFlight(123);

// Get flights from specific airport
const departures = await api.Pilot_getAllFlightsDepartures(123, 'KPHX');
const arrivals = await api.Pilot_getAllFlightsArrivals(123, 'KLAX');

// Get flights between specific airports
const routeFlights = await api.Pilot_getAllFlightDeparturesAndArrivals(123, 'KPHX', 'KLAX');

Get Pilot Screenshots

const screenshots = await api.Pilot_getAllScreenshots(123);
screenshots.forEach(screenshot => {
    console.log(`Screenshot: ${screenshot.name} - ${screenshot.urls.fullsize}`);
});

Airline Operations

Get All Airlines

const airlines = await api.Airline_getAll();
console.log(`Total airlines: ${airlines.length}`);

Get Specific Airline

const airline = await api.Airline_get(6082);
console.log(`Airline: ${airline.name} (${airline.abbr})`);

Get Airline Pilots

const pilots = await api.Airline_getPilots(6082);
console.log(`Airline has ${pilots.length} pilots`);

Get Airline Statistics

const stats = await api.Airline_getStats(6082);
console.log(`Total pilots: ${stats.total_pilots}`);
console.log(`Monthly flights: ${stats.month.total_flights}`);

Get Airline Flights

// Get all flights
const allFlights = await api.Airline_getFlights(6082);

// Get flights from specific airport
const departures = await api.Airline_getAllFlightsDepartures(6082, 'KPHX');
const arrivals = await api.Airline_getAllFlightsArrivals(6082, 'KLAX');

// Get flights between specific airports
const routeFlights = await api.Airline_getAllFlightDeparturesAndArrivals(6082, 'KPHX', 'KLAX');

Get All Airline Roles

// Get all Roles
const allRoles = await api.Airline_getAllRoles();

Get All Airline Ranks

// Get all Ranks
const allRanks = await api.Airline_getAllRanks();

Set Airline Pilot Rank

const rank_id = 6254 // Reef Recruit
const pilot_id = 25097 //NDBoost

const payload: FSHubPilotSetRankData = {
  rank_id: rank_id,
};

const response: FSHubApplicationResponse = await api.Airline_pilotSetRank(pilot_id, airline_id, payload);

Approve Manual PIREP

const flight_id = 4351163;
const response: FSHubApplicationResponse = await api.Airline_approveManualPIREP(airline_id, flight_id);

Reject Manual PIREP

const flight_id = 4351163;
const response: FSHubApplicationResponse = await api.Airline_rejectManualPIREP(airline_id, flight_id);

🔍 Data Types

The library provides comprehensive TypeScript types for all FSHub data structures:

  • Pilot: Pilot information, status, and location
  • Flight: Flight details, aircraft, airports, and performance metrics
  • Airline: Airline information and ownership details
  • PilotStats: Comprehensive pilot statistics (all-time and monthly)
  • Screenshot: Pilot screenshot metadata and URLs
  • Airport: Airport information with weather and navigation data

🧪 Testing

Run the test suite:

npm test

Run tests in watch mode:

npm run test:watch

🏗️ Development

Build

npm run build

Lint

npm run lint

Development Mode

npm run dev

📚 API Reference

Pilot Methods

  • Pilot_getCurrent() - Get current authenticated pilot
  • Pilot_getAll() - Get all pilots
  • Pilot_get(id) - Get specific pilot by ID
  • Pilot_getLatestFlight(id) - Get pilot's latest flight
  • Pilot_getAllFlights(id) - Get all pilot flights
  • Pilot_getStats(id) - Get pilot statistics
  • Pilot_getAllFlightsDepartures(id, airportCode) - Get flights departing from airport
  • Pilot_getAllFlightsArrivals(id, airportCode) - Get flights arriving at airport
  • Pilot_getAllFlightDeparturesAndArrivals(id, departureAirport, arrivalAirport) - Get flights between airports
  • Pilot_getAllScreenshots(id) - Get pilot screenshots

Airline Methods

  • Airline_getAll() - Get all airlines
  • Airline_get(id) - Get specific airline by ID
  • Airline_getPilots(id) - Get airline pilots
  • Airline_getPilotStats(id, pilotId) - Get pilot stats within airline
  • Airline_getFlights(id) - Get airline flights
  • Airline_getAllFlightsDepartures(id, airportCode) - Get airline flights departing from airport
  • Airline_getAllFlightsArrivals(id, airportCode) - Get airline flights arriving at airport
  • Airline_getAllFlightDeparturesAndArrivals(id, departureAirport, arrivalAirport) - Get airline flights between airports
  • Airline_getAllScreenshots(id) - Get airline screenshots
  • Airline_getStats(id) - Get airline statistics
  • Airline_approveApplication - approve an application to join the airline
  • Airline_rejectApplication - reject an application to join the airline
  • Airline_pilotPointPurchase - exchange pilots points for airline
  • Airline_pilotSetRank - set a pilots rank
  • Airline_getAllRanks - get all airline ranks
  • Airline_getAllRoles - get all airline roles
  • Airline_approveManualPIREP - approve a member pilot submitted manual PIREP
  • Airline_rejectManualPIREP - reject a member pilot submitted manual PIREP

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Ensure all tests pass
  6. Submit a pull request

📄 License

ISC License

🔗 Links

🆘 Support

If you encounter any issues or have questions:

  1. Check the FSHub API documentation
  2. Review the test examples in this repository
  3. Open an issue on GitHub