Bitcoin Forum

Other => Beginners & Help => Topic started by: solomon on March 03, 2013, 01:35:02 AM



Title: learning mtgox API
Post by: solomon on March 03, 2013, 01:35:02 AM
Hi i am trying to learn how to use the mtgox api but am struggling with some things.

I have managed to make some basic api calls, but am unsure how to pass parameters when it is necessary.


for example to submit an order the wiki says:

###
Submit an order

https://mtgox.com/api/1/BTCUSD/private/order/add

parameters:

    type (bid|ask) (easier to remember: bid == buy, ask == sell)
    amount_int <amount as int>
    price_int <price as int> (can be omitted to place market order)

submits an order and returns the OID and info about success or error
###


I tried:

https://mtgox.com/api/1/BTCUSD/private/order/add?type=ask?amount_int=100000000?price_int=2500000

But im just getting error:

"Invalid parameter "type" (should be ask or bid)"


(Also in INT is 100000000 = 1BTC?)


Title: Re: learning mtgox API
Post by: bitspill on March 03, 2013, 06:13:35 AM
I don't personally have much experience with the mtgox api however I do see that your url's are wrong. Rather than ?'s between parameters you must use an &

As such:

https://mtgox.com/api/1/BTCUSD/private/order/add?type=ask&amount_int=100000000&price_int=2500000


Title: Re: learning mtgox API
Post by: solomon on March 03, 2013, 11:24:10 AM
OK thanks. I figured i'd have some of the syntax wrong.

It's frustrating that there's so little information available, and the wiki gives details but no examples of how to pass multiple variables. I can learn but i need examples!  ;D

I'm still getting the error, maybe i will post to dev forum, i thought it was too basic tbh.


Title: Re: learning mtgox API
Post by: boristheblade on March 03, 2013, 11:34:39 AM
that's, funny. I'm having the exact same problem right now. let me know if you get anywhere with it.


Title: Re: learning mtgox API
Post by: kokjo on March 03, 2013, 11:38:29 AM
https://en.bitcoin.it/wiki/MtGox/API/HTTP


Title: Re: learning mtgox API
Post by: solomon on March 03, 2013, 12:31:38 PM
OK i figured out how to do it, someone should update the wiki


that's, funny. I'm having the exact same problem right now. let me know if you get anywhere with it.


I'm using php so a market order for .v1 would be the same as the example shown here (https://en.bitcoin.it/wiki/MtGox/API/HTTP) except instead of:

var_dump(mtgox_query('0/buyBTC.php', array('amount' => 1, 'price' => 15)));

it would be something like

var_dump(mtgox_query('1/BTCUSD/private/order/add', array('type' => 'bid', 'amount_int' => 100000000, "price_int" => 1500000) ) );


Title: Re: learning mtgox API
Post by: boristheblade on March 03, 2013, 07:43:34 PM
I'm using java. What does the actual final url look like?


Title: Re: learning mtgox API
Post by: bitmango on March 27, 2013, 11:39:05 AM
Hi,

I'm trying to extract the amount of cash I have in my wallet and put it into a variable.

I'm using :
Code:
var_export(mtgox_query('1/generic/private/info'), true);

Which captures information, but I can't for the life of me work out how to separate the resulting arrays into variables. Can anyone help?

i.e. I want:
Code:
array (
  'result' => 'success',
  'return' =>
  array (
'USD' =>
     array (
        'Balance' =>
        array (
          'value' => '0.00',
        ),

to become:
Code:
$wallet_cash_balance = 'Balance'

Can anyone educate me???

The main problem that i'm having is that there are multiple arrays embedded, and so I can't find any useful php code examples online.


Title: Re: learning mtgox API
Post by: kokjo on March 27, 2013, 04:49:29 PM
http://lmgtfy.com/?q=nested+array+php


Title: Re: learning mtgox API
Post by: kiolo on March 28, 2013, 07:13:35 AM
this is best for me: http://www.mediafire.com/?rtn3yepl5lxtnvx


Title: Re: learning mtgox API
Post by: bombartier357 on March 28, 2013, 09:38:15 PM
Shoot me a PM and I will send you some of my code that I use.  I am at work right now and therefore do not have access to my code.

I currently have 14 bots running that trade bitcoin based on different parameters.  So I do have quite a bit of experience with this.

I would be happy to walk you through it.


Title: Re: learning mtgox API
Post by: happygeorge on March 30, 2013, 05:21:27 PM
Is there a really simple "excel" - style api handling program, or is it all raw C or Python or what is everybody doing to do this?

Where do I get started with an easy API programing BOT creation tool?


Title: Re: learning mtgox API
Post by: dkstar on May 07, 2013, 02:08:00 AM
I am also having a problem trying to pass my parameters as such

https://mtgox.com/api/1/BTCUSD/private/order/add?type=ask&amount_int=100000000&price_int=2500000

I am using python, does anyone know what the solution here is?

Thanks


Title: Re: learning mtgox API
Post by: maverick1337 on May 07, 2013, 03:04:28 AM
I have a question, is there anyway to have a bot send out a notification when the EMA lines cross? I'm sure you guys are initiating buys and sells via EMA (maybe not) but if you are, could you just have it send a notification without trading at all? I know you spend a lot of time and effort in your code but if someone has this functionality, I would greatly appreciate it. You can even delete all the rest of the code, I would just want to be notified when the EMA lines cross. Thanks.


Title: Re: learning mtgox API
Post by: anyroll on May 07, 2013, 03:56:28 AM
I have a question, is there anyway to have a bot send out a notification when the EMA lines cross? I'm sure you guys are initiating buys and sells via EMA (maybe not) but if you are, could you just have it send a notification without trading at all? I know you spend a lot of time and effort in your code but if someone has this functionality, I would greatly appreciate it. You can even delete all the rest of the code, I would just want to be notified when the EMA lines cross. Thanks.
+1


Title: Re: learning mtgox API
Post by: kokjo on May 07, 2013, 05:04:31 PM
I am also having a problem trying to pass my parameters as such

https://mtgox.com/api/1/BTCUSD/private/order/add?type=ask&amount_int=100000000&price_int=2500000

I am using python, does anyone know what the solution here is?

Thanks
yup! RTFM!


Title: Re: learning mtgox API
Post by: dkstar on May 09, 2013, 11:35:44 AM
Geeze, whats the point of having a "newbie" forum...  There is a lot of documentation to go through and it takes those of us with smaller programming vocabularies a lot to get through it all. I solved my problem, so for anyone else having the same issue I read the "FM"...

here is some good background on the request module and has a specific section on passing parameter in a url with a keyword argument.  You then need to urlencode your parameters.
 
http://docs.python-requests.org/en/latest/index.html



Title: Re: learning mtgox API
Post by: WarlockTheGrait on May 30, 2013, 09:58:35 PM
hi everyone. sorry for poor english. i'm trying to move to 1st API vers. our clien(Java). when i'm trying to submint an order with params
type - bid
amount_int - 10000000
price_int - 2500000000
server returns "" string
how i can see magicnumber thats server uses to divide by amount and price is 10^6 (i tryed 10^4 too - in result was "too low amount")
can u help?