Bitcoin Forum
May 06, 2024, 09:04:25 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: EasyMTGox - simple .NET API-wrapper for MTGox  (Read 1444 times)
ThePok (OP)
Full Member
***
Offline Offline

Activity: 131
Merit: 100


View Profile
July 03, 2011, 03:58:48 PM
 #1

With EasyMTGox you can access MTGox from inside you own .NET Application!

In the Download is a Sampleapplication that shows nearly everything that can be done! (trader.exe)

http://www-user.tu-chemnitz.de/~rimarc/wordpress/easymtgox-simple-net-api-wrapper-to-mtgox/

Its as easy as a Hello World:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EasyMTGoxNS;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(”Lastprice:” + EasyMTGox.GetTickerData().LastPrice.ToString()+”USD/BTC”);
Console.WriteLine(”Input your username”);
string Username = Console.ReadLine();
Console.WriteLine(”Input your Password:”);
string Password = Console.ReadLine();

EasyMTGox EMTGOX = new EasyMTGox(Username, Password);
if (EMTGOX.IsConnectionFine())
{

Balance Balance = EMTGOX.GetBalance();
Console.WriteLine(”You have ” + Balance.BTC + “BTC” + ” and ” + Balance.USD + “USD”);

Console.WriteLine(”How many BTC do you want to buy?”);
string amount = Console.ReadLine();
Console.WriteLine(”Maximum price you want to pay per BTC in USD?”);
string price = Console.ReadLine();
EMTGOX.BuyBTCOrder(amount, price);
}

else
{
Console.WriteLine(”Something went wrong! Check Username Password and Internetconnection!”);
}
Console.ReadLine();
}
}
}

This little Programm shows the Last Price on MTGox and you can send an order to buy BTC!
All the API Functions are included! Get the DepthOfMarket, your open Orders, the Ticker, delet Orders!
Its not Freeware!!! You have to Pay 0.01BTC fee per Trade with a probability. Thats 0.01BTC in any case for 100 and more BTC trades.
If you send an Order over 50BTC you have to pay the fee with probability of 50%. If you trade 1 BTC, you have to pay the Fee with 1% and so on. You never have to pay more than 0.01BTC per order.

There are many Events that get trickert too, so you can write an Eventdriven Programm too. Everything that can be done Wthout an MTGox Account uses static functions.


I know, i have no reputation. But i can tell you, iam Hosting this Programm on the Webspace from my University. So i am not Anonym.

What do you think?
"The nature of Bitcoin is such that once version 0.1 was released, the core design was set in stone for the rest of its lifetime." -- Satoshi
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
saykor
Sr. Member
****
Offline Offline

Activity: 350
Merit: 250


View Profile WWW
July 03, 2011, 04:47:25 PM
 #2

Everyone can host a program on Webspace from his University. This is not a guarantee for trust.

Anyway good job and good luck but personally i not will use your program to pay to you a fee when i can make a transactions directly from their website. Other question is that I will ever use a MTGox. They have a too many hacks in last month.

Let's color the MOON: YP4ZV8yabKGBKG2uNWHQBwrdURkyxqst4D
Before to do business with me you can check my  BitcoinFeedback; ebay and .net developer profile
Maxim Gladkov
Newbie
*
Offline Offline

Activity: 28
Merit: 0



View Profile WWW
July 08, 2011, 03:39:53 PM
 #3

Nice to see .NET developers in here... Don't you want to make a WPF/Silverlight app as example? Tongue
NYConsultant
Newbie
*
Offline Offline

Activity: 21
Merit: 0


View Profile
July 09, 2011, 05:44:23 AM
 #4

Nice to see .NET developers in here... Don't you want to make a WPF/Silverlight app as example? Tongue

+1 on seeing other .NET devs here.

As to the OP, not too sure why people would pay for a wrapper that anyone proficient in C# can write within 30 minutes.

I think the value add would be a Silverlight/WPF frontend as Maxim said
Maxim Gladkov
Newbie
*
Offline Offline

Activity: 28
Merit: 0



View Profile WWW
July 09, 2011, 10:13:44 AM
 #5

Nice to see .NET developers in here... Don't you want to make a WPF/Silverlight app as example? Tongue

+1 on seeing other .NET devs here.

As to the OP, not too sure why people would pay for a wrapper that anyone proficient in C# can write within 30 minutes.

I think the value add would be a Silverlight/WPF frontend as Maxim said

Fully, agree. But I think community don't need new MtGox watcher in .NET... We need normal Client with all necessary watchers and trackers and, of course, sexy UI...
txcoin
Newbie
*
Offline Offline

Activity: 32
Merit: 0


View Profile
July 09, 2011, 04:36:09 PM
 #6

For all the C# devs around here: This is the basic code to use the API as of today.

        public static string GetBalance(string userName, string password)
        {
            // parameters: name1=value1&name2=value2
            var parameters = "name=" + HttpUtility.UrlEncode(userName)
                 + "&pass=" + HttpUtility.UrlEncode(password);

            var req = (HttpWebRequest) WebRequest.Create("https://mtgox.com/code/getFunds.php");

            req.ContentType = "application/x-www-form-urlencoded";
            req.Method = "POST";
            req.UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)";
            req.Accept = "application/json";

            byte[] bytes = Encoding.ASCII.GetBytes(parameters);
            req.ContentLength = bytes.Length;

            Stream os = req.GetRequestStream();
            os.Write(bytes, 0, bytes.Length);
            os.Close();

            WebResponse resp = req.GetResponse();

            try
            {
                var sr = new StreamReader(resp.GetResponseStream());
                return sr.ReadToEnd().Trim();
            }
            catch (Exception ex)
            {
                Logger.Fatal(ex.Message);
                Logger.FatalException(ex.InnerException.ToString(), ex);   
                return null;
            }
        } // end HttpPost


As this may become out of date pretty much any moment, also look out for comments by "SlipperySlope" on how to do it in Java. The only change you have to make is that whenever we writes that he is using HtmlEncoding, in C# the UrlEncoding is needed.


Cheers
txcoin

PS: Thus, no need to run a dubious exe and pay fees to anyone obsfuscating his code without reason. We are a community.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!