/prime-explorer-js

Coinbase Prime REST API sample application

Primary LanguageSvelteApache License 2.0Apache-2.0


Prime Explorer

This application provides sample code that showcases the Coinbase Prime APIs. The example UI interacts with both the REST and WebSocket endpoints.

The application was built using Svelte, Carbon Design System, and TailWind CSS.

Requires Node.js 16.x+

Clone the repo

git clone git@github.com:coinbase-samples/prime-explorer-js.git

Getting started

Init via npm:

cd prime-explorer-js
npm install

Access credentials

Navigate to the Prime Settings page and pull the API credentials:

https://prime.coinbase.com/portfolio/{your_portfolio_id}/settings/address-book

Optionally, access Exchange credentials (sandbox or prod):

https://public.sandbox.exchange.coinbase.com/profile/api

Set environment variables

Add the following environment variables to a .env file in base of the repository:

PROD_SVC_ACCOUNTID=YOUR_SENDER_COMP_ID
PROD_ACCESS_KEY=YOUR_ACCESS_KEY
PROD_PORTFOLIO_ID=YOUR_PORTFOLIO_ID
PROD_PASSPHRASE=YOUR_PASSPHRASE
PROD_SIGNING_KEY=YOUR_SIGNING_KEY
PROD_URL=wss://ws-feed.prime.coinbase.com
PROD_API_HOST=https://api.prime.coinbase.com
PORT=YOUR_PORT
HTTP_HOST=http://localhost
ENTITY_ID=YOUR_ENTITY_ID

Validate the values contained in the .env file:

 source .env
 echo $PROD_SVC_ACCOUNTID

Optional

To test a partial list of the Coinbase Exchange endpoints, add the following to the .env file:

EXCHANGE_PROD_ACCESS_KEY=YOUR_ACCESS_KEY
EXCHANGE_PROD_PASSPHRASE=YOUR_PASSPHRASE
EXCHANGE_PROD_SIGNING_KEY=YOUR_SIGNING_KEY

Run the application

npm run dev

Navigate to localhost:{{yourPort}}. You should see the app running.

Generate a build

npm run build