Coinbase Logo

Language and region

Introducing a command-line interface for testing the Coinbase International Exchange API

TL;DR: The INTX CLI is a command-line interface that allows developers to test the Coinbase INTX REST API without writing code. It provides a simple solution for testing various operations like placing orders and retrieving transaction details. This CLI simplifies the development workflow and speeds up integration.

By Jeff Curry

Engineering

, March 29, 2024

Coinbase Blog

Coinbase International Exchange (INTX) is rapidly growing in popularity and usage.

Tailored for those interested in perpetual futures, most traders leverage the INTX FIX API to power trading. However, Coinbase International Exchange's REST APIs have been built out to support a plethora of additional use cases, including balance and funding rate retrieval, transfers and portfolio management, and returning the most up to date instrument information.

The launch of the INTX CLI, powered by the Coinbase INTX SDK, provides a significant increase in REST API testing efficiency. This benchmark application is critical for developers as it provides an easy method to test each REST endpoint available - thus speeding up and improving the development workflow.

This blog post explores the capabilities and design of the INTX CLI, presenting an extensive tutorial on how to begin testing endpoints directly from your command line. The aim is to simplify your development workflow, enabling more attention to be spent on innovative application development with reduced complexity.

Functionality

The INTX CLI is designed to offer a no-code solution for testing the Coinbase INTX API. This approach allows users to perform various operations like placing orders, retrieving transaction details, and executing withdrawals without writing any code. 

For instance, to create a new market order, the following command can be used:

intxctl create-order -i
ETH
-USD -t MARKET -s BUY -b 0.1

Similarly, listing account activities is as straightforward as:

intxctl list-activities

Each request within the CLI provides detailed information about the available flags, denoting the required and optional parameters for each endpoint, such as the List Wallets request. By using the -h flag, users can access a comprehensive list of flags:

Flags:

  -t, --type string             Type of balance (Required)  
  -c, --cursor string           Pagination cursor
  -h, --help                    help for list-wallets
  -l, --limit string            Pagination limit
  -d, --sort-direction string   Sort direction
  -s, --symbols strings         List of symbols

This level of user-friendliness significantly streamlines the testing process, allowing developers to quickly understand and interact with various endpoints.

High-level Architecture

Regarding architecture, the application maintains a straightforward design. Each script encapsulates the logic necessary for interacting with a specific endpoint. For example, in get_portfolio_balances.go, two key functions are defined:

  1. getPortfolioBalancesCmd: This function creates a command (get-portfolio-balances) and constructs a structure with the relevant portfolio IDs. It then sends a request to the INTX SDK’s GetPortfolioBalances function and outputs the response.

  2. The init function initializes this command and defines the necessary flags for the endpoint. In the case of portfolio balances, Portfolio ID is the sole required flag. Notably, Portfolio ID can alternatively be set as an environment variable, eliminating the need to pass it with each request. Users have the option to customize shorthand letters for commands, but this requires rebuilding the project afterwards. 

Running it yourself

From your terminal, navigate to a directory where you wish to store this application. Run the following commands to clone the repository and change directories to it:

cd intx-cli

Next, in order to use the Coinbase INTX API, you will need to pass through your INTX credentials. While this logic is handled for you with each request made by the INTX CLI, you will still need to specify your credentials at the start of the application. Coinbase INTX API credentials can be created in the INTX web console under APIs. 

INTX_CREDENTIALS should match the following format, and the following command should be submitted from the terminal window in which you plan to run the INTX CLI:

export INTX_CREDENTIALS='{
"accessKey":"ACCESSKEY_HERE",
"passphrase":"PASSPHRASE_HERE",
"signingKey":"SIGNINGKEY_HERE",
"portfolioId":"PORTFOLIOID_HERE",
}'

To build the application binary, simply run:

make

This command compiles the application and creates a binary named intxctl in the current directory.

To ensure your project's dependencies are up-to-date, run:

go mod tidy

To install intxctl to /usr/local/bin for easy access from any location, run:

make install

This command moves the intxctl binary to /usr/local/bin/ and sets the appropriate permissions. You also may need sudo access to move the file to /usr/local/bin/.

To verify that intxctl is correctly installed and accessible from any location, you can run:

intxctl

This command should display all available requests if the installation was successful.

Finally, to run commands for each endpoint, use the following format to test each endpoint. Please note that many endpoints require flags, which are detailed with the --help flag. Next try this command to list all portfolios:

intxctl list-portfolios

The INTX CLI is a valuable tool for developers working with the Coinbase INTX API. By providing a simple and efficient way to test REST endpoints, it speeds up the development process and improves integration. With its no-code approach, developers can perform various operations without writing code, making it beginner-friendly. The architecture of the application is straightforward, and running the INTX CLI is easy by following the provided steps. Incorporating the INTX CLI into your development workflow will simplify testing and allow more focus on innovative application development.

- - 

Disclaimer: this application should never be used in any production environment, and any real funds used in this application may be lost. Additionally, this information is provided for informational purposes only and is not investment advice. This is not a recommendation to buy or sell digital assets or to employ a particular investment strategy, codes, or APIs. Coinbase makes no representation on the accuracy, suitability, or validity of any information provided herein.

This material is for informational purposes only and is not (i) an offer, or solicitation of an offer, to invest in, or to buy or sell, any interests or shares, or to participate in any investment or trading strategy, or (ii) intended to provide accounting, legal, or tax advice, or investment recommendations. No representation or warranty is made, expressed or implied, with respect to the accuracy or completeness of the information or to the future performance of any digital asset, financial instrument or other market or economic measure. The information is believed to be current as of the date indicated and may not be updated or otherwise revised to reflect information that subsequently became available or a change in circumstances after the date of publication. Investing in cryptocurrency comes with risk. Prior results do not guarantee future performance. Readers should consult their advisors before making any investment decision. Any references to third parties do not imply Coinbase's endorsement, or approval of any third-party websites or their content. This material is the property of Coinbase, Inc. Any use, review, retransmission, distribution, or reproduction of these materials, in whole or in part, is strictly prohibited in any form without the express written approval of Coinbase. Coinbase, Inc. is licensed to engage in virtual currency business activity by the New York State Department of Financial Services. © 2024 Coinbase, Inc. All Rights Reserved. COINBASE, the C Logo, and the Wallet Logo are all trademarks of Coinbase, Inc.

Coinbase logo
Jeff Curry

About Jeff Curry

Senior Solutions Architect, STP