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

duckapi-client

v1.0.0

Published

A cross-platform client for DuckPowered's official API

Downloads

3

Readme

DuckAPIClient

Introduction

The DuckAPIClient is a TypeScript library designed to interact with the DuckPoweredAPI. It provides a comprehensive set of methods for handling user authentication, device management, friend interactions, notifications, and more. This README.md provides an overview of the library and demonstrates its usage with examples.

Installation

To install the DuckPoweredAPIClient, you can use npm:

npm install duckapi-client

Usage

First, import the DuckPoweredAPIClient into your TypeScript project:

import { DuckPoweredAPIClient, DuckPoweredAPIAuthScope } from 'duck-powered-api-client';

Then, initialize a new instance of the DuckPoweredAPIClient with your preferred data source:

const client = new DuckPoweredAPIClient(DuckPoweredAPIClientDataSource.LocalStorage);

Contributing

To contribute to the DuckPoweredAPIClient, you can clone the repository and install the dependencies:

git clone https://github.com/IntegralPilot/DuckPoweredAPIClient

Then, install the dependencies:

npm install

You can run our unit tests to ensure that your changes do not break any existing functionality:

npm test

Note that you will need to have a local instance of the DuckPoweredAPI running to run the tests. You can find the DuckPoweredAPI repository here.

Any PRs which cause the tests to fail will not be accepted. You may edit the tests in the test directory to add new tests or modify existing ones (so they work with your proposed change).

Examples

Example: User Authentication

// Create an account
const createAccountResult = await client.createAccount("username", "password123!");
console.log(createAccountResult);

// Log in
const loginResult = await client.login("username", "password123!", [DuckPoweredAPIAuthScope.CoreUserInfoRead, DuckPoweredAPIAuthScope.DevicesRead]);
console.log(loginResult);

// Change password
const changePasswordResult = await client.changePassword("username", "password123!", "newPassword456!");
console.log(changePasswordResult);

// Log out
const logoutResult = await client.logout();
console.log(logoutResult);

Example: Device Management

// Create a device
const createDeviceResult = await client.createDevice("MyDevice");
console.log(createDeviceResult);

// Change device name
const changeDeviceNameResult = await client.changeDeviceName("deviceId123", "NewDeviceName");
console.log(changeDeviceNameResult);

// Contribute sample to power saving data
const contributeSampleResult = await client.contributeSampleToPowerSavingData("deviceId123", "W", 75);
console.log(contributeSampleResult);

// Delete device
const deleteDeviceResult = await client.deleteDevice("deviceId123");
console.log(deleteDeviceResult);

Example: Friend Management

// Add a friend
const addFriendResult = await client.addFriend("friendCode123");
console.log(addFriendResult);

// Remove a friend
const removeFriendResult = await client.removeFriend("friendCode123");
console.log(removeFriendResult);

Example: Notifications

// Generate a new notification
const generateNotificationResult = await client.generateNewNotification();
console.log(generateNotificationResult);

// Alter notification read status
const alterNotificationReadStatusResult = await client.alterNotificationReadStatus("notificationId123", true);
console.log(alterNotificationReadStatusResult);

Example: User Information

// Get self information
const selfInformationResult = await client.getSelfInformation();
console.log(selfInformationResult);

Conclusion

The DuckPoweredAPIClient provides a robust set of functionalities for interacting with the DuckPoweredAPI. With its comprehensive methods, handling user authentication, device management, friend interactions, notifications, and user information becomes straightforward and efficient.

For more detailed documentation on each method and its parameters, refer to the TypeScript definitions or the inline JSDoc comments in the source code.