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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@squiddleton/fortnite-api

v2.0.2

Published

A Node.js-compatible wrapper for Fortnite-API

Downloads

25

Readme

Fortnite-API

About

A Node.js-compatible wrapper for Fortnite-API written in TypeScript.

Usage

Node.js v18+ is required.

Install this scoped package by running the following command in your terminal:

npm install @squiddleton/fortnite-api

The package exports three main objects: the Client constructor with methods that fetch Fortnite-API, the Endpoints enum which contains all of the endpoints used in the package, and the FortniteAPIError class which represents errors received from Fortnite-API. All methods return Promises which must be resolved in order to use the returned structure. Functions, their arguments, and returned structures are documented via the declaration files ending in .d.ts in the transpiled code. This library also adheres to semantic versioning, so breaking changes will only be introduced in major version increments.

const { Client, Endpoints } = require('@squiddleton/fortnite-api'); // ESM syntax is also supported
const { key } = require('./config.json'); // The use of imported or environmental variables is suggested for importing your API key (if you have one)

console.log(Endpoints.Map); // Logs "https://fortnite-api.com/v1/map"

const client = new Client({ key }); // The Client constructor supports an object with a "language" (defaults to "en") and a "key" (if you have one)

client.stats({ name: 'Donald Mustard' })
    .then(console.log); // Logs the user's stats


const clientWithoutOptions = new Client(); // No options are required for general usage

clientWithoutOptions.cosmetics()
    .then(cosmetics => console.log(cosmetics.br)); // Logs an array of Battle Royale cosmetics

clientWithoutOptions.brCosmeticsSearch({ id: 'Lorem ipsum' })
    .then(console.log)
    .catch(console.error); // Throws a FortniteAPIError since the cosmetic does not exist

clientWithoutOptions.stats({ name: 'Mark Rein' })
    .then(console.log)
    .catch(console.error); // Throws a TypeError since the stats endpoint requires an API key to be set

Types

This project is written in TypeScript, but its distributed code is transpiled into CommonJS. As such, it retains the full usability of CommonJS modules while adhering to strictly-typed parameters and responses. IntelliSense is supported via the declaration files created upon transpiling. The interfaces for function arguments and returned structures are also exported in these declaration files, so the package supports TypeScript usage with easily-readable interface names, such as BRCosmetic for the Battle Royale cosmetics endpoints and Stats for the stats endpoints.

Contributing

While the object interfaces mirror the data's properties from the site's dashboard, the documentation's typings do not state whether a property is optional.

If you encounter any optional property that was not correctly documented in the typings, please raise an issue or make a pull request so that other package users will also receive correct typings. Additionally, if any data or parameters change properties and the package typings do not accurately reflect those changes, please take similar action.

Credits

Epic Games, Inc. retains all ownership of the Fortnite intellectual property. This package and its contributors do not represent and are not affiliated with Fortnite-API.com.