Coinbase Logo

Language and region

Introducing the Coinbase Advanced Trade Go SDK

TL;DR: The Advanced Trade Go SDK is a flexible sample application that allows customers to automate their crypto trading strategies on Coinbase Advanced. This SDK is built on top of Coinbase Advanced REST APIs and simplifies the development process, enabling traders and developers to integrate advanced crypto trading functionalities with ease.

By Jeff Curry

Engineering

, June 6, 2024

unnamed.png

Coinbase Advanced offers traders the building tools needed for a plethora of significant benefits, including low volume-based fees, more in-depth technical analysis, real-time order books, and improved order reporting. The Advanced Trade API complements these functionalities by providing traders and developers with the tools necessary to build custom crypto trading solutions tailored to their specific needs. Even with robust APIs, integrating these capabilities into custom applications can be complex and time-consuming. By popular demand, we launched our first official Python SDK to simplify the integration process for our Python developers.

Today, we are excited to announce the launch of our community-based Advanced Trade Go SDK. This blog post explores the design and usage of the Advanced Trade Go SDK, which is a sample application that aims to simplify this process. The SDK accelerates development by providing a clear framework for using REST APIs, reducing the complexity of building on top of the Advanced Trade API, and enhancing the overall developer experience.

Functionality

The Advanced Trade Go SDK is designed to make writing code on top of the Advanced Trade API significantly easier. This API works across all features and services within Coinbase Advanced, and it provides developers with straightforward methods to perform any specific endpoint request. The SDK supports a wide range of functionalities, including:

  • Market Data Access: Retrieve real-time market data, historical data, and order book details 

  • Order Management: Place, modify, and cancel orders programmatically, allowing for the automation of trading strategies

  • Account Management: Access account information, including balances, order history, and positions

  • Portfolio Management: Manage multiple portfolios, including the ability to create, update, and delete portfolios

  • International Exchange (INTX) support: For retail users onboarded to Coinbase International Exchange, access exclusive instruments with just one integration

The SDK also includes comprehensive error handling, ensuring that developers can quickly diagnose and resolve issues. With well-documented methods and consistent interfaces, the SDK reduces the learning curve for new users and accelerates the development process.

Additionally, the SDK provides well-structured request and response structures for each API endpoint. This built-in structure simplifies the process of making API calls and handling responses, ensuring that developers can focus on building their applications without worrying about the intricacies of request formatting and response parsing.

High-level Architecture

Regarding architecture, the application maintains a straightforward design. Each endpoint in the API is represented by a corresponding method in the SDK. These methods handle the construction of API requests, submission to the server, and processing of responses.

The architecture is divided into several key components:

  1. HTTP communication: Handles interaction with the Advanced Trade API. This includes methods for sending GET, POST, PUT, and DELETE requests, and also manages JWT token authentication and session handling.

  2. Client Initialization: This call handles the creation and configuration of the client used for making API requests. This client setup is essential for establishing a connection with the API

  3. Endpoint Handlers: Each API endpoint has a corresponding handler that integrates the request and response structures. The request struct defines the parameters required for the endpoint, while the response struct encapsulates the data returned by the API

  4. Model: The model includes a collection of typed request and response structures used throughout the SDK. These models represent the various entities involved in trading, such as assets, orders, and accounts. By using these models, developers can work with structured and type-safe interfaces, avoiding the complexities of handling raw data formats directly

  5. Utilities: Helper functions and utilities are provided to perform common tasks, such as handling pagination

The Advanced Trade Go SDK's architecture is designed to be extensible, allowing developers to easily add support for new endpoints, response objects, and features as they become available. By providing a clear and consistent framework, the SDK empowers developers to build sophisticated trading applications with minimal effort.

Running it yourself

To use the Advanced Trade Go SDK, initialize the Credentials struct and create a new client. The Credentials struct is JSON enabled. Ensure that Advanced Trade API credentials are stored in a secure manner.

There are convenience functions to read the credentials as an environment variable (ReadEnvCredentials) and to deserialize the JSON structure (UnmarshalCredentials) if pulled from a different source. The easiest way to initialize the environment variable is by setting it with the following command:

export ADV_CREDENTIALS='{ "accessKey":"", "privatePemKey":"" }'

Coinbase Advanced Trade API credentials can be created in the Coinbase Developer Platform.

Once the client is initialized, make the desired call. For example, to list portfolios, pass in the request object, check for an error, and if nil, process the response.

response, err := client.ListPortfolios(ctx, &adv.ListPortfoliosRequest{})

The Advanced Trade Go SDK is a powerful tool for developers looking to integrate advanced trading functionalities into their applications. By abstracting the complexities of the Advanced Trade API and providing a clear and consistent interface, the SDK simplifies the development process and accelerates time to market. Whether you are building a trading bot, a portfolio management system, or a custom trading platform, the Advanced Trade Go SDK provides the tools and flexibility you need to succeed.

Help us build better for you.

Advanced Trade GO SDK is made possible through the continued partnership and feedback from our developers. Please take a moment to tell us how we can better help you by providing feedback via our discord channel. You can also continue learning about Advanced Trade API in our technical documentation. Please come find us and other developers on Advanced Trade channel on Discord or on X ( @shubhashriM, @rfffjy), if you need assistance.

- -

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