# Bare Bitcoin API

API for interacting with Bare Bitcoin. Most endpoints require authentication. Create API keys [here](https://barebitcoin.no/innlogget/profil/nokler). Read about API authentication [here](https://dev.barebitcoin.no/#authentication).

Version: 0.0.1

## Servers

Prod environment
```
https://api.bb.no
```

## Security

### apiKey

[object Object]

Type: apiKey
In: header
Name: x-bb-api-key

### apiNonce

Nonce value. Used to ensure correct ordering of all API requests, as well as prevent attackers from being able to replay old requests. Can be set to any value, but needs to increase for each request. Recommendation is to use the current Unix timestamp in milliseconds.

Type: apiKey
In: header
Name: x-bb-api-nonce

### apiHmac

HMAC authentication for the API request, constructed using the corresponding secret value from your API key.

Type: apiKey
In: header
Name: x-bb-api-hmac

### oauth2

OAuth2 access token obtained through the authorization code flow. Only available on a subset of endpoints. The required scope is listed per operation.

Type: oauth2
Authorization URL: https://api.bb.no/oauth2/v0/authorize
Token URL: https://api.bb.no/oauth2/v0/token
Scopes:
- `api:accounts:bitcoin:read`: See balance and names of your bitcoin accounts
- `api:trades:read`: See executed trades
- `api:tax:transactions:read`: Read transactions relevant for tax calculation
- `api:deposits:lightning:read`: See Lightning invoices and their payment status
- `api:deposits:lightning:write`: Create Lightning invoices for payments to you

## Download OpenAPI description

 - [Bare Bitcoin API](https://dev.barebitcoin.no/_bundle/api/openapi.yaml)

## BitcoinTransferService

 - [GET /v1/deposit-destinations/bitcoin](https://dev.barebitcoin.no/api/openapi/bitcointransferservice/bitcointransferservice_depositdestinations.md): Fetches bitcoin deposit destinations. These destinations are always valid, and can be used for receiving arbitrary amounts. Onchain addresses are refreshed every time a deposit is made, but all prio
 - [POST /v1/deposit-destinations/bitcoin/invoice](https://dev.barebitcoin.no/api/openapi/bitcointransferservice/bitcointransferservice_newlightninginvoice.md): Creates a new BOLT11 Lightning invoice. Lightning invoices are requests to receive a specific amount of bitcoin within a set amount of time. If you don't a specific amount, consider using the destin
 - [GET /v1/deposit-destinations/bitcoin/invoice/{id}](https://dev.barebitcoin.no/api/openapi/bitcointransferservice/bitcointransferservice_getlightninginvoice.md): Fetches a Lightning invoice.
 - [POST /v1/withdrawals/bitcoin](https://dev.barebitcoin.no/api/openapi/bitcointransferservice/bitcointransferservice_sendbitcoin.md): Initiates a bitcoin withdrawal. The transaction is not completed until it is confirmed by the network it is sent onto. A success response from this endpoint means the transaction was successfully in
 - [GET /v1/withdrawals/bitcoin/{withdrawalId}](https://dev.barebitcoin.no/api/openapi/bitcointransferservice/bitcointransferservice_getbitcoinwithdrawal.md): Fetches a bitcoin withdrawal.
## PublicService

 - [GET /v1/price/nok](https://dev.barebitcoin.no/api/openapi/publicservice/publicservice_price.md): Fetches the current BTCNOK price.
 - [GET /v1/volume](https://dev.barebitcoin.no/api/openapi/publicservice/publicservice_volume.md): Returns statistics about the volume of BTCNOK trades.
 - [GET /v1/volume/historic](https://dev.barebitcoin.no/api/openapi/publicservice/publicservice_volumehistoric.md)
## TaxService

 - [GET /v1/tax/balance](https://dev.barebitcoin.no/api/openapi/taxservice/taxservice_gettaxbalance.md): Fetches the user's current balances: the NOK balance, and the balance of each bitcoin account.
 - [GET /v1/tax/transactions](https://dev.barebitcoin.no/api/openapi/taxservice/taxservice_listtaxtransactions.md): Lists tax-relevant transactions done by the user within the Bare Bitcoin platform. Note that this does NOT include any of the third party transactions imported into the platform tax calculator.
## TradingService

 - [GET /v1/orders](https://dev.barebitcoin.no/api/openapi/tradingservice/tradingservice_openorders.md): Fetches all open orders for the user. Open orders are orders that are not yet filled, and can be cancelled.
 - [POST /v1/orders](https://dev.barebitcoin.no/api/openapi/tradingservice/tradingservice_neworder.md): Places a new order. If the endpoint returns with a 200 status, the order is successfully placed. If you're creating a market order, a trade is also created, and its ID is included in the response.
 - [DELETE /v1/orders/{orderId}](https://dev.barebitcoin.no/api/openapi/tradingservice/tradingservice_cancelorder.md): Cancel a pending order. If the order is already filled, an error will be returned. It is not possible to cancel market orders.
## UserService

 - [DELETE /v1/user/applications/consent/{clientId}](https://dev.barebitcoin.no/api/openapi/userservice/userservice_revokeconsent.md): This endpoint can be called with any valid OAuth2-obtained token
 - [GET /v1/user/bitcoin-accounts](https://dev.barebitcoin.no/api/openapi/userservice/userservice_listbitcoinaccounts.md): Lists the bitcoin accounts for the user. Each bitcoin account has a separate balance. Every bitcoin transaction (withdrawal, deposit, trade, bonus payout) affects the balance of exactly one bitcoin
 - [GET /v1/user/fiat-account](https://dev.barebitcoin.no/api/openapi/userservice/userservice_getfiataccount.md): Fetches the fiat account. The fiat account for a user holds their NOK balance. Every user has exactly one fiat account. Other sub-accounts for a user only pertains to bitcoin holdings.
