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

@hellomoon/api

v1.23.0

Published

SDK for Hello Moon's REST API, Streaming, and Subscription Management

Downloads

4,645

Readme

Hello Moon API SDK

Installation

Package Manager

Using npm:

$ npm install @hellomoon/api

Using yarn:

$ yarn add @hellomoon/api

Managing subscriptions

Listing your subscriptions

const { RestClient } = require("@hellomoon/api");

const client = new RestClient(process.env.API_KEY);
client.send(new ListStreamsRequest()).then(subscriptions => {
    // Do something with your subscriptions
}).catch(console.error);

Create a subscription

const { RestClient, TokenSwapStream, dataStreamFilters } = require("@hellomoon/api");

const stream = new TokenSwapStream({
    target: {
        targetType: "WEBSOCKET",
    },
    filters: {
        programId: dataStreamFilters.text.equals("whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc")
    },
    name: "SDK Test"
});

const client = new RestClient(process.env.API_KEY);
client.send(new CreateStreamsRequest(stream)).then(subscription => {
    // Do something with your subscription
}).catch(console.error);

Update a subscription

const { RestClient, TokenSwapStream, dataStreamFilters } = require("@hellomoon/api");

const stream = new TokenSwapStream({
    id: "YOUR_SUBSCRIPTION_ID",
    target: {
        targetType: "WEBSOCKET",
    },
    filters: {
        programId: dataStreamFilters.text.equals("whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc")
    },
    name: "SDK Test"
});

const client = new RestClient(process.env.API_KEY);
client.send(new UpdateStreamsRequest(stream)).then(subscription => {
    // Do something with your subscription
}).catch(console.error);

Delete a subscription

const { RestClient } = require("@hellomoon/api");

const client = new RestClient(process.env.API_KEY);
client.send(new DeleteStreamsRequest("YOUR_SUBSCRIPTION_ID")).then(() => {
}).catch(console.error);

Available Streams

BalanceChangeStream

Balance changes for all accounts at a transaction level. Each transaction will have 0 or more balance changes.

LpBalanceChangeStream

Balance changes for Liquidity Pool (LP) at a transaction level.

LpCreationStream

Creation of new Liquidity Pools (LPs)

LpDepositWithdrawalStream

Liquidity has been deposited or withdrawn from the Liquidity Pool (LP).

NftCollectionListingStatsStream

Listing stats for the NFT collection. This is at the collection level. Each collection is emitted at most once per block. If a block contains multiple instruction that modify the stats for a collection, this describes the last instruction.

NftMarketActionStream

Actions taken on secondary NFT markets, e.g. MagicEden. These are generally emitted in the order as they happen on-chain, but new collections may be delayed.

NftPrimarySaleWithCollectionStream

NFT tokens that are minted or sold from the collection to the first owner during the mint phase. These are not emitted in the order as they happen on-chain. To receive the events as they happen on-chain, use NftPrimarySaleWithoutCollection.

NftPrimarySaleWithoutCollectionStream

NFT tokens that are minted or sold from the collection to the first owner during the mint phase. These are emitted in the order as they happen on-chain. To receive the events with the collection name, use NftPrimarySaleWithCollection.

SharkyEventStream

Events related to the Sharky protocol

TokenPriceStream

This stream emits events everytime Hello Moon determines a liquidity pool has changed the valuation of a tokens

TokenSwapStream

This stream emits events anytime a token is swapped on a DEX that Hello Moon monitors.

TokenTransferStream

Balance changes for all accounts at a transaction level. Each transaction will have 0 or more balance changes.

Streaming

Subscribe to a Websocket Subscription

const { StreamClient, isStreamError } = require("@hellomoon/api");

/** 
* The format of the data you expect to receive back from your stream.
* We don't know what a stream will return ahead of time, it is optional to define for typing support
*/
type MyDataType {
    mint: string;
}

const client = new StreamClient(process.env.API_KEY);
client.connect(data => {
    // A fallback message catcher.  This shouldn't fire, but can be used for system messages come through
    console.log(data);
}).then(disconnect => {
    const unsubscribe = client.subscribe("YOUR_SUBSCRIPTION_ID", data => {
        // An array of streamed events
        console.log(data);
    });
    // Disconnect after 60 seconds
    setTimeout(disconnect, 60000);
}, err => {
    // Handle error
    console.log(err);
}).catch(console.error);

Query a Websocket Subscription

const { StreamClient, TokenPriceRequest } = require("@hellomoon/api");

const client = new StreamClient(process.env.API_KEY);
client.connect(data => {
    // A fallback message catcher.  This shouldn't fire, but can be used for system messages come through
    console.log(data);
}).then(disconnect => {
    client.send(new TokenPriceRequest({
        
    }).then(responseData => {
        // The response object
        console.log(responseData);
        // Disconnect when we are done
        disconnect();
    }, err => {
        // Handle error
    }));
    
}).catch(console.error);

Combining streaming with Query

const { StreamClient, isStreamError } = require("@hellomoon/api");

/** 
* The format of the data you expect to receive back from your stream.
* We don't know what a stream will return ahead of time, it is optional to define for typing support
*/
type MyDataType {
    mint: string;
}

const client = new StreamClient(process.env.API_KEY);
client.connect(data => {
    // A fallback message catcher.  This shouldn't fire, but can be used for system messages come through
    console.log(data);
}).then(disconnect => {
    const unsubscribe = client.subscribe<MyDataType>("YOUR_SUBSCRIPTION_ID", data => {        
    client.send(new TokenPriceRequest({
            mint: data[0].mint
        }).then(price => {
            // The response object
            console.log(data);
            // Disconnect when we are done        
        }, err => {
            // Handle error
        }));
    });
    // Disconnect after 10 seconds
    setTimeout(disconnect, 10000);
}).catch(console.error);

Rest API

const { RestClient, NftListingStatusRequest } = require("@hellomoon/api");

const client = new RestClient(process.env.API_KEY);
client
  .send(new NftListingStatusRequest())
  .then(console.log)
  .catch(console.error);

Available Rest Requests

  • AllTimeTxnsByUserRequest
  • BlockRewardsRequest
  • CitrusLoanEventsRequest
  • CitrusLoanSummaryRequest
  • CollaterizedLoanSummaryRequest
  • CollectionAllTimeRequest
  • CollectionFloorpriceRequest
  • CollectionListingCandlesticksRequest
  • CollectionListingStatsRequest
  • CollectionMintsRequest
  • CollectionNameRequest
  • CollectionProgramUsageRequest
  • CollectionStatsRequest
  • CollectionVolatilityRequest
  • CumulativeTokenVolumeRequest
  • CurrentLpEmissionsRequest
  • DailyNftAvgMedianSalesRequest
  • DefiLendingRequest
  • DefiLiquidityPoolsBalancesRequest
  • DefiLiquidityPoolsMetadataRequest
  • DefiLiquidityPoolsRequest
  • DefiProgramLeaderboardV2Request
  • DefiProgramNetNewUsersDailyRequest
  • DefiProgramOverlapRequest
  • DefiSwapProgramsRequest
  • DefiTokenLeaderboardV3Request
  • DefiTokenNetNewPurchasesRequest
  • DefiTokenUsersDailyRequest
  • FilterSetRequest
  • FraktLoanEventsRequest
  • FraktLoanSummaryRequest
  • JupiterCurrentStatsRequest
  • JupiterHistoricalTradingStatsRequest
  • JupiterPairsBrokenDownWeeklyRequest
  • JupiterSwapStatsRequest
  • LeaderboardStatsRequest
  • NftCollectionOwnersCurrentV1Request
  • NftDistinctOwnersInTimeDailyV1Request
  • NftHoldingPeriodV1Request
  • NftListingStatusRequest
  • NftListingsRequest
  • NftMarketStatsRequest
  • NftMintInformationRequest
  • NftMintPriceByCreatorAvgRequest
  • NftMintsByOwnerRequest
  • NftOverlappingOwnersV1Request
  • NftOwnersCumulativeV1Request
  • NftPrimarySaleCollectionStatsRequest
  • NftSocialRequest
  • NftTopHoldersRequest
  • OverlapTopRequest
  • SalesPerMarketDailyRequest
  • SalesPrimaryRequest
  • SalesSecondaryRequest
  • SharkyApyRequest
  • SharkyDefaultStatsRequest
  • SharkyHistoricalDefaultsRequest
  • SharkyLoanEventsRequest
  • SharkyLoanSummaryRequest
  • SolanaArtemisProgramStatsRequest
  • SolanaTxnsByUserRequest
  • SplTokenListRequest
  • Stakeaccountsv2Request
  • Stakeactionsv2Request
  • Staketransfersv2Request
  • StreamCreateRequest
  • StreamUpdateRequest
  • TokenBalancesByOwnerRequest
  • TokenPriceCandlesticksRequest
  • TokenPriceRequest
  • TokenSwapsRequest
  • TokenTransfersWithOwnerRequest
  • Tokencreationv2Request
  • Tokensupplyv2Request
  • TopTokenSellBuyJupRequest
  • TopTokensPerProgram24hrRequest
  • WashtradingCollectionIndexV7Request