Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

Commit

Permalink
docs: Add mission statement
Browse files Browse the repository at this point in the history
  • Loading branch information
bennycode committed Jul 14, 2022
1 parent c94a7d5 commit 034aa5a
Show file tree
Hide file tree
Showing 3 changed files with 5,664 additions and 5 deletions.
50 changes: 45 additions & 5 deletions README.md
Expand Up @@ -2,11 +2,11 @@

![Language Details](https://img.shields.io/github/languages/top/bennycode/coinbase-pro-node) ![Code Coverage](https://img.shields.io/codecov/c/github/bennycode/coinbase-pro-node/main) ![License](https://img.shields.io/npm/l/coinbase-pro-node.svg) ![Package Version](https://img.shields.io/npm/v/coinbase-pro-node.svg)

[Coinbase API][1] for Node.js, written in TypeScript and covered by tests.
Unofficial [Coinbase API][1] for Node.js, written in TypeScript and covered by tests.

## Motivation

The purpose of [coinbase-pro-node][5] is to continue an active **Coinbase API** after Coinbase deprecated the official Node.js library on [January, 16 2020](https://github.com/coinbase/coinbase-pro-node/issues/393#issuecomment-574993096). Its predecessor got deprecated on [July, 19th 2016](https://github.com/coinbase/coinbase-exchange-node/commit/b8347efdb4e2589367c1395b646d283c9c391681).
The purpose of this [coinbase-pro-node][5] package is to maintain a recent Coinbase API for Node.js with type safety through TypeScript.

## Features

Expand Down Expand Up @@ -54,7 +54,7 @@ const client = new CoinbasePro();

The [demo section][3] provides many examples on how to use "coinbase-pro-node". There is also an automatically generated [API documentation][4]. For a quick start, here is a simple example for a REST request:

### REST example
### REST Example

```typescript
import {CoinbasePro} from 'coinbase-pro-node';
Expand All @@ -79,7 +79,7 @@ client.rest.account.listAccounts().then(accounts => {
});
```

### WebSocket example
### WebSocket Example

If you want to listen to WebSocket messages, have a look at these demo scripts:

Expand Down Expand Up @@ -138,7 +138,7 @@ const client = new CoinbasePro({
});
```

### Real-world examples
### Real-world Examples

Checkout [GitHub's dependency graph][6] to see who uses "coinbase-pro-node" in production. There are also [npm packages][7] depending on "coinbase-pro-node".

Expand Down Expand Up @@ -173,6 +173,46 @@ If you like this project, you might also like these related projects:
- [**ig-trading-api**](https://github.com/bennycode/ig-trading-api), REST API, written in TypeScript, for CFD trading with IG.
- [**binance-api-node**](https://github.com/Ashlar/binance-api-node), Heavily tested and Promise-based Binance API with TypeScript definitions.

---

## Problems with official Coinbase APIs

There are official Coinbase APIs for Node.js, but they all come with some disadvantages leading to decreased developer experience (DX):

1. [Coinbase's first Node.js API](https://github.com/coinbase/coinbase-exchange-node) has no type safety and got deprecated on [July, 19th 2016](https://github.com/coinbase/coinbase-exchange-node/commit/b8347efdb4e2589367c1395b646d283c9c391681)
2. [Coinbase's second Node.js API](https://github.com/coinbase/coinbase-pro-node) has no type safety and got deprecated on [January, 16 2020](https://github.com/coinbase/coinbase-pro-node/issues/393#issuecomment-574993096)
3. [Coinbase's current Node.js API](https://docs.cloud.coinbase.com/exchange/reference) ([OAS spec](https://dash.readme.com/api/v1/api-registry/qgumw1pl3iz4yut)) still lacks type safety and does not incorporate best practices like automatic reconnections and request throttling

## Official Coinbase API

Coinbase is versioning its API through [ReadMe.com](https://readme.com/), so you can generate an API client from their [OpenAPI Specification](https://dash.readme.com/api/v1/api-registry/qgumw1pl3iz4yut). ReadMe provides a Node.js package named "[api](https://www.npmjs.com/package/api)" which allows you to retrieve an automatically generated Node.js client:

### Installation

```bash
npm install api@^4.5.1
```

### Usage

```ts
import api from 'api';

const sdk = api('@coinbase-exchange/v1.0#qgumw1pl3iz4yut');

sdk['ExchangeRESTAPI_GetProductTrades']({
product_id: 'BTC-USD',
}).then(response => {
console.log(`Found "${response.length}" trades.`);
});
```

### Drawbacks

The current Coinbase Node.js SDK (provided by the [api package](https://www.npmjs.com/package/api)) does not support typings for response payloads:

![Official Coinbase API](./coinbase-api-screenshot.png 'Type safety problems in official Coinbase API')

[1]: https://pro.coinbase.com/
[2]: https://docs.cloud.coinbase.com/exchange
[3]: https://github.com/bennycode/coinbase-pro-node/tree/main/src/demo
Expand Down
Binary file added coinbase-api-screenshot.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 034aa5a

Please sign in to comment.