Author Topic: bitshares Ruby API (Ruby gem)  (Read 3112 times)

0 Members and 1 Guest are viewing this topic.

Offline bulletproof

Update:

Started work on graphene version of the Gem, with websockets too. Got basic ws calls working, so to aid my understanding of why ws is used/preferred, can someone point me at the docs which describe how graphene handles async/statefull API calls - or maybe just provide one or two examples - i.e. where stateless (JSON RPC) API can't be used & why?

Thx

EDIT: Nothing heard as of 9/04, so will focus on JSON RPC only for now
« Last Edit: September 04, 2015, 09:47:48 pm by bulletproof »
Everything is awesome, or if it isn't it ought to be.

Offline roadscape

http://cryptofresh.com  |  witness: roadscape

Offline bulletproof

Done. v0.1.6 - see latest README

Let me know if you still have trouble
Everything is awesome, or if it isn't it ought to be.

Offline roadscape

I keep getting a 'Bad credentials' error..does that refer to RPC or wallet?

I understand these are RPC credentials. Would it be possible to have these be part of the configuration and not globals?
$BITSHARES_ACCOUNT
$BITSHARES_PASSWORD
http://cryptofresh.com  |  witness: roadscape

Offline ebit

  • Committee member
  • Hero Member
  • *
  • Posts: 1905
    • View Profile
  • BitShares: ebit
telegram:ebit521
https://weibo.com/ebiter

Offline bulletproof

2.0 supports (and prefers?) websocket, will you implement with it as well?

Yup, that's the intention.
Everything is awesome, or if it isn't it ought to be.

Offline abit

  • Committee member
  • Hero Member
  • *
  • Posts: 4664
    • View Profile
    • Abit's Hive Blog
  • BitShares: abit
  • GitHub: abitmore
Great! +5%
2.0 supports (and prefers?) websocket, will you implement with it as well?
BitShares committee member: abit
BitShares witness: in.abit

Offline bytemaster

After some experimentation since here, I've now released a Ruby gem for the bitshares client (v0.x). The gem is called bitshares.

Inspiration from & credit to @xeroc's Python API and the web-services Ruby API code

I've used this as an exercise to teach myself how the bitshares client actually works (lots to learn!). At this stage I'd appreciate any feedback on this project so I can judge whether it is worth continuing with the initiative and maintaining the gem. In any case, pointers to the changes in graphene's JSON RPC API, so I can update the code to be 2.0 compatible, would be great. Feature requests/ideas/collaborators all most welcome  :)

Executive summary
  • it is designed to work with < v1.0 CLI client running the RPC server
  • this version detects the running JSON RPC server ports and can thus be integrated into any Ruby/Rails project running the bitshares_client server
  • multiple wallets/accounts are supported with stored passwords - so functions requiring these may be automated
  • the docs list the functionality, which includes automated trading (long-only so far). Here is a flavour:-

Code: [Select]
client = Bitshares::Client.init
Bitshares.configure(:wallet => {'my_wallet' => 'wallet_password'})
wallet = Bitshares::Wallet.new 'my_wallet'
account = wallet.account 'my_account_name'

# a Market object, representing an asset-pair:-
cny_bts = Bitshares::Market.new('CNY', 'BTS')
cny_bts.order_book # gets order book for this market
etc...

# trading in a market from an account
cny_bts_trader = Bitshares::Trader.new(account, cny_bts)
cny_bts_trader.submit_ask(1000, 0.03) # sell order for 1,000 BTS @ 0.03 CNY/BTS
etc...

Great work!   I will throw some brownies your way for this, and hope you do the same for BTS 2.0
For the latest updates checkout my blog: http://bytemaster.bitshares.org
Anything said on these forums does not constitute an intent to create a legal obligation or contract between myself and anyone else.   These are merely my opinions and I reserve the right to change them at any time.

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12922
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc

Offline roadscape

 +5% Awesome.. I'll test it out this week!
http://cryptofresh.com  |  witness: roadscape

Offline bulletproof

After some experimentation since here, I've now released a Ruby gem for the bitshares client (v0.x). The gem is called bitshares.

Inspiration from & credit to @xeroc's Python API and the web-services Ruby API code

I've used this as an exercise to teach myself how the bitshares client actually works (lots to learn!). At this stage I'd appreciate any feedback on this project so I can judge whether it is worth continuing with the initiative and maintaining the gem. In any case, pointers to the changes in graphene's JSON RPC API, so I can update the code to be 2.0 compatible, would be great. Feature requests/ideas/collaborators all most welcome  :)

Executive summary
  • it is designed to work with < v1.0 CLI client running the RPC server
  • this version detects the running JSON RPC server ports and can thus be integrated into any Ruby/Rails project running the bitshares_client server
  • multiple wallets/accounts are supported with stored passwords - so functions requiring these may be automated
  • the docs list the functionality, which includes automated trading (long-only so far). Here is a flavour:-

Code: [Select]
client = Bitshares::Client.init
Bitshares.configure(:wallet => {'my_wallet' => 'wallet_password'})
wallet = Bitshares::Wallet.new 'my_wallet'
account = wallet.account 'my_account_name'

# a Market object, representing an asset-pair:-
cny_bts = Bitshares::Market.new('CNY', 'BTS')
cny_bts.order_book # gets order book for this market
etc...

# trading in a market from an account
cny_bts_trader = Bitshares::Trader.new(account, cny_bts)
cny_bts_trader.submit_ask(1000, 0.03) # sell order for 1,000 BTS @ 0.03 CNY/BTS
etc...
Everything is awesome, or if it isn't it ought to be.