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 🙏

© 2025 – Pkg Stats / Ryan Hefner

spur-client

v0.5.1

Published

Client to access the Spur API.

Readme

Client to access the Spur API.

Start with fetching a quote using SpurClient.quote and execute a swap using SpurClient.swapInteractive in the browser using a Solana Wallet Adapter or SpurClient.swapNonInteractive in a server or cli application using a Keypair.

Installation

npm install spur-client

Quick Start

Browser with Wallet Adapter

import { SpurClient } from 'spur-client';
import { Connection } from '@solana/web3.js';
import { useWallet } from '@solana/wallet-adapter-react';

const client = new SpurClient('your-wallet-public-key');
const connection = new Connection('https://api.mainnet-beta.solana.com');
const { wallet } = useWallet();

// Get a quote
const quote = await client.quote(
  BigInt(1000000), // 1 USDC (6 decimals)
  'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v', // USDC mint
  'So11111111111111111111111111111111111111112'  // SOL mint
);

// Execute swap
const signature = await client.swapInteractive(
  connection,
  quote,
  wallet.adapter,
  0.01 // 1% slippage
);

console.log('Swap completed:', signature);

Server/CLI with Keypair

import { SpurClient } from 'spur-client';
import { Connection, Keypair } from '@solana/web3.js';
import fs from 'fs';

// Load keypair
const secretKey = JSON.parse(fs.readFileSync('keypair.json', 'utf8'));
const keypair = Keypair.fromSecretKey(Uint8Array.from(secretKey));

const client = new SpurClient(keypair.publicKey.toString());
const connection = new Connection('https://api.mainnet-beta.solana.com');

// Get quote and execute swap
const quote = await client.quote(
  BigInt(1000000000), // 1 SOL (9 decimals)
  'So11111111111111111111111111111111111111112', // SOL
  'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'  // USDC
);

const signature = await client.swapNonInteractive(
  connection,
  quote,
  keypair,
  0.005 // 0.5% slippage
);

console.log('Swap completed:', signature);

API Overview

SpurClient

// Initialize client
const client = new SpurClient(payerPublicKey?: string);

// Get swap quote
const quote = await client.quote(inputAmount, inputMint, outputMint, limits?);

// Get priority fees
const priorityLamports = await client.getPriorityLamports("medium"); // "high" | "medium" | "low"

// Execute swap with wallet adapter
const signature = await client.swapInteractive(connection, quote, wallet, slippage, priorityLamports?);

// Execute swap with keypair
const signature = await client.swapNonInteractive(connection, quote, signer, slippage, priorityLamports?);

// Advanced: compile transaction without executing
const compiledSwap = await client.compileSwap(connection, quote, slippage, priorityLamports?, blockhash?);

Common Token Mints

const USDC = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v';
const SOL = 'So11111111111111111111111111111111111111112';
const USDT = 'Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB';

Advanced Usage

Custom Transaction Handling

// Compile swap for custom handling
const swap = await client.compileSwap(connection, quote, 0.01);

// Sign transaction
await swap.signInteractive(wallet); // or swap.signNonInteractive(keypair)

// Send and confirm
const signature = await swap.sendTransaction(connection);
const error = await swap.confirmTransaction(connection);

if (error) {
  console.error('Transaction failed:', error);
} else {
  console.log('Transaction confirmed:', signature);
}

Setting Resource Limits

const quote = await client.quote(
  inputAmount,
  inputMint,
  outputMint,
  {
    compute_units: 800_000,  // Compute budget (default: 1,000,000)
    encoded_bytes: 1000      // Transaction size limit (default: 1,100)
  }
);

Priority Fee Management

// Get current priority fees
const highFee = await client.getPriorityLamports("high");
const mediumFee = await client.getPriorityLamports("medium");
const lowFee = await client.getPriorityLamports("low");

// Use custom priority fee
const signature = await client.swapInteractive(
  connection,
  quote,
  wallet,
  0.01,
  BigInt(50000) // 50k lamports
);

Error Handling

try {
  const quote = await client.quote(inputAmount, inputMint, outputMint);
  const signature = await client.swapInteractive(connection, quote, wallet, 0.01);
  console.log('Swap successful:', signature);
} catch (error) {
  if (error.message.includes('could not find route')) {
    console.error('No trading route available');
  } else if (error.message.includes('could not quote')) {
    console.error('Quote failed:', error.message);
  } else {
    console.error('Swap failed:', error);
  }
}

Notes

  • All amounts are in native token atoms (smallest unit)
  • Slippage is expressed as a decimal (0.01 = 1%)
  • Priority fees help with transaction inclusion during network congestion
  • The client automatically handles Address Lookup Tables (ALTs) for transaction compression
  • Failed transactions are automatically reported to Spur for debugging
  • Use the demo website to make some test transactions