Coinbase Pro REST API

From sgcWebSockets 4.4.8, Coinbase Pro REST API is fully supported. The REST API allows to access to public Market Data and Private Accounts, place new orders... sgcWebSockets library supports the following endpoints

Authentication, Accounts, Orders,  Fills, Limits, Deposits, Withdrawals, Stablecoin Conversions, Payment Methods, Coinbase Accounts, Fees, Reports, Profiles, Margin, Oracle


Coinbase Pro Public REST API 

Coinbase Pro offers public Market Data through REST Endpoints, when you call one of these endpoints, you will get an snapshot of the market data requested.

The Market Data Endpoints doesn't require authentication, so are freely available to all users.

Example: to get an snapshot of the ticker BTC-USD, do the following call

oCoinbase := TsgcWSAPI_Coinbase.Create(nil);
ShowMessage(oCoinbase.REST_API.GetProductTicker('BTC-USD')); 

Coinbase Pro Private REST API 

The Coinbase Pro REST API offer public and private endpoints. The Private endpoints requires that messages signed to increase the security of transactions.

First you must login to your Coinbase Pro account and create a new API, you will get the following values:

  • ApiKey
  • ApiSecret
  • Passphrase

These fields must be configured in the Coinbase property of the Coinbase API client component.

Once configured, you can start to do private requests to the Coinbase Pro REST API

oCoinbase := TsgcWSAPI_Coinbase.Create(nil);
oCoinbase.Coinbase.ApiKey := '<your api key>';
oCoinbase.Coinbase.ApiSecret := '<your api secret>';
oCoinbase.Coinbase.ApiPassphrase := '<your passphrase>';
ShowMessage(oCoinbase.REST_API.ListAccounts); 

Coinbase Pro Place Orders 

In order to place new orders in Coinbase Pro, you require first your APIs to access your private data. Once you have configured your API keys, you can start to place orders

Example: Place a new Market Order, buy 0.002 contracts of BTC-USD

oCoinbase := TsgcWSAPI_Coinbase.Create(nil);
oCoinbase.Coinbase.ApiKey := 'your api key';
oCoinbase.Coinbase.ApiSecret := 'your api secret';
oCoinbase.Coinbase.ApiPassphrase := 'your passphrase';
ShowMessage(oCoinbase.REST_API.PlaceMarketOrder(coisBuy, 'BTC-USD', 0.002)); 

Coinbase Pro SandBox Account 

Coinbase Pro allows to use a SandBox account where you can trade without real funds. This account requires to create API keys different from production account.

To use the SandBox account, just set Coinbase.SandBox property to true, before do any request to API.

oCoinbase := TsgcWSAPI_Coinbase.Create(nil);
oCoinbase.Coinbase.ApiKey := 'your api key';
oCoinbase.Coinbase.ApiSecret := 'your api secret';
oCoinbase.Coinbase.ApiPassphrase := 'your passphrase';
oCoinbase.Coinbase.SandBox := True;
ShowMessage(oCoinbase.REST_API.ListAccounts); 

SandBox Trading with Coinbase Pro API 

 In the following video you can see how place new orders using REST API and how you get real-time updates using websocket user channel.

×
Stay Informed

When you subscribe to the blog, we will send you an e-mail when there are new updates on the site so you wouldn't miss them.

OpenSSL Perfect Forward Secrecy
WebSocket Masked Messages

Related Posts