BitShares Forum

Main => Technical Support => Topic started by: EkremH on November 26, 2014, 04:08:35 pm

Title: Wallet API acess
Post by: EkremH on November 26, 2014, 04:08:35 pm
I wanna play around with wallet API. To install I followed the instruction from 'github.com/BitShares/web_wallet' and I cannot find this directory '/bitshares_toolkit/programs/client/RelWithDebInfo' (the folder 'RelWithDebInfo' doesn't exist in my bitshares toolkit insalled in my machine using these instructions). Does anyone have any idea if the folder is changed (if I am doing right)? Or, may anyone give me any idea how to access the wallet API? I'll appreciate your help!
Title: Re: Wallet API acess
Post by: svk on November 26, 2014, 05:38:49 pm
I'm not sure what you mean by wallet API. The web_wallet is simply the html/javascript code for the wallet, you can use it to run a wallet as a web server on your local machine. The RPC API of the wallet is run from the client, by launching it with:

Code: [Select]
bitshares_client --server
You'll need to setup the config.json file in the .Bitshares folder in order to set the password and login name.

If you explain what you're trying to more precisely we can probably help you better.
Title: Re: Wallet API acess
Post by: xeroc on November 26, 2014, 07:48:35 pm
An example for the use of the RPC interface with python:
https://github.com/xeroc/pytshares/blob/master/btsrpcapi.py

Also related thread:
https://bitsharestalk.org/index.php?topic=5562.0;all
Title: Re: Wallet API acess
Post by: EkremH on December 01, 2014, 03:41:54 pm
Ok, I'll try to explain. I wanna show for example any data from my bitshares wallet in my app. To do this, is there any public API or I have to install the bitshares tookit?
Title: Re: Wallet API acess
Post by: pc on December 01, 2014, 04:08:43 pm
Ok, I'll try to explain. I wanna show for example any data from my bitshares wallet in my app. To do this, is there any public API or I have to install the bitshares tookit?

These guys are creating a "public" API for their mobile wallet: https://bitsharestalk.org/index.php?topic=11902.0
Title: Re: Wallet API acess
Post by: xeroc on December 01, 2014, 05:46:32 pm
maybe someday bitsharesblocks.com will have a documented API
Title: Re: Wallet API acess
Post by: EkremH on December 04, 2014, 12:56:54 pm
I've followed the instructions form Bitshares GUI (web wallet). I wanna start a client and access the RCP json. My config file looks like this:
  "rpc": {
    "enable": true,
    "rpc_user": "test",
    "rpc_password": "test",
    "rpc_endpoint": "127.0.0.1:0",
    "httpd_endpoint": "127.0.0.1:0",
    "htdocs": "./htdocs"
  }
and so on.

I start the client with this command: ./bitshares_client --server / --rpcuser=test --rpcpassword=test /  --httpdendpoint=127.0.0.1:5000.

 And I get this result at console:

Loading blockchain from: /home/ekrem/.BitShares/chain
Loading config from file: /home/ekrem/.BitShares/config.json
Starting JSON RPC server on port 48449 (localhost only)
Starting HTTP JSON RPC server on port 5000 (localhost only)
Attempting to map P2P port 1776 with UPNP...
Listening for P2P connections on port 1776
Adding peer 54.77.51.177:1776 to peer database
Adding peer 104.131.35.149:1776 to peer database
Adding peer 106.185.26.162:1776 to peer database
Adding peer 178.62.50.61:1779 to peer database
Adding peer 178.62.50.61:1778 to peer database
Adding peer 178.62.157.161:1776 to peer database
Adding peer 180.153.142.120:1777 to peer database
Adding peer 5.101.106.138:1777 to peer database
Adding peer 61.129.33.213:1776 to peer database
Adding peer 95.85.33.16:8764 to peer database
Adding peer 46.226.109.66:1776 to peer database
Adding peer 84.238.140.192:42577 to peer database
Adding peer 188.226.195.137:60696 to peer database
Adding peer 5.101.106.138:1778 to peer database
Adding peer 5.101.106.138:1776 to peer database
Adding peer 178.62.50.61:1776 to peer database
Adding peer 54.79.27.224:1776 to peer database
Adding peer 185.25.22.21:1776 to peer database
Adding peer 178.62.50.61:1777 to peer database
Adding peer 85.214.53.224:1776 to peer database
--- there are now 8 active connections to the p2p network
--- syncing with p2p network, 4861 blocks left to fetch
--- syncing with p2p network, our last block is 10 hours old
--- currently syncing at 48 blocks/sec, 70 seconds remaining
--- in sync with p2p network
--- there are now 6 active connections to the p2p network
(wallet closed)

When I go to localhost:5000, it show me a dialog windows that requires username and password (A username and password are beeing required by localhost:5000. This site says "bts wallet"). I've wrote username: test and password: test, like in my config.json file and the command I started bitshares_client, and the result I've get is "Invalid RPC Request".

Does anyone have the idea how to solve this?
Title: Re: Wallet API acess
Post by: xeroc on December 04, 2014, 01:54:25 pm
You nees to post a request .. you cannot just load the page in the browser... search the forum for "curl" to find a working example
Title: Re: Wallet API acess
Post by: toast on December 04, 2014, 04:27:21 pm
You CAN just load the page in a browser, if you're trying to access the wallet GUI. In that case you need to make "htdocs" point to "web_wallet/generated" after you run "lineman build".

If you're trying to do direct API access then you need to POST to /rpc
Title: Re: Wallet API acess
Post by: EkremH on December 05, 2014, 02:47:00 pm
I think you helped me. I tried with curl and I get result. But do you have any simple example with angular.js ore node.js how to access directly ? It would help me too much
Title: Re: Wallet API acess
Post by: xeroc on December 05, 2014, 05:09:44 pm
Take a look at this:
https://bitsharestalk.org/index.php?topic=5562.0;all
Title: Re: Wallet API acess
Post by: EkremH on December 05, 2014, 05:57:22 pm
I've tried some examples accessing bitshres_client started at port 5000 for example, but now it looks I have problems with cross origin allowed. Does anyone have any idea ?
Title: Re: Wallet API acess
Post by: valzav on December 05, 2014, 06:39:07 pm
I've tried some examples accessing bitshres_client started at port 5000 for example, but now it looks I have problems with cross origin allowed. Does anyone have any idea ?
Looks like you are using JS to access bitshares_client.  Take a look at https://github.com/BitShares/web_wallet - it's a good example of JS application communticating with with the wallet.