cryptopia_api v0.2.1 CryptopiaApi.Private View Source

Private API for Cryptopia

Link to this section Summary

Functions

Cancels a single order

Cancels a single order, all orders for a tradepair or all open orders

Get list of all currencies on account

Load balance only for given currency name or id

Creates or returns a deposit address for the specified currency

Returns a list of open orders for all tradepairs or specified tradepair

Same as get_open_orders/1 but 2nd parameter is amount of orders to return

Returns a list of trade history for all tradepairs or specified tradepair

Returns a list of trade history for all tradepairs or specified tradepair with amount of records returned

Returns a list of transactions

Submits a tip to the Trollbox

Submits a transfer request

Submits a transfer request

Link to this section Functions

Link to this function cancel_trade(order_id) View Source
cancel_trade(number) :: {:ok, [number]} | {:error, any}

Cancels a single order

Example

iex(4)> CryptopiaApi.Private.cancel_trade(67731009)
{:ok, [67731009]}
Link to this function cancel_trade(type, pair_id) View Source
cancel_trade(String.t, number) ::
  {:ok, [number]} |
  {:error, any}

Cancels a single order, all orders for a tradepair or all open orders

Type might be one of this:

  • “All” - Cancel all open orders
  • “TradePair” - Cancel order for given trade pair
iex(5)> CryptopiaApi.Private.cancel_trade("All", 100)
{:ok, [65929994, 65930065, 65930124, 65930482, 67556018, 67538785]}

iex(6)> CryptopiaApi.Private.cancel_trade("TradePair", 100)
{:ok, [65929994, 65930065]}
Link to this function get_balance() View Source
get_balance() :: {:ok, [any]} | {:error, any}

Get list of all currencies on account

Example

iex(51)> CryptopiaApi.Private.get_balance
{:ok,
  [%{Address: nil, Available: 0.0, BaseAddress: nil, CurrencyId: 331,
    HeldForTrades: 0.0, PendingWithdraw: 0.0, Status: "OK", StatusMessage: nil,
    Symbol: "1337", Total: 0.0, Unconfirmed: 0.0},
   ...]}
Link to this function get_balance(currencyId) View Source
get_balance(number) :: {:ok, [any]} | {:error, any}
get_balance(String.t) :: {:ok, [any]} | {:error, any}

Load balance only for given currency name or id

Example

iex(1)> CryptopiaApi.Private.get_balance("BTC")
{:ok,
  [%{Address: nil, Available: 7.7355e-4, BaseAddress: nil, CurrencyId: 1,
    HeldForTrades: 0.0, PendingWithdraw: 0.0, Status: "OK", StatusMessage: nil,
    Symbol: "BTC", Total: 7.7355e-4, Unconfirmed: 0.0}]}
Link to this function get_deposit_address(currencyId) View Source
get_deposit_address(number) :: {:ok, map} | {:error, any}
get_deposit_address(String.t) :: {:ok, map} | {:error, any}

Creates or returns a deposit address for the specified currency

Example:

iex(1)> CryptopiaApi.Private.get_deposit_address("BTC")
{:ok,
  %{Address: "1KUNsASBLTWfxStANiUEiTWktWvWhgUzqo", BaseAddress: nil,
    Currency: "BTC"}}
Link to this function get_open_orders(market) View Source
get_open_orders(String.t | number) ::
  {:ok, [any]} |
  {:error, any}

Returns a list of open orders for all tradepairs or specified tradepair

Example

iex(10)> CryptopiaApi.Private.get_open_orders("ACC/BTC")
{:ok,
  [%{Amount: 7.26568176, Market: "ACC/BTC", OrderId: 65930482, Rate: 1.023e-4,
    Remaining: 7.26568176, TimeStamp: "2017-08-25T21:33:25.3199485",
    Total: 7.4328e-4, TradePairId: 5331, Type: "Sell"}]}
Link to this function get_open_orders(market, count) View Source
get_open_orders(String.t | number, number) ::
  {:ok, [any]} |
  {:error, any}

Same as get_open_orders/1 but 2nd parameter is amount of orders to return

Link to this function get_trade_history(market) View Source
get_trade_history(String.t | number) ::
  {:ok, [any]} |
  {:error, any}

Returns a list of trade history for all tradepairs or specified tradepair

Example

iex(1)> CryptopiaApi.Private.get_trade_history("ACC/BTC")
{:ok,
  [%{Amount: 723.30610462, Fee: 1.33e-6, Market: "NAMO/BTC", Rate: 9.2e-7,
    TimeStamp: "2017-08-28T12:14:31.8680187", Total: 6.6544e-4,
    TradeId: 15757416, TradePairId: 5405, Type: "Buy"},
   %{Amount: 500.0, Fee: 8.6e-7, Market: "NAMO/BTC", Rate: 8.6e-7,
     TimeStamp: "2017-08-28T12:12:09.4043842", Total: 4.3e-4, TradeId: 15757174,
     TradePairId: 5405, Type: "Sell"},
   %{Amount: 500.0, Fee: 6.2e-7, Market: "NAMO/BTC", Rate: 6.2e-7,
     TimeStamp: "2017-08-28T08:37:22.5063473", Total: 3.1e-4, TradeId: 15745534,
     TradePairId: 5405, Type: "Buy"},
   %{Amount: 7.26568176, Fee: 6.7e-7, Market: "ACC/BTC", Rate: 4.586e-5,
     TimeStamp: "2017-08-25T21:19:47.3708483", Total: 3.332e-4,
     TradeId: 15573801, TradePairId: 5331, Type: "Buy"},
   %{Amount: 93.07663016, Fee: 1.16e-6, Market: "OX/BTC", Rate: 6.24e-6,
     TimeStamp: "2017-08-25T20:31:38.4157247", Total: 5.808e-4,
     TradeId: 15571756, TradePairId: 5399, Type: "Buy"}]}
Link to this function get_trade_history(market, count) View Source
get_trade_history(String.t | number, number) ::
  {:ok, [any]} |
  {:error, any}

Returns a list of trade history for all tradepairs or specified tradepair with amount of records returned

Example

iex(1)> CryptopiaApi.Private.get_trade_history("ACC/BTC", 1)
{:ok,
  [%{Amount: 723.30610462, Fee: 1.33e-6, Market: "NAMO/BTC", Rate: 9.2e-7,
    TimeStamp: "2017-08-28T12:14:31.8680187", Total: 6.6544e-4,
    TradeId: 15757416, TradePairId: 5405, Type: "Buy"}]}
Link to this function get_transactions(type, count \\ 100) View Source

Returns a list of transactions

Type could be “Deposit” or “Withdraw”

Example

iex(1)> CryptopiaApi.Private.get_transactions("Deposit")
{:ok,
  [%{Address: nil, Amount: 0.002, Confirmations: 2, Currency: "BTC", Fee: 0.0,
    Id: 9515790, Status: "Confirmed", Timestamp: "2017-08-25T15:21:15",
    TxId: "1a6c1eddb4420eab6e847873104d21b0bc42f147737fa29f2f2b6598ccb5e619",
    Type: "Deposit"}]}
Link to this function submit_tip(currency, users, amount) View Source
submit_tip(number, 2..100, number) ::
  {:ok, String.t} |
  {:error, any}
submit_tip(String.t, 2..100, number) ::
  {:ok, String.t} |
  {:error, any}

Submits a tip to the Trollbox

Example

iex(4)> CryptopiaApi.Private.submit_tip("BTC", 45, 0.00034500)
{:ok, "You tipped 45 users 0.00034500 BTC each."}
Link to this function submit_trade(market, type, rate, amount) View Source
submit_trade(number, String.t, number, number) ::
  {:ok, [any]} |
  {:error, any}
submit_trade(String.t, String.t, number, number) ::
  {:ok, [any]} |
  {:error, any}

Submits a transfer request

Type should be “Buy” or “Sell”

Example

iex(1)> CryptopiaApi.Private.submit_trade("ACC/BTC", "Buy", 0.00000250, 100)
{:ok, %{FilledOrders: [], OrderId: 67731009}}
Link to this function submit_transfer(currency, username, amount) View Source
submit_transfer(number, String.t, number) ::
  {:ok, String.t} |
  {:error, any}
submit_transfer(String.t, String.t, number) ::
  {:ok, String.t} |
  {:error, any}

Submits a transfer request

##Example

iex(6)> CryptopiaApi.Private.submit_transfer("BTC", "kosss", 100)
{:ok, "Successfully transfered 100 BTC to Kosss"}
Link to this function submit_withdraw(currency, address, payment_id, amount) View Source
submit_withdraw(number, String.t, String.t | number, number) ::
  {:ok, number} |
  {:error, any}
submit_withdraw(String.t, String.t, String.t | number, number) ::
  {:ok, number} |
  {:error, any}

Submits a withdrawal request

Example

iex(6)> CryptopiaApi.Private.submit_withdraw("BTC", "1a6c1eddb4420eab6e847873104d21b0bc42f147737fa29f2f2b6598ccb5e619", "random-payment_id", 12)
{:ok, 405667}