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

pmxtjs

v2.49.1

Published

Unified prediction market data API - The ccxt for prediction markets

Downloads

20,259

Readme

pmxtjs

A unified TypeScript/Node.js SDK for prediction markets — The ccxt for prediction markets.

Note: Use with a PMXT API key (hosted, recommended) or self-host the sidecar locally. Get a key at pmxt.dev/dashboard.

Installation

npm install pmxtjs

Quick Start

Get your API key at pmxt.dev/dashboard. For reads, only pmxtApiKey and walletAddress are required.

import { Polymarket } from "pmxtjs";

// Reads — pmxtApiKey + walletAddress only
const client = new Polymarket({
  pmxtApiKey: "pmxt_live_...",
  walletAddress: "0xYourWalletAddress",
});

// Search for markets
const markets = await client.fetchMarkets({ query: "Trump" });
console.log(markets[0].title);

// Get outcome details
const outcome = markets[0].outcomes[0];
console.log(`${outcome.label}: ${(outcome.price * 100).toFixed(1)}%`);

// Fetch historical data (use outcome.outcomeId!)
const candles = await client.fetchOHLCV(outcome.outcomeId, {
    resolution: '1d',
    limit: 30,
});

// Get current order book
const orderBook = await client.fetchOrderBook(outcome.outcomeId);
const spread = orderBook.asks[0].price - orderBook.bids[0].price;
console.log(`Spread: ${(spread * 100).toFixed(2)}%`);

// Account reads
const positions = await client.fetchPositions();
const balance = await client.fetchBalance();

How it works (hosted)

When you pass pmxtApiKey, the SDK talks to PMXT's hosted services: catalog requests go to api.pmxt.dev, trading requests go to trade.pmxt.dev. The SDK does not spawn a local process. For Polymarket and Opinion, PMXT's PreFundedEscrow handles custody — you sign orders with your own key, PMXT settles on-chain.

How it works (self-hosted)

Omit pmxtApiKey to use the local sidecar. Install pmxt-core from npm and supply venue credentials directly. See Self-hosted trading (advanced) below.

Core Methods

Market Data

  • fetchMarkets(params?) - Get active markets

    // Fetch recent markets
    await poly.fetchMarkets({ limit: 20, sort: 'volume' });
    
    // Search by text
    await poly.fetchMarkets({ query: 'Fed rates', limit: 10 });
    
    // Fetch by slug/ticker
    await poly.fetchMarkets({ slug: 'who-will-trump-nominate-as-fed-chair' });
  • fetchEvents(params?) - Get events (groups of related markets)

    await poly.fetchEvents({ query: 'Fed Chair', limit: 5 });
  • filterMarkets(markets, query) - Filter markets by keyword

    const events = await poly.fetchEvents({ query: 'Fed Chair' });
    const warsh = poly.filterMarkets(events[0].markets, 'Kevin Warsh')[0];

Deep-Dive Methods

  • fetchOHLCV(outcomeId, params) - Get historical price candles
  • fetchOrderBook(outcomeId) - Get current bids/asks
  • fetchTrades(outcomeId, params) - Get trade history

Helper Methods

  • getExecutionPrice(orderBook, side, amount) - Calculate volume-weighted average price
  • getExecutionPriceDetailed(orderBook, side, amount) - Get detailed execution info

Trading

Hosted trading (recommended)

With a PMXT API key, pass pmxtApiKey, walletAddress, and privateKey. The SDK auto-wraps your key into an EthersSigner and PMXT settles the order on-chain.

Polymarket:

import { Polymarket } from "pmxtjs";

const trader = new Polymarket({
  pmxtApiKey: "pmxt_live_...",
  walletAddress: "0xYourWalletAddress",
  privateKey: "0xYourPrivateKey",
});

const balance = await trader.fetchBalance();
console.log(`Available: $${balance[0].available}`);

const order = await trader.createOrder({
  marketId: "market-uuid",
  outcomeId: "outcome-uuid",
  side: "buy",
  type: "market",
  amount: 5.0,
  denom: "usdc",
  slippage_pct: 30.0,
} as any);
console.log(`Order status: ${order.status}`);

Opinion:

import { Opinion } from "pmxtjs";

const trader = new Opinion({
  pmxtApiKey: "pmxt_live_...",
  walletAddress: "0xYourWalletAddress",
  privateKey: "0xYourPrivateKey",
});

See the full hosted trading guide for venue support, custody model, and limits.

Self-hosted trading (advanced)

When self-hosting, supply venue credentials directly — no pmxtApiKey. The SDK spawns a local sidecar process.

Polymarket:

const poly = new pmxt.Polymarket({
    privateKey: process.env.POLYMARKET_PRIVATE_KEY,
    proxyAddress: process.env.POLYMARKET_PROXY_ADDRESS, // Optional
    // signatureType: 'gnosis-safe' (default)
});

Kalshi:

const kalshi = new pmxt.Kalshi({
    apiKey: process.env.KALSHI_API_KEY,
    privateKey: process.env.KALSHI_PRIVATE_KEY
});

Limitless:

const limitless = new pmxt.Limitless({
    privateKey: process.env.LIMITLESS_PRIVATE_KEY
});

Trading Methods

  • createOrder(params) - Place a new order

    // Using outcome shorthand (recommended)
    await poly.createOrder({
        outcome: market.yes,
        side: 'buy',
        type: 'limit',
        amount: 10,
        price: 0.55
    });
  • cancelOrder(orderId) - Cancel an open order

  • fetchOrder(orderId) - Get order details

  • fetchOpenOrders(marketId?) - Get all open orders

Account Methods

  • fetchBalance() - Get account balance
  • fetchPositions() - Get current positions

Documentation

For complete API documentation and examples, see:

Important Notes

  • Use outcome.outcomeId, not market.marketId for deep-dive methods (fetchOHLCV, fetchOrderBook, fetchTrades)
  • Prices are 0.0 to 1.0 (multiply by 100 for percentages)
  • Timestamps are Unix milliseconds
  • Volumes are in USD

License

MIT