Skip to content

coinbase-samples/exchange-scripts-py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Exchange API Scripts

This repository provides Python examples of the Coinbase Exchange Public APIs. Currently, only FIX is supported; however, REST will be added during Summer 2023.

Getting started

1. Gaining access

Clone the repository with the following command:

git clone https://github.com/coinbase-samples/exchange-scripts-py

2. Configuration

Depending on if you are accessing REST or FIX, dependencies will differ. Within each folder, you will find a requirements.txt file, from which you will be able to install dependencies with the following command:

pip install -r requirements.txt

Additionally, these scripts make use of environment variables where applicable. Please note that only the first three values noted below are needed for REST APIs. The remainder are requirements for FIX.

To fill these values, you will need to generate an API key with trading and reading functionality and also retrieve your portfolio ID, which is provided in the response of Get Products. Finally, your SVC_ACCOUNTID is identical to your ACCESS_KEY. Populate the below and run the following to declare these variables:

export ACCESS_KEY=ACCESSKEYHERE
export PASSPHRASE=PASSPHRASEHERE
export SIGNING_KEY=SIGNING_KEYHERE
export PORTFOLIO_ID=PORTFOLIO_IDHERE
export SVC_ACCOUNTID=SVC_ACCOUNTIDHERE
export FIX_VERSION=FIX.4.2
export TARGET_COMP_ID=COIN

3. Running scripts

A detailed README.md is provided inside the fix repository. For REST, scripts are entirely standalone and do not require any main application to access. You can run them simply by running a command like the following:

python script_name_here.py