Liking cljdoc? Tell your friends :D

copytop: Clojure client for copy.top

copy.top tracks what top traders buy and sell on fomo, pumpfun and Hyperliquid, and lets people copy them. This library is the official Clojure client for the copy.top API: the trader leaderboard, a trader's profile, the coins top traders are buying now, money flow, live trades, alerts and Hyperliquid markets, as plain Clojure maps.

  • Read-only: nothing here places an order.
  • No key needed. java.net.http.HttpClient (JDK 11 or later), only dependency org.clojure/data.json.
  • All 16 routes of https://copy.top/v1, typed errors (ex-info with a :type), retries that honour Retry-After.

Site: https://copy.top | Docs for developers and AI agents: https://copy.top/agents | OpenAPI: https://copy.top/v1/openapi.json

Install (coming soon)

Not yet available: net.clojars.copytop/copytop is not published on Clojars yet, so the lines below do not work today. They will once the library is out.

deps.edn:

net.clojars.copytop/copytop {:mvn/version "0.1.0"}

Leiningen: [net.clojars.copytop/copytop "0.1.0"] (same: not yet available).

Examples

1. Coins top traders are buying right now

(require '[copytop.core :as ct])

(def c (ct/client))

(doseq [coin (:coins (ct/hot-coins c {:window "1h" :limit 5}))]
  (println (:symbol coin) (:topTraders coin) "top traders," (:boughtUsd coin) "usd bought"
           (ct/coin-url (:chain coin) (:token coin))))

2. The 7 day leaderboard of pumpfun traders, clean fair play only

(doseq [t (:traders (ct/traders c {:window "7d" :platform "pumpfun" :fair-play "clean" :limit 10}))]
  (println (:handle t) (:pnl t) (:roi t) (:url t)))

3. Look up a trader or a coin by name, $ticker or address

(let [found (ct/search c "$BONK")
      profile (ct/trader c (-> found :traders first :handle))]
  [(get-in profile [:trader :pnl]) (take 3 (:open_positions profile))])

4. An alert bot (several top traders on one coin, or a big trade)

(doseq [event (ct/watch-alerts c {:kinds ["confluence" "big_trade"] :min-top-traders 3})]
  (println (:kind event) (:symbol event) (:url event)))

watch-alerts returns a lazy, endless sequence: it polls once a minute, passes the cursor of each answer back as :since, gives the new events oldest first, and keeps going through 429 and 5xx answers (:on-error sees them). Take what you need (take, take-while) or doseq forever. :on-cursor gives you the cursor to save and pass back as :since after a restart. A complete bot is in examples/alerts.clj.

5. Hyperliquid: top perps traders and markets

(def whales (:traders (ct/hl-traders c {:window "30d" :sort "pnl" :limit 5})))
(def stocks (:markets (ct/hl-markets c {:category "stocks" :limit 10})))
(def btc (ct/hl-market c "BTC"))   ; technicals, funding, open interest, what top traders hold

Functions

Every function takes the client first and returns the decoded JSON answer as a map with keyword keys. The options map is optional; a nil option is left to the server default. Option values can be strings, keywords (:window :7d), numbers or collections (:kinds ["confluence" "thesis"]).

functionroutewhat it returns
(traders c {:window :sort :chain :platform :fair-play :limit})GET /traderstrader leaderboard (fomo and pumpfun), like copy.top/traders
(trader c handle)GET /traders/{handle}one trader: pnl 30d, roi, win rate, fair play, positions, latest trades
(search c query)GET /searchtraders and coins by name, @handle, $ticker or address
(hot-coins c {:window :max-mcap-usd :limit})GET /coins/hotcoins tracked traders are buying now
(hot-index c {:window :chain :limit})GET /coins/indexcoins ranked 0 to 100 by attention
(money-flow c {:side :window :limit})GET /coins/flowcoins ranked by dollars bought or sold
(dex-paid c {:limit})GET /coins/dex-paidcoins whose team paid for a dexscreener profile in the last 24 h
(coin c chain address)GET /coins/{chain}/{address}one coin: price, market cap, which tracked traders hold or sold it
(trades c {:since :side :min-usd :limit})GET /tradesthe live tape of buys and sells, with a cursor
(alerts c {:since :min-top-traders :min-trade-usd :max-mcap-usd :kinds :limit})GET /alertsconfluence, big trade and thesis events since a cursor
(watch-alerts c {:interval :since :on-cursor :on-error ...filters})GET /alerts in a looplazy sequence of new events, cursor handled for you
(theses c {:sort :hours :limit})GET /thesestheses posted by tracked traders
(hl-traders c {:window :sort :limit})GET /hyperliquid/tradersHyperliquid traders ranked by pnl or roi
(hl-trader c address)GET /hyperliquid/traders/{address}one Hyperliquid trader: metrics, positions, fills
(hl-markets c {:category :limit})GET /hyperliquid/marketslive Hyperliquid markets (crypto, stocks, indices, fx)
(hl-market c coin)GET /hyperliquid/markets/{coin}copy.top's read of one Hyperliquid market
(hl-calls c coin)GET /hyperliquid/markets/{coin}/callsanalyst calls on one Hyperliquid market and their track record
(api-get c path params)any routefor routes or parameters this library does not model yet

Page links: (ct/trader-url handle), (ct/coin-url chain address), (ct/hl-trader-url address) and (ct/hl-market-url coin) give the matching page on copy.top.

Chains: solana, base, bnb, eth, robinhood, arc. A handle starting with pf_ is a pumpfun account; the others are fomo traders.

Options, limits, API key and errors

(def c (ct/client {:api-key "..."     ; optional; default: the COPYTOP_API_KEY environment variable
                   :timeout 45         ; seconds; some routes take up to 30 s on a cold cache
                   :max-retries 3
                   :backoff 1.0        ; seconds, doubled on each retry
                   :key-fn keyword}))  ; identity keeps JSON keys as strings

The API is open without a key, at about 20 calls a minute per IP (about 6 a minute for search, trader and coin). A free key from https://copy.top/account#api raises the limits. It is sent as Authorization: Bearer <key>, and printing the client never shows it.

Answers 429 and 5xx, and network errors, are retried with exponential backoff, honouring Retry-After. Then every error is an ex-info whose ex-data has a :type:

:typewhen
:copytop/not-found404: no such trader, coin or market
:copytop/rate-limit429 after all retries (:retry-after in seconds)
:copytop/auth401 or 403: the API key was refused
:copytop/bad-request400: a parameter was refused
:copytop/server5xx after all retries
:copytop/apianother HTTP status
:copytop/networkthe API could not be reached
:copytop/decodethe answer was not a JSON object

The answered errors also carry :status, :api-message and :url. (ct/error-type e) gives the :type, (ct/temporary? e) is true for 429, 5xx and network errors. An empty handle, address or query throws IllegalArgumentException before any call.

(try
  (ct/trader c "nobody_here")
  (catch clojure.lang.ExceptionInfo e
    (case (ct/error-type e)
      :copytop/not-found nil
      (throw e))))

:transport takes any function of {:url :headers :timeout} returning {:status :headers :body}, to plug in another HTTP library or a cache. The default is (copytop.transport/http-transport), which never follows redirects.

Tests

clojure -X:test                  # offline, against a fake transport
COPYTOP_LIVE=1 clojure -X:live   # one call per route on https://copy.top/v1, 4 s apart

Also from copy.top

About

copy.top is independent and is not affiliated with fomo, pump.fun or Hyperliquid. Figures are data, not advice. Trading crypto is risky and past performance does not predict results.

Contact: ana@copy.top. License: MIT.

Can you improve this documentation?Edit on Bitbucket

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close