BTCTrader / broker-api-docs

The documentation for BTCTrader's white label exchange platform API. Use this documentation to access the APIs of BTCTurk other BTCTrader partners.
110 stars 32 forks source link

https://api.btcturk.com/api/v1/order #161

Closed akrepfatih closed 4 years ago

akrepfatih commented 4 years ago

Aşağıdaki kod ile www.btcturk.com/api/exchange den C# ile alım satım yapabiliyorum. Geçen gün yazdığınız yazıda www.btcturk.com api nin kapatılacağını söylemiştiniz. https://api.btcturk.com/api/v1/order ın Çalşan C# örneğini paylaşabilir misiniz?

public string m_btcturk_emrigir(string s_adres, string s_symbol, string s_precision, string s_alsat, string s_adet_tam, string s_adet_kusurat, string s_fiyat_tam, string s_fiyat_kusurat) { string sonuc;

        using (var client = new HttpClient())
        {
            var unixTimestamp = DateTime.UtcNow.Ticks;
            string message = AnaForm.s_apipublic + unixTimestamp;
            using (HMACSHA256 hmac = new HMACSHA256(Convert.FromBase64String(AnaForm.s_apiprivate)))
            {
                byte[] signatureBytes = hmac.ComputeHash(Encoding.UTF8.GetBytes(message));
                string signature = Convert.ToBase64String(signatureBytes);
                client.DefaultRequestHeaders.Add("X-PCK", AnaForm.s_apipublic);
                client.DefaultRequestHeaders.Add("X-Stamp", unixTimestamp.ToString());
                client.DefaultRequestHeaders.Add("X-Signature", signature);
                client.BaseAddress = new Uri("https://www.btcturk.com/");
            }

            IEnumerable<KeyValuePair<string, string>> gonderilecekler = new List<KeyValuePair<string, string>>()
            {
                new KeyValuePair<string, string>("totalPrecision", "60"),
                new KeyValuePair<string, string>("amount", s_adet_tam),
                new KeyValuePair<string, string>("amountPrecision", s_adet_kusurat),
                new KeyValuePair<string, string>("price", s_fiyat_tam),
                new KeyValuePair<string, string>("pricePrecision", s_fiyat_kusurat),
                new KeyValuePair<string, string>("orderMethod", "0"),
                new KeyValuePair<string, string>("orderType", s_alsat),
                new KeyValuePair<string, string>("triggerPrice", "0"),
                new KeyValuePair<string, string>("triggerPricePrecision", "00"),
                new KeyValuePair<string, string>("DenominatorPrecision", s_precision),
                new KeyValuePair<string, string>("PairSymbol", s_symbol),
            };
            HttpContent sorgu = new FormUrlEncodedContent(gonderilecekler);

            using (var response = client.PostAsync(s_adres, sorgu))
            {
                sonuc = response.Result.Content.ReadAsStringAsync().Result;
            }
        }
        return sonuc;
    }
onurgozupek commented 4 years ago

Çalışan C# kod örneği için https://github.com/BTCTrader/broker-api-csharp-v2 sayfasını ziyaret edebilirsiniz. APIExampleV1 klasöründe appsettings.json dosyasında değişkenleri düzenlemeniz yeterli.

{
    "resourceUrl": "https://api.btcturk.com/api",
    "publicKey": "API_PUBLIC",
    "privateKey": "API_SECRET"

Örneğin içinde kullanbileceğiniz uç noktaları (Emir verme, bakiye sorgulama, emir iptali vs.) yer alıyor.

akrepfatih commented 4 years ago

Teşekkürler.