https://github.com/teramonagi/bitflyer
R wrapper for bitFlyer's REST API
https://github.com/teramonagi/bitflyer
bitflyer bitflyer-api r
Last synced: 7 months ago
JSON representation
R wrapper for bitFlyer's REST API
- Host: GitHub
- URL: https://github.com/teramonagi/bitflyer
- Owner: teramonagi
- License: other
- Created: 2018-06-26T13:47:31.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2021-01-11T02:28:19.000Z (over 5 years ago)
- Last Synced: 2025-10-09T04:16:10.294Z (8 months ago)
- Topics: bitflyer, bitflyer-api, r
- Language: R
- Size: 67.4 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 5
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
README
---
output: github_document
---
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-"
)
```
# bitflyer
[](https://github.com/teramonagi/bitflyer/actions)
[](https://www.tidyverse.org/lifecycle/#experimental)
R wrapper for [bitFlyer's API](https://lightning.bitflyer.com/docs/api?lang=en)
## Installation
```{r gh-installation, eval = FALSE}
# Not yet on CRAN
# install.packages("bitflyer")
# Install the development version from GitHub:
# install.packages("devtools")
devtools::install_github("teramonagi/bitflyer")
```
## Preparation of API keys
bitFlyer Private APIs require authentication using an API Key and API Secret.
They can be obtained by generating them on the [developer's page](https://lightning.bitflyer.com/developer).
You must set these keys in `.Renviron`
```bash
❯ cat ~/.Renviron
BITFLYER_LIGHTNING_API_KEY=
BITFLYER_LIGHTNING_API_SECRET=
```
or as global variables in R
```{r, eval=FALSE}
> BITFLYER_LIGHTNING_API_KEY <- "your-api-key"
> BITFLYER_LIGHTNING_API_SECRET <- "your-api-secret"
```
## Example
### HTTP API
#### [HTTP Public API](https://lightning.bitflyer.com/docs/api?lang=en#http-public-api)
```{r public_api}
library("bitflyer")
# Get the list of market
fromJSON(markets())
# Get order book
x <- board(product_code = "BTC_JPY")
x <- fromJSON(x)
str(x)
# Ticker
ticker(product_code = "BTC_JPY")
# Execution History
head(fromJSON(executions()))
# Get orderbook status
fromJSON(get_board_state())
# Get the current status of the exchange.
get_health()
```
#### [HTTP Private API](https://lightning.bitflyer.com/docs/api?lang=en#http-private-api)
The results of this chunk are hidden because you really understand of my portfolio/positions ...
```{r private_api, eval=FALSE}
# Get a list of which HTTP Private APIs can be used with the specified API key
fromJSON(get_permissions())
# Get Margin Status
fromJSON(get_collateral())
#Send a New Order
x <- send_child_order(
product_code = "BTC_JPY",
child_order_type = "LIMIT",
side = "BUY",
price = 300*10^4,
size = 0.001
)
x
child_order_acceptance_id <- fromJSON(x)$child_order_acceptance_id
# List Orders
fromJSON(get_child_orders(product_code = "BTC_JPY", child_order_acceptance_id=child_order_acceptance_id))
# You can also get all active orders
# fromJSON(get_child_orders(product_code = "BTC_JPY", child_order_state="ACTIVE"))
# Cancel the order
cancel_child_order(product_code = "BTC_JPY", child_order_acceptance_id = child_order_acceptance_id)
# You can also cancel all child orders
# cancel_all_child_orders(product_code = "BTC_JPY")
# No active orders (Check)
fromJSON(get_child_orders(product_code = "BTC_JPY", child_order_state="ACTIVE"))
# Get balance
fromJSON(get_balance())
# Get Parent Order Details
get_parent_orders(product_code = "BTC_JPY")
# List Executions
fromJSON(get_executions(product_code = "BTC_JPY"))
# List Balance History
fromJSON(get_balance_history())
# Get Open Interest Summary
get_positions()
# Get Margin Change History
fromJSON(get_collateral_history())
# Get Trading Commission
get_trading_commission(product_code = "BTC_JPY")
```
The following APIs are not implemented yet.
- [Deposits and Withdrawals](https://lightning.bitflyer.com/docs?lang=en#get-crypto-assets-deposit-addresses) APIs
- [Submit New Parent Order (Special order)](https://lightning.bitflyer.com/docs?lang=en#submit-new-parent-order-special-order) API
- Endpoint: `/v1/me/sendparentorder`
### Realtime API
... Not implemented yet(under development) ...