Overview

The Refinery aggregates hashrate from miners and distributes it as fixed-size orders of hashwork, denominated in hashdays. The standard unit is the petahash-day (PHd), currently priced at — sats/PHd. Placing an order means accepting the posted hashprice.

Hashrate
Rate at which a miner computes SHA256d, measured in hashes per second. 1 PH/s = 1015 hashes per second.
Hashwork
Raw accumulated work from accepted shares (1 unit = 232 hashes). Example: 100 shares at pool difficulty 1,000 produce 100,000 units of hashwork, approximately 429 trillion hashes.
Hashdays
Hashwork expressed as hashrate sustained for one day. 1 PHd = 1 PH/s for 1 full day (= 1015 Hd = 20.12 G units of hashwork).
Hashprice
Price of hashwork, in satoshis per petahash-day (sats/PHd). All pricing is variable and subject to change based on, but not limited to, network difficulty, bitcoin price, and market demand.
Hashrate
Duration
Hashwork
Hashdays

Endpoints (beta)

All endpoints are relative to https://parasite.space/api/refinery. This is an experimental API that is still subject to a lot of changes. Please check the /status git_commit field to see which exact fields are returned to be sure.

For conversions, see hashmath.ts, hash.rs, or the calculator.

▶GET/status

Description

Returns the current router status: hashprice, total and used capacity, whether order creation is halted, whether pace routing is enabled, and aggregate upstream/downstream mining stats.

hash_price is the current quote in sats/PHd; hash_value is the base before premium and difficulty_multiplier.

target_hashrate, deficit_hashrate, and surplus_hashrate are aggregate targets/under/over in H/s. starving_order_count counts active unfulfilled orders below target; capacity fields are in Hd.

block_count/recent_blocks are router-recorded blocks, not chain height. wallet.synced and halt control order creation. pace controls routing: when enabled, connections that arrive after every open bucket reaches its target spill to sink orders instead of overfilling buckets. git_commit is the deployed build.

Example

curl -s https://parasite.space/api/refinery/status
{
  "uptime_secs": 166650,
  "block_count": 1,
  "recent_blocks": ["00000000000000000000b3b4ffabf7eed7e613c5fcb50ec85f015e424b0bcf6d"],
  "hash_price": 47051,
  "hash_value": 44810,
  "difficulty_multiplier": 1,
  "total_capacity_hash_days": 1000000000000000000,
  "used_capacity_hash_days": 18156355635669600,
  "halt": false,
  "pace": false,
  "wallet": { "synced": true },
  "target_hashrate": 300000000000000,
  "deficit_hashrate": 242660823167963.25,
  "surplus_hashrate": 2409028380977510,
  "starving_order_count": 1,
  "upstream": {
    "users": 4,
    "workers": 4,
    "orders": 5,
    "pending": 0,
    "disconnected": 0,
    "disconnects_1h": 5,
    "hashrate_1m": 23903891512998370,
    "hashrate_5m": 22351127069392070,
    "hashrate_15m": 21017789416449050,
    "hashrate_1hr": 13615135960832540,
    "hashrate_6hr": 11293861977378782,
    "hashrate_1d": 25477950174276900,
    "hashrate_7d": 34998599365939650,
    "sps_1m": 0.8659437857645059,
    "sps_5m": 0.787279530746437,
    "sps_15m": 0.7781535618482415,
    "sps_1hr": 0.5789747379903702,
    "accepted_shares": 11137,
    "rejected_shares": 0,
    "accepted_work": 44077108716.264595,
    "rejected_work": 0,
    "best_share": 70156720686,
    "last_share": 1793198908,
    "totals": {
      "users": 684,
      "orders": 3908,
      "accepted_shares": 21714524,
      "rejected_shares": 3261,
      "accepted_work": 201020604306333.72,
      "rejected_work": 38980956870.4914,
      "delivered_hash_days": 9994726195055389000,
      "best_share": 400975189086445,
      "last_share": 1793198908
    }
  },
  "downstream": {
    "users": 1,
    "workers": 4,
    "sessions": 20,
    "idle": 0,
    "disconnected": 16,
    "connects_1h": { "total": 9767, "sessions": 156, "probes": 9611, "rejects": 0, "pending": 0 },
    "disconnects_1h": { "total": 9750, "client": 9702, "server": 3, "trim": 45, "rejects": 0 },
    "hashrate_1m": 20322723193479148,
    "hashrate_5m": 15472835568427222,
    "hashrate_15m": 8388059207169918,
    "hashrate_1hr": 2635720504297727,
    "hashrate_6hr": 470638597216694.06,
    "hashrate_1d": 118908319749193.73,
    "hashrate_7d": 17038394625728.324,
    "sps_1m": 7.247110208588404,
    "sps_5m": 5.098069196267634,
    "sps_15m": 2.561778494216036,
    "sps_1hr": 0.7684923549907909,
    "accepted_shares": 2952,
    "rejected_shares": 1,
    "accepted_work": 2400489826.813699,
    "rejected_work": 1000000.7735922161,
    "best_share": 70156720686,
    "last_share": 1793198908,
    "totals": {
      "users": 2,
      "workers": 2514,
      "accepted_shares": 485200828,
      "rejected_shares": 59914,
      "accepted_work": 200799075962956.75,
      "rejected_work": 21940234604.05207,
      "delivered_hash_days": 9982866862476966000,
      "best_share": 400975189086445,
      "last_share": 1793198908
    }
  },
  "git_commit": "abcdef0123456789abcdef0123456789abcdef01"
}
▶GET/orders

Description

Lists orders, newest first. Returns up to 50 orders by default. Use limit (1–500) and cursor to page through results.

Parameters

NameTypeDescription
statusstringComma-separated filter: pending, in_mempool, active, fulfilled, cancelled, disconnected, expired.
kindstringbucket or sink.
reviewstringReview filter: clean, flagged, or cleared.
addressstringOnly orders paying to, or mining for, this address.
searchstringCase-insensitive match on order id, upstream target, or payment address.
limitintegerPage size, 1–500. Defaults to 50. Use with cursor for keyset pagination.
cursorintegerKeyset cursor from a previous page's X-Next-Cursor header.

requested_hash_days and target_hashrate are null for sink orders. target_hashrate is target H/s, not actual; hashrate is actual 1-minute H/s; delivered_hash_days is Hd.

Pagination

Without limit, the endpoint returns the newest 50 orders. Set limit (1–500) to request a larger page. When more results exist, the response includes an X-Next-Cursor header; send its value back as cursor to fetch the next page. The effective page size is returned in the X-Limit header.

curl -si "https://parasite.space/api/refinery/orders?status=active,in_mempool&kind=bucket&limit=1" | grep -i '^x-'
x-limit: 1
x-next-cursor: 42

Example

curl -s "https://parasite.space/api/refinery/orders?status=active,in_mempool&kind=bucket&limit=1"
[
  {
    "id": 42,
    "status": "active",
    "review": "clean",
    "endpoint": "parasite.wtf:42068",
    "username": "bc1q....worker",
    "requested_hash_days": 10000000000000000,
    "target_hashrate": 10000000000000000,
    "hashrate": 10400000000000000,
    "delivered_hash_days": 3200000000000000,
    "best_share": 123456789
  }
]

Next page: repeat the request with &cursor=42 (from the X-Next-Cursor header).

▶GET/orders/count

Description

Returns the number of orders matching the given filters. Accepts the same filters as /orders, except cursor and limit.

Parameters

NameTypeDescription
statusstringComma-separated filter: pending, in_mempool, active, fulfilled, cancelled, disconnected, expired.
kindstringbucket (orders with a work target) or sink.
reviewstringReview filter: clean, flagged, or cleared.
addressstringOnly orders paying to, or mining for, this address.
searchstringCase-insensitive match on order id, upstream target, or payment address.

Example

curl -s "https://parasite.space/api/refinery/orders/count?status=active&kind=bucket"
{
  "count": 7
}
▶GET/order/{id}

Description

Returns details for an order, including payment information, transaction ids, mining stats, and active worker sessions. The public endpoint redacts upstream and session IP addresses.

target_hashrate is target H/s and null for sink orders. hash_price/payment fields are null for sinks; txids is empty until paid. Public responses redact upstream_address and session remote_address; created_at is Unix seconds, created_at_height is a block height.

Example

curl -s https://parasite.space/api/refinery/order/42
{
  "id": 42,
  "status": "fulfilled",
  "review": "clean",
  "upstream_target": {
    "endpoint": "parasite.wtf:42068",
    "username": "bc1qexample.worker",
    "password": null
  },
  "upstream_address": null,
  "upstream_disconnects_total": 0,
  "requested_hash_days": 299000000000000,
  "target_hashrate": 299000000000000,
  "hash_price": 47096,
  "payment_address": "bc1qexamplepaymentaddress",
  "payment_amount": 14082,
  "txids": ["exampletxid"],
  "created_at": 1761000000,
  "created_at_height": 921800,
  "upstream": {
    "hashrate_1m": 0,
    "hashrate_5m": 0,
    "hashrate_15m": 24511.928608076323,
    "hashrate_1hr": 2511380599112,
    "hashrate_6hr": 248279636325150,
    "hashrate_1d": 198640222735611,
    "hashrate_7d": 40319828280266,
    "sps_1m": 0,
    "sps_5m": 0,
    "sps_15m": 1.3860600113664807e-12,
    "sps_1hr": 0.00016625749661147924,
    "accepted_shares": 3816,
    "rejected_shares": 0,
    "accepted_work": 6025337965,
    "rejected_work": 0,
    "delivered_hash_days": 299521174839564,
    "best_share": 2448827500,
    "last_share": 1793176337
  },
  "downstream": {
    "hashrate_1m": 0,
    "hashrate_5m": 0,
    "hashrate_15m": 0,
    "hashrate_1hr": 0,
    "hashrate_6hr": 0,
    "hashrate_1d": 0,
    "hashrate_7d": 0,
    "sps_1m": 0,
    "sps_5m": 0,
    "sps_15m": 0,
    "sps_1hr": 0,
    "accepted_shares": 0,
    "rejected_shares": 0,
    "accepted_work": 0,
    "rejected_work": 0,
    "delivered_hash_days": 0,
    "best_share": null,
    "last_share": null
  },
  "sessions": []
}
▶POST/order

Description

Creates an order for a fixed amount of work at the current hashprice. Responds 201 with a payment address and amount; the order activates once the payment confirms. Pay exactly payment_amount sats to payment_address; do not rely on an independently calculated total.

Request body (JSON)

NameTypeDescription
upstream_target.endpointstringStratum endpoint, e.g. parasite.wtf:42068.
upstream_target.usernamestringStratum username, typically <address>.<worker>.
upstream_target.passwordstring | nullStratum password, if any.
hash_daysnumberPositive finite amount of work in hashdays (Hd). 1 PHd = 1e15 Hd.
hash_ratenumberOptional target hashrate in H/s. Omit to target the work over 24 hours. This is a best-effort target: actual delivered hashrate can vary, and it does not change the order price.

The public endpoint applies the current hash_price; do not send hash_price in the request body. Payment is based on hash_days, not on the optional target hashrate.

The router allows delivery from 1 hour up to the next difficulty adjustment. Rates that would deliver faster than 1 hour or stretch past that window are rejected.

Common errors

  • 400: invalid hash days or target hash rate, or payment below dust.
  • 422: hashprice below the minimum or insufficient capacity.
  • 429: rate limited.
  • 503: order creation halted or router wallet syncing.
  • 504: order outcome unknown; check your orders before retrying.
  • 502: router unavailable or returned an invalid quote.

Example

curl -s -X POST https://parasite.space/api/refinery/order \
  -H "Content-Type: application/json" \
  -d '{
    "upstream_target": {
      "endpoint": "parasite.wtf:42068",
      "username": "bc1qyouraddress.yourworker",
      "password": null
    },
    "hash_days": 10000000000000000
  }'
{
  "order_id": 43,
  "payment_address": "bc1q...",
  "payment_amount": 470510,
  "hash_price": 47051
}

Examples

How to create an order:

const base = 'https://parasite.space/api/refinery';

// Create an order at the current server-selected quote. This one is real:
// the returned amount must be paid.

// 1 PHd = 1e15 hashdays. This order buys 1.25 PHd.
const hashDays = 1.25 * 1e15;

// Replace the endpoint and username with your own.
const orderResponse = await fetch(`${base}/order`, {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    upstream_target: {
      endpoint: 'parasite.wtf:42068',
      username: 'foo.bar',
      password: null,
    },
    hash_days: hashDays,
    // Optional target hashrate in H/s. Omit for 24-hour delivery.
    // hash_rate: 1.25e15,
  }),
});
if (!orderResponse.ok) throw new Error(await orderResponse.text());

// Pay the returned amount in sats; don't use a locally calculated estimate.
const { order_id, payment_address, payment_amount } = await orderResponse.json();
console.log({ order_id, payment_address, payment_amount });

How to page/filter through orders:

// Page through /orders with filters. Keep the filters identical for every
// page; only the cursor changes. The first request has no cursor. Read
// X-Next-Cursor from each response and send it back as the cursor parameter.
// Stop when it is absent. X-Limit is the effective page size (limit is 1–500,
// default 50). Treat cursors as opaque, and restart if the filters change.
const base = 'https://parasite.space/api/refinery';

const params = new URLSearchParams({
  status: 'active,in_mempool',
  limit: '100',
});

const orders = [];
let cursor = null;
const seenCursors = new Set();

do {
  // Add the next-page cursor; the first request has none.
  if (cursor) params.set('cursor', cursor);
  else params.delete('cursor');

  // Fetch one page with the same filters.
  const response = await fetch(`${base}/orders?${params}`, { cache: 'no-store' });
  if (!response.ok) throw new Error(await response.text());

  orders.push(...(await response.json()));

  // The next cursor is null on the last page.
  const pageSize = response.headers.get('x-limit');
  cursor = response.headers.get('x-next-cursor');
  console.log('page size:', pageSize, 'next cursor:', cursor);

  // Defensive: stop if the server ever repeats a cursor.
  if (cursor && seenCursors.has(cursor)) throw new Error('pagination repeated a cursor');
  if (cursor) seenCursors.add(cursor);
} while (cursor);

console.log('loaded', orders.length, 'orders');