MexbtClient 0.0.1

MexbtClient 0.0.1

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Aug 2015

Maintained by Ricardo Alves.



Objective C client library for the meXBT exchange API

Usage

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

Public API

[MexbtClient productPairs];
[MexbtClient ticker:@"BTCMXN"];
[MexbtClient trades:@"BTCMXN" startIndex:-1 count:20];
[MexbtClient tradesByDate:@"BTCMXN" startDate:1416530012 endDate:1416559390];
[MexbtClient orderBook:@"BTCMXN"];

Private API

MexbtClient *client = [[MexbtClient alloc] init];
client.privateKey = @"<YOUR PRIVATE KEY>";
client.publicKey  = @"<YOUR PUBLIC  KEY>";
client.userId     = @"<YOUR USER ID / EMAIL";
client.isSandbox  = YES;

[client createMarketOrder:@"BTCUSD" side:@"buy" qty:@1.0 px:@342.99];
[client createLimitOrder:@"BTCUSD"  side:@"buy" qty:@1.0 px:@342.99];

NSDictionary *order = [client createOrder:@"BTCUSD" side:@"buy" orderType:0 qty:@1.0 px:@342.99];
NSInteger orderId = [order[@"serverOrderId"] integerValue];

[client modifyOrder:@"BTCUSD"    serverOrderId:orderId modifyAction:1];
[client moveOrderToTop:@"BTCUSD" serverOrderId:orderId];
[client executeOrder:@"BTCUSD"   serverOrderId:orderId];

[client cancelOrder:@"BTCUSD" serverOrderId:orderId];
[client cancelAll:@"BTCUSD"];

[client accountInfo];
[client balance];
[client accountTrades:@"BTCUSD" startIndex:-1 count:20];
[client orders];
[client depositAddresses];
[client depositAddress:@"BTC"]
[client withdraw:@"BTC" amount:@1.123456 sendToAddress:@"address"];

Requirements

Installation

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

pod "MexbtClient"
pod "IGDigest", "~> 1.1"

Important Notes

  1. All functions return (NSDictionary *) except for depositAddress which returns (NSString *).
  2. All functions return nil when meXBT API returns with HTTP status code other than 200 or returns non-json or empty response.
  3. Unfortunately, for some implementation details boolean json values (e.g: true, false) are stored as (NSNumber *) using 0 for false and 1 for true. So if if you want to get the BOOL of an (NSNumber *) x, you would use [x boolValue]
  4. All functions assume that meXBT API will respond with the expected format as specified in meXBT APIs documentation: 1)Public API. 2)Private API, otherwise some exceptions will be thrown; please, keep that in mind when you find some unexpcted behavior in your code.

Development

For convenience you can install the lib in any XCode from the Github repo directly.

This only makes sense when you are working on the lib not when your are using it, in which case you should do as specified in Installation section above.

You can do that by adding the following to Podfile.

pod 'MexbtClient', :git => 'https://github.com/Ahimta/mexbt-objective-c.git'
pod 'IGDigest', '~> 1.1'
git clone https://github.com/Ahimta/mexbt-objective-c.git
cd mexbt-objective-c/Example
pod install

Then open mexbt-objective-c/Example/MexbtClient.xcworkspace in XCode.

The library consists primarily of three files (the rest is mostly generated by CocoaPods):

  1. mexbt-objective-c/Pod/Classes/MexbtClient.h
  2. mexbt-objective-c/Pod/Classes/MexbtClient.m
  3. mexbt-objective-c/Example/Tests/Tests.m

Author

Abdullah Alansari, [email protected]

License

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