Bitso 0.1.1

Bitso 0.1.1

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Jun 2016

Maintained by Mario Romero Zavala.



 
Depends on:
AFNetworking>= 0
Mantle>= 0
 

Bitso 0.1.1

  • By
  • Mario Romero

Bitso Credentials

From a terminal:

  • cd directory
  • Pod install
  • export CLIENT_ID=YOUR_CLIENT_ID
  • export API_KEY=YOUR_API_KEY
  • export API_SECRET=YOUR_API_SECRET
  • open -a xcode
  • From Xcode, open Bitso.xcworkspace

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

Bitso is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "Bitso"

API Usage

BitsoAPI *bitsoAPI = [BitsoAPI APIWithClientID:CLIENT_ID APIKey:API_KEY APISecret:API_SECRET];

Public Endpoints

Ticker

[bitsoAPI getTickerForBook:@"btc_mxn" successBlock:^(BTSTickerModel *ticker) {
    NSLog(@"Last Price:%@", [ticker.last stringValue])
  } failureBlock:^(NSError *error) {
    NSLog(@"Error: %@ %@", error, [error userInfo]);
}];

Transactions

[bitsoAPI getTransactionsFromBook:@"btc_mxn" forTimeRange:@"hour" successBlock:^(NSArray *trades) {
    for (BitsoTrade* trade in trades) {
      NSLog(@"amount:%@, side:%@, price:%@", [trade.amount stringValue], trade.side, [trade.price stringValue]);
    }
  } failureBlock:^(NSError *error) {
    NSLog(@"Error: %@ %@", error, [error userInfo]);
}];

Order Book

[bitsoAPI getOrderBook:@"btc_mxn" withGrouping:YES successBlock:^(BTSOrderBookModel *orderbook) {
    for (NSArray *ask in orderbook.asks) {
      NSLog(@"%@ @ %@", [ask[1] stringValue], [ask[0] stringValue]);
    }
  } failureBlock:^(NSError *error) {
    NSLog(@"Error: %@ %@", error, [error userInfo]);
}];

Private Endpoints

Balance

[bitsoAPI getBalanceWithSuccessBlock:^(BTSBalanceModel *balance) {
    NSLog(@"BTC balance:%@", [balance.btc_balance stringValue]);
  } failureBlock:^(NSError *error) {
    NSLog(@"Error: %@ %@", error, [error userInfo]);
}];

User Transactions

[bitsoAPI getUserTransactionsFromBook:@"btc_mxn" offset:nil limit:nil sort:nil successBlock:^(NSArray *utxs) {
    for (BitsoUserTransaction* transaction in utxs) {
      NSLog(@"datetime:%@", [transaction.datetime stringValue]);
    }
  } failureBlock:^(NSError *error) {
    NSLog(@"Error: %@ %@", error, [error userInfo]);
}];

Open Orders

[bitsoAPI getOpenOrdersFromBook:@"btc_mxn" successBlock:^(NSArray *orders) {
    for (BTSOrderModel *order in orders) {
      NSLog(@"oid:%@", transaction.oid);
    }
  } failureBlock:^(NSError *error) {
      NSLog(@"Error: %@ %@", error, [error userInfo]);
}];

 Lookup Order

[bitsoAPI lookupOrderWithOrderID:ORDER_ID successBlock:^(BTSOrderModel *order) {
    NSLog(@"price:%@, amount:%@", [order.price stringValue], [order.amount stringValue]);
} failureBlock:^(NSError *error) {
    NSLog(@"Error: %@ %@", error, [error userInfo]);
}];

 Cancel Order

[bitsoAPI  cancelOrderWithOrderID:ORDER_ID successBlock:^(NSString *response) {
    NSLog(@"%@", response);
} failureBlock:^(NSError *error) {
    NSLog(@"Error: %@ %@", error, [error userInfo]);
}];

Place Buy Order

[bitsoAPI  placeBuyOrderInBook:BOOK
                        amount:AMOUNT
                         price:PRICE
                  successBlock:^(BTSOrderModel *order) {
      NSLog(@"price:%@, amount:%@", [order.price stringValue], [order.amount stringValue]);
} failureBlock:^(NSError *error) {
      NSLog(@"Error: %@ %@", error, [error userInfo]);
}];

Place Sell Order

[bitsoAPI  placeSellOrderInBook:BOOK
                         amount:AMOUNT
                          price:PRICE
                   successBlock:^(BTSOrderModel *order) {
      NSLog(@"price:%@, amount:%@", [order.price stringValue], [order.amount stringValue]);
} failureBlock:^(NSError *error) {
      NSLog(@"Error: %@ %@", error, [error userInfo]);
}];

Get Bitcoin deposit address

[bitsoAPI getBitcoinDepositAddressWithSuccessBlock:^(NSString *response) {
    NSLog("%@", response);
} failureBlock:^(NSError *error) {
    NSLog(@"Error: %@ %@", error, [error userInfo]);
}];

Bitcoin withdrawal

[bitsoAPI bitcoinWithdrawalToAddress:ADDRESS amount:AMOUNT successBlock:^(NSString *response) {
    NSLog("%@", response);
} failureBlock:^(NSError *error) {
    NSLog(@"Error: %@ %@", error, [error userInfo]);
}];

Ripple withdrawal

[bitsoAPI rippleWithdrawalOfCurrency:CURRENCY toAddress:ADDRESS amount:AMOUNT successBlock:^(NSString *response) {
    NSLog("%@", response);
} failureBlock:^(NSError *error) {
    NSLog(@"Error: %@ %@", error, [error userInfo]);
}];

Bank withdrawal

[bitsoAPI bankWithdrawalForAmount:AMOUNT recipientGivenNames:GIVEN_NAMES familyNames:FAMILY_NAMES clabe:CLABE_SPEI notesRef:@"" numericRef:@"" successBlock:^(NSString *response) {
    NSLog("%@", response);
} failureBlock:^(NSError *error) {
    NSLog(@"Error: %@ %@", error, [error userInfo]);
}];

Author

Mario Romero, [email protected]

Copyright © 2016 Bitso SAPI de CV. All rights reserved.

License

Bitso is available under the MIT license. See the LICENSE file for more info.