Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1.0.0 #8

Merged
merged 2 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![License](https://img.shields.io/badge/License-Apache%202.0-green.svg)](https://opensource.org/license/apache-2-0/)
[![Code Style](https://img.shields.io/badge/code_style-black-black)](https://black.readthedocs.io/en/stable/)

Welcome to the official Coinbase Advanced Trading API Python SDK. This python project was created to allow coders to easily plug into the [Coinbase Advanced Trade API](https://docs.cloud.coinbase.com/advanced-trade-api/docs/welcome).
Welcome to the official Coinbase Advanced API Python SDK. This python project was created to allow coders to easily plug into the [Coinbase Advanced API](https://docs.cloud.coinbase.com/advanced-trade-api/docs/welcome).

## Installation

Expand All @@ -13,7 +13,7 @@ pip3 install coinbase-advanced

## Cloud API Keys

This SDK uses the Coinbase Cloud API keys. To use this SDK, you will need to create a Coinbase Cloud API key and secret. You can do this by following the instructions [here](https://docs.cloud.coinbase.com/advanced-trade-api/docs/auth#cloud-api-keys).
This SDK uses the Coinbase Cloud API keys. To use this SDK, you will need to create a Coinbase Cloud API key and secret by following the instructions [here](https://docs.cloud.coinbase.com/advanced-trade-api/docs/auth#cloud-api-keys).
Make sure to save your API key and secret in a safe place. You will not be able to retrieve your secret again.

WARNING: We do not recommend that you save your API secrets directly in your code outside of testing purposes. Best practice is to use a secrets manager and access your secrets that way. You should be careful about exposing your secrets publicly if posting code that leverages this library.
Expand Down Expand Up @@ -47,7 +47,7 @@ client = RESTClient(api_key=api_key, api_secret=api_secret, timeout=5)

### Using the Client

You can then use any of the API hooks to make calls to the Coinbase API. For example:
You are able to use any of the API hooks to make calls to the Coinbase API. For example:
```python
from json import dumps

Expand All @@ -59,11 +59,11 @@ print(dumps(order, indent=2))
```
This code calls the `get_accounts` and `market_order_buy` endpoints.

You can refer to the [Advanced Trade API Reference](https://docs.cloud.coinbase.com/advanced-trade-api/reference) for detailed information on each exposed endpoint.
You can look in the `coinbase.rest` module to see the API hooks that are exposed.
Refer to the [Advanced API Reference](https://docs.cloud.coinbase.com/advanced-trade-api/reference) for detailed information on each exposed endpoint.
Look in the `coinbase.rest` module to see the API hooks that are exposed.

### Passing in additional parameters
You can use `kwargs` to pass in any additional parameters. For example:
Use `kwargs` to pass in any additional parameters. For example:
```python
kwargs = {
"param1": 10,
Expand All @@ -73,7 +73,7 @@ product = client.get_product(product_id="BTC-USD", **kwargs)
```

### Generic REST Calls
You can also make generic REST calls using the `get`, `post`, `put`, and `delete` methods. For example:
You can make generic REST calls using the `get`, `post`, `put`, and `delete` methods. For example:
```python
market_trades = client.get("/api/v3/brokerage/products/BTC-USD/ticker", params={"limit": 5})

Expand All @@ -90,7 +90,7 @@ portfolio = client.create_portfolio(name="TestPortfolio")
## Authentication
Authentication of Cloud API Keys is handled automatically by the SDK when making a REST request.

However, if you wish to handle this yourself, you must create a JWT token and attach it to your request as detailed in the Cloud API docs [here](https://docs.cloud.coinbase.com/advanced-trade-api/docs/rest-api-auth#making-requests). You can use the built in `jwt_generator` to create your JWT token. For example:
However, if you wish to handle this yourself, you must create a JWT token and attach it to your request as detailed in the Cloud API docs [here](https://docs.cloud.coinbase.com/advanced-trade-api/docs/rest-api-auth#making-requests). Use the built in `jwt_generator` to create your JWT token. For example:
```python
from coinbase import jwt_generator

Expand All @@ -102,7 +102,7 @@ uri = "/api/v3/brokerage/orders"
jwt_uri = jwt_generator.format_jwt_uri("POST", uri)
jwt = jwt_generator.build_rest_jwt(jwt_uri, api_key, api_secret)
```
This will create a JWT token for the POST `/api/v3/brokerage/orders` endpoint. You can then pass this JWT token in the `Authorization` header of your request as:
This will create a JWT token for the POST `/api/v3/brokerage/orders` endpoint. Pass this JWT token in the `Authorization` header of your request as:
`
"Authorization": "Bearer " + jwt
`
Expand All @@ -116,13 +116,13 @@ api_secret = "-----BEGIN EC PRIVATE KEY-----\nYOUR PRIVATE KEY\n-----END EC PRIV

jwt = jwt_generator.build_ws_jwt(api_key, api_secret)
```
You can use this JWT to connect to the Websocket API by setting it in the "jwt" field of your subscription requests. See the docs [here](https://docs.cloud.coinbase.com/advanced-trade-api/docs/ws-overview#sending-messages-using-cloud-api-keys) for more details.
Use this JWT to connect to the Websocket API by setting it in the "jwt" field of your subscription requests. See the docs [here](https://docs.cloud.coinbase.com/advanced-trade-api/docs/ws-overview#sending-messages-using-cloud-api-keys) for more details.

## Changelog
For a detailed list of changes, see the [Changelog](CHANGELOG.md).

## Contributing

If you've found a bug within this project, please open an issue on this repo and add the "bug" label to it.
If you would like to request a new feature, please open an issue on this repo and add the "enhancement" label to it.
Please direct concerns or questions on the API to the [Advanced Trade API Developer Forum](https://forums.coinbasecloud.dev/c/advanced-trade-api/20).
If you've found a bug within this project, open an issue on this repo and add the "bug" label to it.
If you would like to request a new feature, open an issue on this repo and add the "enhancement" label to it.
Direct concerns or questions on the API to the [Advanced API Developer Forum](https://forums.coinbasecloud.dev/c/advanced-trade-api/20).
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
long_description_content_type="text/markdown",
author="Coinbase",
url="https://github.com/coinbase/coinbase-advanced-py",
keywords=["Coinbase", "Advanced Trade", "API"],
keywords=["Coinbase", "Advanced Trade", "API", "Advanced API"],
packages=find_packages(exclude=("tests",)),
install_requires=[req for req in requirements],
extras_require={
Expand Down