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

solscan-js

v0.1.70

Published

TypeScript client for Solscan API

Readme

Solscan API TypeScript Client

A TypeScript client library for Solscan API. This library provides a convenient way to interact with both public and pro endpoints of the Solscan API.

DISCLAIMER: This is an unofficial library and is not affiliated with, maintained, authorized, endorsed, or sponsored by Solscan or any of its affiliates. This is an independent tool created to help developers interact with the Solscan API.

Installation

npm install solscan-js

Features

  • TypeScript support with proper typing
  • Support for all Solscan API endpoints (public and pro)
  • Clean, Promise-based API
  • Lazy initialization of API modules
  • Helper utilities for building query parameters

API Key

To use the Solscan Pro API endpoints, you need to obtain an API key from Solscan. You can sign up and get your API key at Solscan.

Basic Usage

import { SolscanAPI } from 'solscan-js';

// Initialize with your API key
const solscan = new SolscanAPI('YOUR_API_KEY');

// Public API - Chain info
solscan.public.chainInfo()
  .then(result => console.log(result))
  .catch(error => console.error(error));

// Direct access to account transfers
solscan.account.transfer('ADDRESS')
  .then(result => console.log(result))
  .catch(error => console.error(error));

API Sections

The library provides direct access to all API endpoints. You can now use clean, direct calls without nested structures:

Public API

// Get chain information
solscan.public.chainInfo()
  .then(result => console.log(result))
  .catch(error => console.error(error));

Account API

// Get account details
solscan.account.detail('ADDRESS')
  .then(result => console.log(result))
  .catch(error => console.error(error));

// Get account transfers (direct access!)
solscan.account.transfer('ADDRESS')
  .then(result => console.log(result))
  .catch(error => console.error(error));

// Get account token accounts
solscan.account.tokenAccounts('ADDRESS', 'token', { hideZero: true })
  .then(result => console.log(result))
  .catch(error => console.error(error));

// Get defi activities
solscan.account.defiActivities('ADDRESS', {
  page: 1,
  pageSize: 20,
  sortBy: 'block_time',
  sortOrder: 'desc'
})
  .then(result => console.log(result))
  .catch(error => console.error(error));

// Get balance change activities
solscan.account.balanceChangeActivities('ADDRESS', {
  page: 1,
  pageSize: 20
})
  .then(result => console.log(result))
  .catch(error => console.error(error));

Token API

// Get token metadata
solscan.token.meta('TOKEN_ADDRESS')
  .then(result => console.log(result))
  .catch(error => console.error(error));

// Get trending tokens
solscan.token.trending(10)
  .then(result => console.log(result))
  .catch(error => console.error(error));

// Get token price
solscan.token.tokenPrice('TOKEN_ADDRESS')
  .then(result => console.log(result))
  .catch(error => console.error(error));

// Get top tokens
solscan.token.top()
  .then(result => console.log(result))
  .catch(error => console.error(error));

// Get token defi activities
solscan.token.defiActivities('TOKEN_ADDRESS')
  .then(result => console.log(result))
  .catch(error => console.error(error));

NFT API

// Get NFT news
solscan.nft.news()
  .then(result => console.log(result))
  .catch(error => console.error(error));

// Get NFT collections
solscan.nft.collectionLists({ range: 7 })
  .then(result => console.log(result))
  .catch(error => console.error(error));

// Get collection items
solscan.nft.collectionItems('COLLECTION_ID')
  .then(result => console.log(result))
  .catch(error => console.error(error));

Transaction API

// Get transaction details
solscan.transaction.detail('TX_SIGNATURE')
  .then(result => console.log(result))
  .catch(error => console.error(error));

// Get latest transactions
solscan.transaction.last({ limit: 20 })
  .then(result => console.log(result))
  .catch(error => console.error(error));

Block API

// Get latest blocks
solscan.block.last(50)
  .then(result => console.log(result))
  .catch(error => console.error(error));

// Get block details
solscan.block.detail(BLOCK_NUMBER)
  .then(result => console.log(result))
  .catch(error => console.error(error));

Monitoring API

// Get API usage information
solscan.monitoring.usage()
  .then(result => console.log(result))
  .catch(error => console.error(error));

Advanced Usage

Using with async/await

async function getAccountInfo(address: string) {
  try {
    const accountDetail = await solscan.account.detail(address);
    const tokenAccounts = await solscan.account.tokenAccounts(address, 'token');
    const transfers = await solscan.account.transfer(address);
    
    return {
      account: accountDetail,
      tokens: tokenAccounts,
      transfers: transfers
    };
  } catch (error) {
    console.error('Error fetching account info:', error);
    throw error;
  }
}

Legacy API Access (Backward Compatibility)

If you have existing code using the old structure, it will still work:

// Legacy access (still supported)
solscan.apiV2.account.detail('ADDRESS')
  .then(result => console.log(result))
  .catch(error => console.error(error));

// But you can now use the cleaner direct access:
solscan.account.detail('ADDRESS')
  .then(result => console.log(result))
  .catch(error => console.error(error));

Direct class usage

You can also use the API classes directly if you prefer:

import { TokenAPI } from 'solscan-js';

const tokenApi = new TokenAPI('YOUR_API_KEY');
tokenApi.meta('TOKEN_ADDRESS')
  .then(result => console.log(result))
  .catch(error => console.error(error));

Migration Guide

If you're upgrading from a previous version, you can easily migrate to the new direct access pattern:

// Old way
solscan.apiV2.account.transfer('ADDRESS')
solscan.apiV2.token.meta('TOKEN_ADDRESS')
solscan.publicApi.chainInfo()

// New way (recommended)
solscan.account.transfer('ADDRESS')
solscan.token.meta('TOKEN_ADDRESS')
solscan.public.chainInfo()

The old way still works for backward compatibility, but the new direct access is cleaner and more intuitive.

Error Handling

All API methods return promises that will reject with an error if the API request fails. We recommend using try/catch blocks or promise error handlers to handle these cases.

try {
  const result = await solscan.account.detail('ADDRESS');
  // Process result
} catch (error) {
  // Handle error
  console.error('API request failed:', error);
}

Contributing

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

License

MIT

Disclaimer

This library is not affiliated with, maintained, authorized, endorsed, or sponsored by Solscan or any of its affiliates. All product and company names are the registered trademarks of their original owners. The use of any trade name or trademark is for identification and reference purposes only and does not imply any association with the trademark holder.