### Install and Initialize Ruby Coincheck Client Source: https://context7.com/coincheckjp/ruby_coincheck_client/llms.txt Add the gem to your Gemfile or install it directly. Initialize the client with API credentials for private endpoints or without for public endpoints only. Custom configurations are also supported. ```ruby gem 'ruby_coincheck_client' # Or install directly # $ gem install ruby_coincheck_client require 'ruby_coincheck_client' # Initialize with API credentials for private endpoints cc = CoincheckClient.new("YOUR_API_KEY", "YOUR_SECRET_KEY") # Initialize without credentials for public endpoints only cc_public = CoincheckClient.new # Custom configuration (optional) cc_custom = CoincheckClient.new("API_KEY", "SECRET_KEY", { base_url: "https://coincheck.com/", ssl: true }) ``` -------------------------------- ### Install ruby_coincheck_client Gem Source: https://github.com/coincheckjp/ruby_coincheck_client/blob/master/README.md Add the gem to your Gemfile for project dependency management. ```ruby gem 'ruby_coincheck_client' ``` -------------------------------- ### GET /api/exchange/orders/opens Source: https://context7.com/coincheckjp/ruby_coincheck_client/llms.txt Retrieves open or closed positions from the exchange. ```APIDOC ## GET /api/exchange/orders/opens ### Description Retrieves a list of positions filtered by their status. ### Parameters #### Query Parameters - **status** (string) - Required - The status of positions to retrieve ('open' or 'closed'). ### Response #### Success Response (200) - **data** (array) - List of position objects. #### Response Example { "success": true, "data": [ { "id": 123, "pair": "btc_jpy", "status": "open", "amount": "0.01" } ] } ``` -------------------------------- ### GET /api/exchange/borrows Source: https://context7.com/coincheckjp/ruby_coincheck_client/llms.txt Retrieves active borrow matches. ```APIDOC ## GET /api/exchange/borrows ### Description Retrieves active borrow matches. ### Method GET ### Response #### Success Response (200) - **success** (boolean) - Indicates if the request was successful - **matches** (array) - List of active borrow matches ### Response Example { "success": true, "matches": [ {"id": 123, "amount": "0.1", "currency": "BTC", "rate": "0.0001", "created_at": "2024-01-01T00:00:00.000Z"} ] } ``` -------------------------------- ### GET /api/accounts/balance Source: https://context7.com/coincheckjp/ruby_coincheck_client/llms.txt Retrieves the current balance for all currencies in your account. ```APIDOC ## GET /api/accounts/balance ### Description Retrieves the current balance for all currencies in your account. Requires authentication. ### Method GET ### Response #### Success Response (200) - **success** (boolean) - Status - **jpy** (string) - JPY balance - **btc** (string) - BTC balance - **jpy_reserved** (string) - Reserved JPY - **btc_reserved** (string) - Reserved BTC #### Response Example { "success": true, "jpy": "100000.0", "btc": "0.5", "jpy_reserved": "50000.0", "btc_reserved": "0.1" } ``` -------------------------------- ### GET /api/ticker Source: https://context7.com/coincheckjp/ruby_coincheck_client/llms.txt Retrieves the current ticker information including last price, bid, ask, high, low, and volume for the BTC/JPY market. ```APIDOC ## GET /api/ticker ### Description Retrieves the current ticker information including last price, bid, ask, high, low, and volume for the BTC/JPY market. ### Method GET ### Response #### Success Response (200) - **last** (number) - Last price - **bid** (number) - Current bid price - **ask** (number) - Current ask price - **high** (number) - High price - **low** (number) - Low price - **volume** (string) - Trading volume - **timestamp** (number) - Unix timestamp #### Response Example { "last": 4500000, "bid": 4499500, "ask": 4500500, "high": 4550000, "low": 4450000, "volume": "1234.5678", "timestamp": 1609459200 } ``` -------------------------------- ### GET /api/order_books Source: https://context7.com/coincheckjp/ruby_coincheck_client/llms.txt Retrieves the current order book with all bids and asks for the market. ```APIDOC ## GET /api/order_books ### Description Retrieves the current order book with all bids and asks for the market. ### Method GET ### Response #### Success Response (200) - **asks** (array) - List of ask orders - **bids** (array) - List of bid orders #### Response Example { "asks": [["4500500.0", "0.5"]], "bids": [["4499500.0", "0.8"]] } ``` -------------------------------- ### GET /api/orders/rate Source: https://context7.com/coincheckjp/ruby_coincheck_client/llms.txt Calculates the rate for a specified order type and amount. ```APIDOC ## GET /api/orders/rate ### Description Calculates the rate for a specified order type and amount. Useful for estimating order execution prices. ### Method GET ### Parameters #### Query Parameters - **order_type** (string) - Required - 'buy' or 'sell' - **amount** (string) - Optional - Amount to trade - **price** (number) - Optional - Price for calculation - **pair** (string) - Optional - Trading pair ### Response #### Success Response (200) - **success** (boolean) - Status - **rate** (string) - Calculated rate - **price** (string) - Calculated price - **amount** (string) - Amount used #### Response Example { "success": true, "rate": "4500000.0", "price": "45000.0", "amount": "0.01" } ``` -------------------------------- ### GET /api/rate Source: https://context7.com/coincheckjp/ruby_coincheck_client/llms.txt Retrieves the current exchange rate for a specified trading pair. ```APIDOC ## GET /api/rate ### Description Retrieves the current exchange rate for a specified trading pair. ### Method GET ### Parameters #### Query Parameters - **pair** (string) - Optional - The trading pair (e.g., btc_jpy, eth_btc) ### Response #### Success Response (200) - **rate** (string) - The current exchange rate #### Response Example { "rate": "4500000.0" } ``` -------------------------------- ### GET /api/bank_accounts Source: https://context7.com/coincheckjp/ruby_coincheck_client/llms.txt Retrieves or manages registered bank accounts for fiat withdrawals. ```APIDOC ## GET /api/bank_accounts ### Description Retrieves a list of bank accounts registered for fiat withdrawals. ### Response #### Success Response (200) - **data** (array) - List of bank account objects. #### Response Example { "success": true, "data": [ { "id": 123, "bank_name": "MUFG Bank", "number": "1234567" } ] } ``` -------------------------------- ### GET /api/trades Source: https://context7.com/coincheckjp/ruby_coincheck_client/llms.txt Retrieves recent trade history for a specified trading pair. ```APIDOC ## GET /api/trades ### Description Retrieves recent trade history for a specified trading pair. Defaults to BTC/JPY. ### Method GET ### Parameters #### Query Parameters - **pair** (string) - Optional - The trading pair (e.g., btc_jpy, eth_jpy) ### Response #### Success Response (200) - **success** (boolean) - Status of the request - **pagination** (object) - Pagination details - **data** (array) - List of trade records #### Response Example { "success": true, "pagination": {}, "data": [ {"id": 123, "amount": "0.1", "rate": 4500000, "pair": "btc_jpy", "order_type": "sell", "created_at": "2024-01-01T00:00:00.000Z"} ] } ``` -------------------------------- ### Initialize and Use CoincheckClient Source: https://github.com/coincheckjp/ruby_coincheck_client/blob/master/README.md Demonstrates client initialization with API credentials and various API method calls for account, order, and market data management. ```ruby #!/usr/bin/env ruby -Ilib require 'ruby_coincheck_client' cc = CoincheckClient.new("YOUR API KEY", "YOUR SECRET KEY") response = cc.read_balance response = cc.read_leverage_balance response = cc.read_accounts response = cc.read_transactions response = cc.read_positions response = cc.read_orders response = cc.read_orders_rate(order_type: 'buy', amount: "0.01") response = cc.create_orders(rate: "40001", amount: "0.01", order_type: "buy") response = cc.create_orders(rate: "50001", amount: "0.001", order_type: "sell") response = cc.create_orders(market_buy_amount: 100, order_type: "market_buy") response = cc.create_orders(amount: "0.001", order_type: "market_sell") response = cc.create_orders(rate: "40000", amount: "0.001", order_type: "leverage_buy") response = cc.create_orders(rate: "60000", amount: "0.001", order_type: "leverage_sell") response = cc.create_orders(rate: "60000", amount: "0.001", position_id: "2222", order_type: "close_long") response = cc.create_orders(rate: "40000", amount: "0.001", position_id: "2222", order_type: "close_short") response = cc.delete_orders(id: "2503344") response = cc.create_send_money(address: "136aHpRdd7eezbEusAKS2GyWx9eXZsEuMz", amount: "0.0005") response = cc.read_send_money response = cc.read_deposit_money response = cc.create_deposit_money_fast(id: "2222") response = cc.read_ticker response = cc.read_trades response = cc.read_rate response = cc.read_order_books response = cc.read_bank_accounts response = cc.delete_bank_accounts(id: "2222") response = cc.read_withdraws response = cc.delete_withdraws response = cc.create_borrows(amount: "0.001", currency: "BTC") response = cc.read_borrows response = cc.delete_borrows(id: "58606") response = cc.transfer_to_leverage(amount: "1000") response = cc.transfer_from_leverage(amount: "1000") JSON.parse(response.body) ``` -------------------------------- ### Create orders Source: https://context7.com/coincheckjp/ruby_coincheck_client/llms.txt Creates various types of orders including limit, market, and leverage orders. ```ruby require 'ruby_coincheck_client' cc = CoincheckClient.new(ENV['API_KEY'], ENV['SECRET_KEY']) # Limit buy order: Buy 0.01 BTC at 4,000,000 JPY response = cc.create_orders( rate: "4000000", amount: "0.01", order_type: "buy" ) order = JSON.parse(response.body) # Limit sell order: Sell 0.001 BTC at 5,000,000 JPY response = cc.create_orders( rate: "5000000", amount: "0.001", order_type: "sell" ) # Market buy order: Buy 100 JPY worth of BTC at market price response = cc.create_orders( market_buy_amount: 100, order_type: "market_buy" ) # Market sell order: Sell 0.001 BTC at market price response = cc.create_orders( amount: "0.001", order_type: "market_sell" ) # Leverage buy order response = cc.create_orders( rate: "4000000", amount: "0.001", order_type: "leverage_buy" ) # Leverage sell order response = cc.create_orders( rate: "6000000", amount: "0.001", order_type: "leverage_sell" ) # Close long position response = cc.create_orders( rate: "6000000", amount: "0.001", position_id: "2222", order_type: "close_long" ) # Close short position response = cc.create_orders( rate: "4000000", amount: "0.001", position_id: "2222", order_type: "close_short" ) # Order with different trading pair response = cc.create_orders( rate: "300000", amount: "0.1", order_type: "buy", pair: CoincheckClient::Pair::ETH_JPY ) puts order # { # "success": true, # "id": 123456, # "rate": "4000000.0", # "amount": "0.01", # "order_type": "buy", # "pair": "btc_jpy", # "created_at": "2024-01-01T00:00:00.000Z" # } ``` -------------------------------- ### Create Borrows Request Source: https://context7.com/coincheckjp/ruby_coincheck_client/llms.txt Use this to create a new borrow request for margin trading. Requires amount and currency. ```ruby require 'ruby_coincheck_client' cc = CoincheckClient.new(ENV['API_KEY'], ENV['SECRET_KEY']) response = cc.create_borrows( amount: "0.001", currency: "BTC" ) result = JSON.parse(response.body) puts result # {"success": true, "id": 123, "amount": "0.001", "currency": "BTC"} ``` -------------------------------- ### Create Fast Deposit Source: https://context7.com/coincheckjp/ruby_coincheck_client/llms.txt Requests fast deposit processing for a pending deposit. ```ruby require 'ruby_coincheck_client' cc = CoincheckClient.new(ENV['API_KEY'], ENV['SECRET_KEY']) response = cc.create_deposit_money_fast(id: "2222") result = JSON.parse(response.body) puts result ``` -------------------------------- ### Retrieve Order Book Source: https://context7.com/coincheckjp/ruby_coincheck_client/llms.txt Fetches the current order book, displaying all bids and asks for the market. Requires the client to be initialized. ```ruby require 'ruby_coincheck_client' cc = CoincheckClient.new response = cc.read_order_books order_books = JSON.parse(response.body) puts order_books # { # "asks": [ # ["4500500.0", "0.5"], # ["4500600.0", "1.2"], # ... # ], # "bids": [ # ["4499500.0", "0.8"], # ["4499400.0", "2.1"], # ... # ] # } ``` -------------------------------- ### Retrieve leverage balance Source: https://context7.com/coincheckjp/ruby_coincheck_client/llms.txt Fetches the current leverage account balance and margin details. ```ruby require 'ruby_coincheck_client' cc = CoincheckClient.new(ENV['API_KEY'], ENV['SECRET_KEY']) response = cc.read_leverage_balance leverage_balance = JSON.parse(response.body) puts leverage_balance # { # "success": true, # "margin": { # "jpy": "100000.0" # }, # "margin_available": { # "jpy": "80000.0" # }, # "margin_level": "5.0" # } ``` -------------------------------- ### Create Order Source: https://context7.com/coincheckjp/ruby_coincheck_client/llms.txt Creates a new order. Supports limit orders, market orders, and leverage orders. ```APIDOC ## POST /api/orders ### Description Creates a new order. Supports limit orders, market orders, and leverage orders. ### Method POST ### Endpoint /api/orders ### Request Body - **rate** (string) - Optional - The limit price for the order (required for limit orders). - **amount** (string) - Optional - The amount of the base currency to trade (required for limit and market sell orders). - **market_buy_amount** (integer) - Optional - The amount of quote currency to spend for a market buy order. - **order_type** (string) - Required - The type of order (e.g., "buy", "sell", "market_buy", "market_sell", "leverage_buy", "leverage_sell", "close_long", "close_short"). - **pair** (string) - Optional - The trading pair (e.g., "btc_jpy"). Defaults to "btc_jpy". - **position_id** (string) - Optional - The ID of the position to close (required for close orders). ### Request Example (Limit Buy Order) ```json { "rate": "4000000", "amount": "0.01", "order_type": "buy" } ``` ### Request Example (Market Buy Order) ```json { "market_buy_amount": 100, "order_type": "market_buy" } ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the request was successful. - **id** (integer) - The ID of the created order. - **rate** (string) - The limit price of the order. - **amount** (string) - The amount of the order. - **order_type** (string) - The type of the order. - **pair** (string) - The trading pair. - **created_at** (string) - The timestamp when the order was created. ### Response Example ```json { "success": true, "id": 123456, "rate": "4000000.0", "amount": "0.01", "order_type": "buy", "pair": "btc_jpy", "created_at": "2024-01-01T00:00:00.000Z" } ``` ``` -------------------------------- ### Create Bank Account Source: https://context7.com/coincheckjp/ruby_coincheck_client/llms.txt Registers a new bank account for fiat withdrawals. ```ruby require 'ruby_coincheck_client' cc = CoincheckClient.new(ENV['API_KEY'], ENV['SECRET_KEY']) response = cc.create_bank_accounts( bank_name: "MUFG Bank", branch_name: "Shibuya", bank_account_type: "futsu", number: "1234567", name: "Yamada Taro" ) result = JSON.parse(response.body) puts result ``` -------------------------------- ### Retrieve BTC/JPY Ticker Information Source: https://context7.com/coincheckjp/ruby_coincheck_client/llms.txt Fetches the current ticker information for the BTC/JPY market, including last price, bid, ask, high, low, and volume. Requires the client to be initialized. ```ruby require 'ruby_coincheck_client' cc = CoincheckClient.new response = cc.read_ticker data = JSON.parse(response.body) puts data # { # "last": 4500000, # "bid": 4499500, # "ask": 4500500, # "high": 4550000, # "low": 4450000, # "volume": "1234.5678", # "timestamp": 1609459200 # } ``` -------------------------------- ### Supported Currency Pairs and Constants Source: https://context7.com/coincheckjp/ruby_coincheck_client/llms.txt Access constants for all supported trading pairs and currencies within the CoincheckClient library. ```ruby require 'ruby_coincheck_client' # JPY pairs CoincheckClient::Pair::BTC_JPY # "btc_jpy" CoincheckClient::Pair::ETH_JPY # "eth_jpy" CoincheckClient::Pair::ETC_JPY # "etc_jpy" CoincheckClient::Pair::LSK_JPY # "lsk_jpy" CoincheckClient::Pair::FCT_JPY # "fct_jpy" CoincheckClient::Pair::XRP_JPY # "xrp_jpy" CoincheckClient::Pair::XEM_JPY # "xem_jpy" CoincheckClient::Pair::LTC_JPY # "ltc_jpy" CoincheckClient::Pair::BCH_JPY # "bch_jpy" # BTC pairs CoincheckClient::Pair::ETH_BTC # "eth_btc" CoincheckClient::Pair::ETC_BTC # "etc_btc" CoincheckClient::Pair::LSK_BTC # "lsk_btc" CoincheckClient::Pair::FCT_BTC # "fct_btc" CoincheckClient::Pair::XRP_BTC # "xrp_btc" CoincheckClient::Pair::XEM_BTC # "xem_btc" CoincheckClient::Pair::LTC_BTC # "ltc_btc" CoincheckClient::Pair::BCH_BTC # "bch_btc" # Currency constants CoincheckClient::JPY # "JPY" CoincheckClient::BTC # "BTC" CoincheckClient::ETH # "ETH" CoincheckClient::XRP # "XRP" # ... and more ``` -------------------------------- ### Retrieve account information Source: https://context7.com/coincheckjp/ruby_coincheck_client/llms.txt Fetches user account details including ID, email, and verification status. ```ruby require 'ruby_coincheck_client' cc = CoincheckClient.new(ENV['API_KEY'], ENV['SECRET_KEY']) response = cc.read_accounts account = JSON.parse(response.body) puts account # { # "success": true, # "id": 12345, # "email": "user@example.com", # "identity_status": "identity_verified", # "bitcoin_address": "1ABC..." # } ``` -------------------------------- ### Retrieve open orders Source: https://context7.com/coincheckjp/ruby_coincheck_client/llms.txt Fetches a list of all currently unfilled orders. ```ruby require 'ruby_coincheck_client' cc = CoincheckClient.new(ENV['API_KEY'], ENV['SECRET_KEY']) response = cc.read_orders orders = JSON.parse(response.body) puts orders # { # "success": true, # "orders": [ # { # "id": 123456, # "order_type": "buy", # "rate": "4400000.0", # "pair": "btc_jpy", # "pending_amount": "0.1", # "pending_market_buy_amount": null, # "stop_loss_rate": null, # "created_at": "2024-01-01T00:00:00.000Z" # } # ] # } ``` -------------------------------- ### POST /api/exchange/borrows Source: https://context7.com/coincheckjp/ruby_coincheck_client/llms.txt Creates a new borrow request for margin trading. ```APIDOC ## POST /api/exchange/borrows ### Description Creates a new borrow request for margin trading. ### Method POST ### Parameters #### Request Body - **amount** (string) - Required - The amount to borrow - **currency** (string) - Required - The currency code (e.g., BTC) ### Response #### Success Response (200) - **success** (boolean) - Indicates if the request was successful - **id** (integer) - The ID of the created borrow - **amount** (string) - The borrowed amount - **currency** (string) - The currency borrowed ### Response Example { "success": true, "id": 123, "amount": "0.001", "currency": "BTC" } ``` -------------------------------- ### POST /api/exchange/transfers/from_leverage Source: https://context7.com/coincheckjp/ruby_coincheck_client/llms.txt Transfers funds from leverage account back to spot account. ```APIDOC ## POST /api/exchange/transfers/from_leverage ### Description Transfers funds from leverage account back to spot account. ### Method POST ### Parameters #### Request Body - **amount** (string) - Required - The amount to transfer - **currency** (string) - Optional - The currency code ### Response #### Success Response (200) - **success** (boolean) - Indicates if the request was successful - **amount** (string) - The transferred amount - **currency** (string) - The currency transferred ### Response Example { "success": true, "amount": "1000", "currency": "JPY" } ``` -------------------------------- ### Read Positions Source: https://context7.com/coincheckjp/ruby_coincheck_client/llms.txt Retrieves open or closed positions from the account. ```ruby # Get only open positions response = cc.read_positions(status: 'open') open_positions = JSON.parse(response.body) # Get only closed positions response = cc.read_positions(status: 'closed') closed_positions = JSON.parse(response.body) ``` -------------------------------- ### Create Send Money Source: https://context7.com/coincheckjp/ruby_coincheck_client/llms.txt Sends cryptocurrency to an external wallet address. ```ruby require 'ruby_coincheck_client' cc = CoincheckClient.new(ENV['API_KEY'], ENV['SECRET_KEY']) response = cc.create_send_money( address: "136aHpRdd7eezbEusAKS2GyWx9eXZsEuMz", amount: "0.0005" ) result = JSON.parse(response.body) puts result ``` -------------------------------- ### POST /api/exchange/transfers/to_leverage Source: https://context7.com/coincheckjp/ruby_coincheck_client/llms.txt Transfers funds from spot account to leverage account. ```APIDOC ## POST /api/exchange/transfers/to_leverage ### Description Transfers funds from spot account to leverage account. ### Method POST ### Parameters #### Request Body - **amount** (string) - Required - The amount to transfer - **currency** (string) - Optional - The currency code ### Response #### Success Response (200) - **success** (boolean) - Indicates if the request was successful - **amount** (string) - The transferred amount - **currency** (string) - The currency transferred ### Response Example { "success": true, "amount": "1000", "currency": "JPY" } ``` -------------------------------- ### Retrieve leverage positions Source: https://context7.com/coincheckjp/ruby_coincheck_client/llms.txt Fetches leverage trading positions, with optional filtering by status. ```ruby require 'ruby_coincheck_client' cc = CoincheckClient.new(ENV['API_KEY'], ENV['SECRET_KEY']) # Get all positions response = cc.read_positions positions = JSON.parse(response.body) ``` -------------------------------- ### Read Account Balance Source: https://context7.com/coincheckjp/ruby_coincheck_client/llms.txt Retrieves the current balance for all currencies in your account. This method requires the client to be initialized with API credentials. ```ruby require 'ruby_coincheck_client' cc = CoincheckClient.new(ENV['API_KEY'], ENV['SECRET_KEY']) response = cc.read_balance balance = JSON.parse(response.body) puts balance # { # "success": true, # "jpy": "100000.0", # "btc": "0.5", # "jpy_reserved": "50000.0", # "btc_reserved": "0.1", # "jpy_lend_in_use": "0.0", # "btc_lend_in_use": "0.0", # "jpy_lent": "0.0", # "btc_lent": "0.0", # "jpy_debt": "0.0", # "btc_debt": "0.0" # } ``` -------------------------------- ### Read Leverage Balance Source: https://context7.com/coincheckjp/ruby_coincheck_client/llms.txt Retrieves the leverage account balance and margin information. ```APIDOC ## GET /api/accounts/leverage_balance ### Description Retrieves the leverage account balance and margin information. ### Method GET ### Endpoint /api/accounts/leverage_balance ### Response #### Success Response (200) - **success** (boolean) - Indicates if the request was successful. - **margin** (object) - Contains the current margin details. - **jpy** (string) - The available margin in JPY. - **margin_available** (object) - Contains the available margin details. - **jpy** (string) - The available margin in JPY. - **margin_level** (string) - The current margin level. ### Response Example ```json { "success": true, "margin": { "jpy": "100000.0" }, "margin_available": { "jpy": "80000.0" }, "margin_level": "5.0" } ``` ``` -------------------------------- ### Read Accounts Source: https://context7.com/coincheckjp/ruby_coincheck_client/llms.txt Retrieves account information including user ID and email. ```APIDOC ## GET /api/accounts ### Description Retrieves account information including user ID and email. ### Method GET ### Endpoint /api/accounts ### Response #### Success Response (200) - **success** (boolean) - Indicates if the request was successful. - **id** (integer) - The user ID. - **email** (string) - The user's email address. - **identity_status** (string) - The verification status of the user's identity. - **bitcoin_address** (string) - The user's Bitcoin address. ### Response Example ```json { "success": true, "id": 12345, "email": "user@example.com", "identity_status": "identity_verified", "bitcoin_address": "1ABC..." } ``` ``` -------------------------------- ### Read Orders Source: https://context7.com/coincheckjp/ruby_coincheck_client/llms.txt Retrieves all open (unfilled) orders. ```APIDOC ## GET /api/orders ### Description Retrieves all open (unfilled) orders. ### Method GET ### Endpoint /api/orders ### Response #### Success Response (200) - **success** (boolean) - Indicates if the request was successful. - **orders** (array) - A list of open order objects. - **id** (integer) - The order ID. - **order_type** (string) - The type of order (e.g., "buy", "sell"). - **rate** (string) - The limit price for the order. - **pair** (string) - The trading pair (e.g., "btc_jpy"). - **pending_amount** (string) - The remaining amount to be filled. - **pending_market_buy_amount** (null) - Placeholder for market buy amount. - **stop_loss_rate** (null) - The stop loss rate, if set. - **created_at** (string) - The timestamp when the order was created. ### Response Example ```json { "success": true, "orders": [ { "id": 123456, "order_type": "buy", "rate": "4400000.0", "pair": "btc_jpy", "pending_amount": "0.1", "pending_market_buy_amount": null, "stop_loss_rate": null, "created_at": "2024-01-01T00:00:00.000Z" } ] } ``` ``` -------------------------------- ### Retrieve Current Exchange Rate Source: https://context7.com/coincheckjp/ruby_coincheck_client/llms.txt Fetches the current exchange rate for a specified trading pair. Defaults to BTC/JPY. Use CoincheckClient::Pair constants for other pairs like ETH/BTC. ```ruby require 'ruby_coincheck_client' cc = CoincheckClient.new # Get BTC/JPY rate (default) response = cc.read_rate rate = JSON.parse(response.body) # Get ETH/BTC rate response = cc.read_rate(pair: CoincheckClient::Pair::ETH_BTC) rate = JSON.parse(response.body) puts rate # {"rate": "4500000.0"} ``` -------------------------------- ### Retrieve Recent Trade History Source: https://context7.com/coincheckjp/ruby_coincheck_client/llms.txt Fetches recent trade history for a specified trading pair. Defaults to BTC/JPY. Use CoincheckClient::Pair constants for specifying other pairs like ETH/JPY. ```ruby require 'ruby_coincheck_client' cc = CoincheckClient.new # Get BTC/JPY trades (default) response = cc.read_trades trades = JSON.parse(response.body) # Get ETH/JPY trades response = cc.read_trades(pair: CoincheckClient::Pair::ETH_JPY) trades = JSON.parse(response.body) puts trades # { # "success": true, # "pagination": {...}, # "data": [ # {"id": 123, "amount": "0.1", "rate": 4500000, "pair": "btc_jpy", "order_type": "sell", "created_at": "2024-01-01T00:00:00.000Z"}, # ... # ] # } ``` -------------------------------- ### Retrieve paginated transactions Source: https://context7.com/coincheckjp/ruby_coincheck_client/llms.txt Fetches transaction history using pagination for large datasets. ```ruby require 'ruby_coincheck_client' cc = CoincheckClient.new(ENV['API_KEY'], ENV['SECRET_KEY']) response = cc.read_page_transactions transactions = JSON.parse(response.body) puts transactions # { # "success": true, # "pagination": { # "limit": 25, # "order": "desc", # "starting_after": null, # "ending_before": null # }, # "data": [...] # } ``` -------------------------------- ### Read Leverage Positions Source: https://context7.com/coincheckjp/ruby_coincheck_client/llms.txt Retrieves leverage trading positions. Can filter by status (open/closed). ```APIDOC ## GET /api/positions ### Description Retrieves leverage trading positions. Can filter by status (open/closed). ### Method GET ### Endpoint /api/positions ### Query Parameters - **status** (string) - Optional - Filter positions by status ('open' or 'closed'). ### Response #### Success Response (200) - **success** (boolean) - Indicates if the request was successful. - **positions** (array) - A list of leverage position objects. - **id** (integer) - The position ID. - **pair** (string) - The trading pair. - **amount** (string) - The amount of the position. - **rate** (string) - The rate at which the position was opened. - **type** (string) - The type of position ('long' or 'short'). - **unrealized_pl** (string) - The unrealized profit or loss. - **realized_pl** (string) - The realized profit or loss. - **margin** (string) - The margin used for the position. - **open_rate** (string) - The rate at which the position was opened. - **leverage_rate** (string) - The leverage rate applied. - **created_at** (string) - The timestamp when the position was opened. ### Response Example ```json { "success": true, "positions": [ { "id": 123, "pair": "btc_jpy", "amount": "0.01", "rate": "4500000.0", "type": "long", "unrealized_pl": "1000.0", "realized_pl": "0.0", "margin": "10000.0", "open_rate": "4490000.0", "leverage_rate": "5.0", "created_at": "2024-01-01T00:00:00.000Z" } ] } ``` ``` -------------------------------- ### Retrieve transaction history Source: https://context7.com/coincheckjp/ruby_coincheck_client/llms.txt Fetches the history of executed orders. ```ruby require 'ruby_coincheck_client' cc = CoincheckClient.new(ENV['API_KEY'], ENV['SECRET_KEY']) response = cc.read_transactions transactions = JSON.parse(response.body) puts transactions # { # "success": true, # "transactions": [ # { # "id": 123456, # "order_id": 654321, # "created_at": "2024-01-01T00:00:00.000Z", # "funds": {"btc": "0.1", "jpy": "-450000.0"}, # "pair": "btc_jpy", # "rate": "4500000.0", # "fee_currency": "JPY", # "fee": "0.0", # "liquidity": "T", # "side": "buy" # } # ] # } ``` -------------------------------- ### Repay Borrowed Amount Source: https://context7.com/coincheckjp/ruby_coincheck_client/llms.txt Use this to repay a borrowed amount. Requires the borrow ID. ```ruby require 'ruby_coincheck_client' cc = CoincheckClient.new(ENV['API_KEY'], ENV['SECRET_KEY']) response = cc.delete_borrows(id: "58606") result = JSON.parse(response.body) puts result # {"success": true, "id": 58606} ``` -------------------------------- ### Read Deposit Money History Source: https://context7.com/coincheckjp/ruby_coincheck_client/llms.txt Retrieves the history of cryptocurrency deposits, optionally filtered by currency. ```ruby require 'ruby_coincheck_client' cc = CoincheckClient.new(ENV['API_KEY'], ENV['SECRET_KEY']) # Get BTC deposit history (default) response = cc.read_deposit_money deposits = JSON.parse(response.body) # Get ETH deposit history response = cc.read_deposit_money(currency: "ETH") eth_deposits = JSON.parse(response.body) puts deposits ``` -------------------------------- ### Calculate Order Rate Source: https://context7.com/coincheckjp/ruby_coincheck_client/llms.txt Calculates the estimated execution rate for a specified order type and amount. Supports specifying order type, amount, price, and trading pair. ```ruby require 'ruby_coincheck_client' cc = CoincheckClient.new # Calculate rate for buying 0.01 BTC response = cc.read_orders_rate(order_type: 'buy', amount: "0.01") rate_info = JSON.parse(response.body) # Calculate rate for selling at 100000 JPY worth response = cc.read_orders_rate(order_type: 'sell', price: 100000) rate_info = JSON.parse(response.body) # Specify a different trading pair response = cc.read_orders_rate( order_type: 'buy', amount: "1.0", pair: CoincheckClient::Pair::ETH_JPY ) puts rate_info # {"success": true, "rate": "4500000.0", "price": "45000.0", "amount": "0.01"} ``` -------------------------------- ### Read Bank Accounts Source: https://context7.com/coincheckjp/ruby_coincheck_client/llms.txt Retrieves registered bank accounts for fiat withdrawals. ```ruby require 'ruby_coincheck_client' cc = CoincheckClient.new(ENV['API_KEY'], ENV['SECRET_KEY']) response = cc.read_bank_accounts accounts = JSON.parse(response.body) puts accounts ``` -------------------------------- ### Read Send Money History Source: https://context7.com/coincheckjp/ruby_coincheck_client/llms.txt Retrieves the history of cryptocurrency withdrawals, optionally filtered by currency. ```ruby require 'ruby_coincheck_client' cc = CoincheckClient.new(ENV['API_KEY'], ENV['SECRET_KEY']) # Get BTC send history (default) response = cc.read_send_money sends = JSON.parse(response.body) # Get ETH send history response = cc.read_send_money(currency: "ETH") eth_sends = JSON.parse(response.body) puts sends ``` -------------------------------- ### Read Active Borrows Source: https://context7.com/coincheckjp/ruby_coincheck_client/llms.txt Retrieves a list of active borrow matches. No parameters are required. ```ruby require 'ruby_coincheck_client' cc = CoincheckClient.new(ENV['API_KEY'], ENV['SECRET_KEY']) response = cc.read_borrows borrows = JSON.parse(response.body) puts borrows # { # "success": true, # "matches": [ # {"id": 123, "amount": "0.1", "currency": "BTC", "rate": "0.0001", "created_at": "2024-01-01T00:00:00.000Z"} # ] # } ``` -------------------------------- ### Transfer Funds from Leverage Account Source: https://context7.com/coincheckjp/ruby_coincheck_client/llms.txt Transfers funds from your leverage account back to your spot account. Specify amount and optionally currency. ```ruby require 'ruby_coincheck_client' cc = CoincheckClient.new(ENV['API_KEY'], ENV['SECRET_KEY']) # Transfer 1000 JPY from leverage account response = cc.transfer_from_leverage(amount: "1000") result = JSON.parse(response.body) # Transfer with specific currency response = cc.transfer_from_leverage(amount: "1000", currency: "JPY") puts result # {"success": true, "amount": "1000", "currency": "JPY"} ``` -------------------------------- ### POST /api/send_money Source: https://context7.com/coincheckjp/ruby_coincheck_client/llms.txt Sends cryptocurrency to an external wallet address. ```APIDOC ## POST /api/send_money ### Description Initiates a transfer of cryptocurrency to a specified external address. ### Parameters #### Request Body - **address** (string) - Required - The destination wallet address. - **amount** (string) - Required - The amount of cryptocurrency to send. ### Response #### Success Response (200) - **id** (integer) - The ID of the transaction. - **fee** (string) - The transaction fee. #### Response Example { "success": true, "id": 123, "address": "136aHpRdd7...", "amount": "0.0005", "fee": "0.0001" } ``` -------------------------------- ### Transfer Funds to Leverage Account Source: https://context7.com/coincheckjp/ruby_coincheck_client/llms.txt Transfers funds from your spot account to your leverage account. Specify amount and optionally currency. ```ruby require 'ruby_coincheck_client' cc = CoincheckClient.new(ENV['API_KEY'], ENV['SECRET_KEY']) # Transfer 1000 JPY to leverage account response = cc.transfer_to_leverage(amount: "1000") result = JSON.parse(response.body) # Transfer with specific currency response = cc.transfer_to_leverage(amount: "1000", currency: "JPY") puts result # {"success": true, "amount": "1000", "currency": "JPY"} ``` -------------------------------- ### Read Withdrawals Source: https://context7.com/coincheckjp/ruby_coincheck_client/llms.txt Retrieves the history of JPY withdrawals to bank accounts. ```ruby require 'ruby_coincheck_client' cc = CoincheckClient.new(ENV['API_KEY'], ENV['SECRET_KEY']) response = cc.read_withdraws withdraws = JSON.parse(response.body) puts withdraws ``` -------------------------------- ### Read Transactions Source: https://context7.com/coincheckjp/ruby_coincheck_client/llms.txt Retrieves the transaction history for executed orders. ```APIDOC ## GET /api/transactions ### Description Retrieves the transaction history for executed orders. ### Method GET ### Endpoint /api/transactions ### Response #### Success Response (200) - **success** (boolean) - Indicates if the request was successful. - **transactions** (array) - A list of transaction objects. - **id** (integer) - The transaction ID. - **order_id** (integer) - The ID of the associated order. - **created_at** (string) - The timestamp when the transaction was created. - **funds** (object) - The amounts of funds involved in the transaction. - **btc** (string) - The amount of BTC. - **jpy** (string) - The amount of JPY. - **pair** (string) - The trading pair (e.g., "btc_jpy"). - **rate** (string) - The execution rate of the order. - **fee_currency** (string) - The currency in which the fee is denominated. - **fee** (string) - The transaction fee. - **liquidity** (string) - The liquidity indicator ('T' for taker, 'M' for maker). - **side** (string) - The side of the order ('buy' or 'sell'). ### Response Example ```json { "success": true, "transactions": [ { "id": 123456, "order_id": 654321, "created_at": "2024-01-01T00:00:00.000Z", "funds": {"btc": "0.1", "jpy": "-450000.0"}, "pair": "btc_jpy", "rate": "4500000.0", "fee_currency": "JPY", "fee": "0.0", "liquidity": "T", "side": "buy" } ] } ``` ``` -------------------------------- ### Read Paginated Transactions Source: https://context7.com/coincheckjp/ruby_coincheck_client/llms.txt Retrieves paginated transaction history for handling large datasets. ```APIDOC ## GET /api/transactions?pagination=true ### Description Retrieves paginated transaction history for handling large datasets. ### Method GET ### Endpoint /api/transactions ### Query Parameters - **pagination** (boolean) - Required - Set to `true` to enable pagination. ### Response #### Success Response (200) - **success** (boolean) - Indicates if the request was successful. - **pagination** (object) - Pagination details. - **limit** (integer) - The number of items per page. - **order** (string) - The order of transactions (e.g., "desc"). - **starting_after** (null) - Indicates the starting point for the next page (if applicable). - **ending_before** (null) - Indicates the ending point for the previous page (if applicable). - **data** (array) - A list of transaction objects (structure similar to non-paginated transactions). ### Response Example ```json { "success": true, "pagination": { "limit": 25, "order": "desc", "starting_after": null, "ending_before": null }, "data": [] } ``` ``` -------------------------------- ### Delete orders Source: https://context7.com/coincheckjp/ruby_coincheck_client/llms.txt Cancels an existing order using its ID. ```ruby require 'ruby_coincheck_client' cc = CoincheckClient.new(ENV['API_KEY'], ENV['SECRET_KEY']) # Cancel order with ID 2503344 response = cc.delete_orders(id: "2503344") result = JSON.parse(response.body) puts result # {"success": true, "id": 2503344} ``` -------------------------------- ### DELETE /api/exchange/borrows/:id Source: https://context7.com/coincheckjp/ruby_coincheck_client/llms.txt Repays a borrowed amount. ```APIDOC ## DELETE /api/exchange/borrows/:id ### Description Repays a borrowed amount. ### Method DELETE ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the borrow to repay ### Response #### Success Response (200) - **success** (boolean) - Indicates if the request was successful - **id** (integer) - The ID of the repaid borrow ### Response Example { "success": true, "id": 58606 } ``` -------------------------------- ### Delete Bank Account Source: https://context7.com/coincheckjp/ruby_coincheck_client/llms.txt Removes a registered bank account. ```ruby require 'ruby_coincheck_client' cc = CoincheckClient.new(ENV['API_KEY'], ENV['SECRET_KEY']) response = cc.delete_bank_accounts(id: "2222") result = JSON.parse(response.body) puts result ``` -------------------------------- ### Cancel Order Source: https://context7.com/coincheckjp/ruby_coincheck_client/llms.txt Cancels an open order by its ID. ```APIDOC ## DELETE /api/orders/:id ### Description Cancels an open order by its ID. ### Method DELETE ### Endpoint /api/orders/:id ### Path Parameters - **id** (string) - Required - The ID of the order to cancel. ### Response #### Success Response (200) - **success** (boolean) - Indicates if the cancellation was successful. - **id** (integer) - The ID of the canceled order. ### Response Example ```json {"success": true, "id": 2503344} ``` ```