Go to file
Nathaniel Parke 82f05636da Add documentation 2020-11-13 16:18:36 +08:00
bin Initial commit 2020-10-20 17:21:05 +08:00
src Add documentation 2020-11-13 16:18:36 +08:00
.env.development Add documentation 2020-11-13 16:18:36 +08:00
.eslintignore Initial commit 2020-10-20 17:21:05 +08:00
.eslintrc.json Initial commit 2020-10-20 17:21:05 +08:00
.gitignore Add api server (#1) 2020-11-11 17:43:43 +08:00
.prettierignore Add routes (#2) 2020-11-12 11:44:18 +08:00
LICENSE Create LICENSE (#4) 2020-11-12 15:02:30 +08:00
README.md Add documentation 2020-11-13 16:18:36 +08:00
package.json Initial commit 2020-10-20 17:21:05 +08:00
shell Add api server (#1) 2020-11-11 17:43:43 +08:00
tsconfig.json Initial commit 2020-10-20 17:21:05 +08:00
yarn.lock Wrap api responses and update serum-js (#3) 2020-11-12 14:15:13 +08:00

README.md

serum-rest-server

Install

This server uses yarn to manage node.js dependencies. To install dependencies, from the root directory run

yarn

to build the workspace run

yarn build

to start the server in debug mode

DEBUG=js:* yarn start

Configuration

Server configurations are managed with dotenv. A default configuration is provided in .env.development. The server looks for solana private keys in the file specified by the SECRETS_FILE config. Without any further configuration to permission the server, create a file with following format, replacing "your_bs58_private_key" with your base58 encoded solana private key (which you can export from sollet.io).

{
  "serum_private_key": "your_bs58_private_key"
}

Then store this file at a location of your choosing and set the SECRETS_FILE config to your chosen location. Note that dotenv by default looks for .env files, so you will need to rename .env.development to .env for the configurtation file to take effect.

Shell

A node.js shell is provided for debugging purposes. Start the shell with

yarn shell

An example of fetching an orderbook for the BTC/USDC pair is provided below.

[~/serum-rest-server]$ yarn shell
> sapi = await SerumApi.create()
...
> await sapi.getWsOrderbook('BTC', 'USDC')
{
  bids: [...],
  asks: [...],
  market: Pair { coin: 'BTC', priceCurrency: 'USDC' },
  validAt: ...,
  receivedAt: ...
}