Coinbase.Pro.REST (coinbasepro_rest v1.0.0) View Source
This package implements a low-level REST API of the Coinbase Pro. Low-level means it is just a wrapper over HTTP library which handles authentication, request signing and has a few nice helper functions but you still have to construct URLs and interpret responses on your own.
If you want to use a high-level API, see elixir-coinbase/coinbasepro.
Installation
If available in Hex, the package can be installed
by adding coinbasepro_rest to your list of dependencies in mix.exs:
def deps do
[
{:coinbasepro_rest, "~> 1.0"}
]
endAdditional dependencies
As it uses Tesla underneath, you
have to follow its installation instructions. Specifically, you have to
install JSON library and you probably should install a HTTP client library
as default HTTP client based on httpc does not validate SSL certificates.
For example, add Jason and Hackney to the dependencies in mix.exs:
defp deps do
[
{:hackney, "~> 1.16.0"},
{:jason, ">= 1.0.0"}
]
endConfigure default adapter in config/config.exs (optional).
config :tesla, adapter: Tesla.Adapter.HackneySee Tesla's README for list of supported HTTP and JSON libraries.
Configuration
Base URL
By default, the API sends requests to the production API. If you want to
use Sandbox, you can add the following to the config/config.exs:
config :coinbasepro_rest, :base_url, "https://api-public.sandbox.pro.coinbase.com"User Agent
It is a good idea to override the default value of the User-Agent header added
to the requests to something that clearly identifies your application name and
version. If you want to do this, you can add the following to the config/config.exs:
config :coinbasepro_rest, :user_agent, "MyApp/1.0.0"Usage
In order to issue GET request
alias Coinbase.Pro.REST.{Context,Request}
# Obtain these values from Coinbase
context = %Context{key: "...", secret: "...", passphrase: "..."}
{:ok, response} = Request.get(context, "/orders?limit=10")
{:ok, response} = Request.post(context, "/deposits/payment-method", %{
"amount": 10.00,
"currency": "USD",
"payment_method_id": "bc677162-d934-5f1a-968c-a496b1c1270b"
})Documentation
The docs can be found at https://hexdocs.pm/coinbasepro_rest.
License
MIT
Authors
Marcin Lewandowski