REST API

To interact with the REST API, it is required to set the header Content-Type: application/json and send a JSON payload containing values for the fields specified below, or if no inputs are described, an empty object can be supplied.

/address

Retrieves the pint1 address associated with the daemon's connection to pintp2p.

pintswap-cli address

/ethereum-address

Retrieves the Ethereum wallet address associated with the daemon which is used to sign spends involved in trades.

pintswap-cli ethereum-address

/peer

Retrieves the orderbook hosted by a remote peer on the PintSwap network, as well as any other details hosted by the peer, including the bio

Inputs:

{
  "peer": "QmQ8e4HF8Vxw4Ep7mdQjvphZJwDhjLUAoXqmEzftZnyAK2"
}

A .drip name can be used in place of a pint address, if one is registered

{
  "peer": "wock.drip"
}
pintswap-cli peer --peer wock.drip

#{
#  "offers": [
#    {
#      "gets": {
#        "amount": "0x0e22fac675c8c8",
#        "token": "0x0000000000000000000000000000000000000000"
#      },
#      "gives": {
#        "amount": "0x6eca1d",
#        "token": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
#      },
#      "id": "0xb0bbfbf1d64037a456f3e1f01f1149017bec1618d506dfa6a42d217205269cc9"
#    },

# List will continue for all offers

# "bio": "fwm I always got it"

/peer-image

Pipes binary data to stdout containing the PNG image content for a PeerId profile picture. Should be redirected to a file. Inputs can be a pint address or a .drip name.

Inputs:

{
  "peer": "wock.drip"
}
pintswap-cli peer-image --peer wock.drip > ~/wock.png

/add

Adds a limit order to the local orderbook. If the order exists on the daemon, it can be taken by anyone who dials the peer with the /trade function, whether or not the node is actively publishing. It only requires the pint address of the daemon to trade against it, or otherwise the .drip name registered, if there is one.

Inputs:

{
  "getsToken": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
  "getsAmount": "0x102f40a4",
  "givesToken": "0x8d008CAC1a5CB08aC962b1e34E977B79ABEee88D",
  "givesAmount": "0x14c7ec8e56a7fc000000"
}
pintswap-cli add --gets-token 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 --gets-amount 0x102f40a4 --gives-token 0x8d008CAC1a5CB08aC962b1e34E977B79ABEee88D --gives-amount 0x14c7ec8e56a7fc000000

#0xcfb8673b6c96f217aa47ea68cc1c5a3ff77c728f1b775f59e3e9ed23b49d34cf

/limit

Alternative syntax for the functionality in /add, which will adjust for a decimals() value automatically, so a floating point value can be used with the RPC for a price and amount.

Inputs:

{
  "price": "0.00267",
  "amount": "100",
  "type": "sell",
  "pair": "0x8d008CAC1a5CB08aC962b1e34E977B79ABEee88D/USDC"
}
pintswap-cli limit --price 0.00267 --amount 100 --type sell --pair 0x8d008CAC1a5CB08aC962b1e34E977B79ABEee88D/USDC

/offers

Retrives the local orders hosted on the daemon process which will be published if /publish is invoked.

pintswap-cli offers

#[
#  {
#    "gives": {
#     "token": "0x8d008CAC1a5CB08aC962b1e34E977B79ABEee88D",
#      "amount": "0x14c7ec8e56a7fc000000"
#    },
#    "gets": {
#      "token": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
#      "amount": "0x102f40a4"
#    },
#    "id": "0xcfb8673b6c96f217aa47ea68cc1c5a3ff77c728f1b775f59e3e9ed23b49d34cf"
#  }
#]

/delete

Deletes an order from the local orderbook hosted on the daemon process.

{
   "id": "<orderhash>"
}
pintswap-cli delete --id 0xcd9305ed3975e3c0ad35f9169e75d386c63a21f4fa21433b2a97332336b39ad4

#true if deleted
#false if not

/clear

Deletes the entire local orderbook hosted on the daemon process.

pintswap-cli clear
#0

/publish

Begins publishing the orderbook local to the daemon. This must be called after the daemon initializes or your orders will not be visible on the public orderbook.

Example:

pintswap-cli publish
#OK

/subscribe

Begins listening fo orderbook publishes on the PintSwap network. Orders will accumulate and can thereafter be queried with the /orderbook route. If this API endpoint is not called after the daemon initializes the /orderbook route will respond with an empty list.

pintswap-cli subscribe
#OK

/unsubscribe

Stops listening for orderbook publishes on the PintSwap network.

pintswap-cli unsubscribe
#OK

/orderbook

Returns a view of the complete orderbook and associated PeerId for each offering.

pintswap-cli orderbook

#[
#  "pint1zgsp4ga24uswa954kf03w3jhw5ad5qq5kgt90ykn560aktkussv9h2gyc5cjp",
#  [
#    {
#      "gets": {
#        "amount": "0x0429d069189e0000",
#        "token": "0x0000000000000000000000000000000000000000"
#      },
#      "gives": {
#        "tokenId": "0x01",
#        "token": "0x0B2403086af285de8E1B897E7404E3d5CBb1Bb10"
#      },
#      "id": "0xd26e819196d5a0aff1ab71f86ec349fdae5d7ba2f563d4672292ee3d79ca6650"
#    },
# All orders and PeerId's will be listed

/trade

Attempts to negotiate a trade aggregating the complete set of orderid/amount pairs supplied, with the targeted peer. Supports the broadcast: true property which, if set, will attempt to execute the trade transactions as a bundle using the flashbots relay API.

A /trade invocation can only execute if the base asset / trade asset pair are consistent throughout the list of orders to take, and they all must be offered by the same peer. This is true for any trade execution on the PintSwap protocol, whether it is by the daemon or the webapp that is being called to perform the trade.

Inputs:

{
  "peer": "wock.drip",
  "trades": [{
    "offerHash": "0x44bdebb961a61ed9413fc1d950dad4cf9bf6410e4a95dbff7c2459bcc065ef6b",
    "amount": "0x20f5612972944a000000"
  }, {
    "offerHash": "0xcd9305ed3975e3c0ad35f9169e75d386c63a21f4fa21433b2a97332336b39ad4",
    "amount": "0x14c7ec8e56a7fc000000"
  }],
  "broadcast": true
}
pintswap-cli trade --peer wock.drip --trades 0x44bdebb961a61ed9413fc1d950dad4cf9bf6410e4a95dbff7c2459bcc065ef6b,0x20f5612972944a000000,0xcd9305ed3975e3c0ad35f9169e75d386c63a21f4fa21433b2a97332336b39ad4,0x14c7ec8e56a7fc000000 --broadcast

/register

Registers a name on the .drip nameserver peers. Can only be unregistered with the PeerId used to register. Further work is planned to improve name resolution access control and mutability. For now, ensure you do not lose your PeerId if you intend to keep your .drip name.

Inputs:

{
  "name": "wock.drip"
}
pintswap-cli register --name wock.drip
#0

/resolve

Resolves a .drip name to a pint address. Can also be used to do reverse lookups

Inputs:

{
  "name": "wock.drip"
}
pintswap-cli resolve --name wock.drip
#pint1zgsw52stcg9kgy4y6qvl3rpu0dzwzdcy9m3yy4mdnfm22c5ht90jh8qtvlwzh

/set-bio

Sets the bio associated with your daemon process, as visible on the webapp.

Inputs:

{
  "bio": "fwm I always got it"
}
pintswap-cli set-bio --bio 'fwm I always got it'
#OK

/set-image

Sets the profile picture associated with your daemon process, as visible on the webapp.

Inputs:

{
  "image": "<base64 encoded PNG>"
}
pintswap-cli set-image --image ./wock.png

ws://localhost:42161

Open a WebSocket connection to ws://: as specified by the environment to begin receiving logs in the form

{
  "type": "log",
  "message": {
    "logLevel": "info"
    "timestamp": 1691183404902,
    "data": "initiating trade",
  }
}
pintswap-cli attach

Last updated