Making Your First Trade
To use the Advanced Trade Typescript SDK, first start by creating API keys. Once finished, import the RESTClient and then initialize it by passing in your API keys. Here is this would look:
import { RESTClient } from './rest';
const client = new RESTClient("INSERT_API_KEY", "INSERT_API_SECRET");
Once the client is initialized, you are ready to make your first call. In the provided example, we place a 10 USD Market Buy order on BTC-USD. To do so, we will make a request to the Create Order endpoint. Request and response objects are defined for all endpoints, so developers should have an easier time making requests and interacting with responses that get returned from them.
This endpoints uses the CreateOrderRequest object, in which there are 4 required fields:
clientOrderId: Provide a unique ID for this order
productId: The product you want to place the order for. In this case, it’s BTC-USD
side: Indicate whether you want to BUY or SELL this product. Import the OrderSide enum type and set it to either OrderSide.BUY or OrderSide.SELL
orderConfiguration: The details of the order. In this case, we are placing a Market order, so it only requires the size of the quote currency (USD)
After we provide the necessary fields, we send the request. If successful, it will return a CreateOrderResponse object and print it; otherwise, we print the error message that is returned instead.
import { RESTClient } from './rest';
import { OrderSide } from './rest/types/common-types';
} from './rest/types/orders-types';
const client = new RESTClient('INSERT_API_KEY', 'INSERT_API_SECRET');
clientOrderId: '00000001',
console.log(result as CreateOrderResponse);
console.error(error.message);
Refer to the API Reference for information about other endpoints.
The Advanced Trade TypeScript SDK simplifies integrating advanced trading features into applications by abstracting the Advanced Trade API's complexities. It offers a clear, consistent interface that speeds up development and time to market, making it ideal for building trading bots, portfolio management systems, or custom trading platforms.
Help us build better for you.
Advanced Trade Typescript SDK is made possible through the continued collaboration 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 the Advanced Trade channel on Discord or on X ( @shubhashriM), 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.