<blockquote>
  <p>My understand of this statement is that I use my 1.2 Bitcoin to buy
  1.3X1.2 Litecoin. Is this correct?</p>
</blockquote>

<p>The <code>quantity</code> parameter refers to how many of the coin you want to buy, and the <code>rate</code> parameter as to the limit price you want to buy/sell those coins at.  </p>

<p>Example, buy 100 dogecoin at 0.00000400 BTC each.</p>

<pre><code>https://bittrex.com/api/v1.1/market/buylimit?apikey=api_key&amp;market=BTC-DOGE&amp;quantity=100&amp;rate=0.000004&amp;nonce=nonce
</code></pre>

<blockquote>
  <p>If I want to use my Litecoin to buy Bitcoin, do I need to change the
  market from BTC-LTC to LTC-BTC??</p>
</blockquote>

<p>No, the market stays the same, just change part of the URI from <code>/buylimit?</code> to <code>/selllimit?</code> or vice-versa. Selling your litecoin for bitcion is the same as buying bitcoin with litecoin. </p>

<p>You can make it act like a market order by checking the current bid/ask and making your rate equal to the side your trading. For example if you want to market buy you can query the best ask price and then make that the rate.</p>

<pre><code>function fetchPairPrice($pair){
    $pair = strtoupper($pair);
    $uri = "https://bittrex.com/api/v1.1/public/getticker?market=BTC-".$pair;
    $ch = curl_init($uri);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $execResult = curl_exec($ch);
    $obj = json_decode($execResult, true);
    return $obj;
}


function bittrexbuy($apikey, $apisecret, $symbol, $quant, $rate){
    $nonce=time();
    $uri='https://bittrex.com/api/v1.1/market/buylimit?apikey='.$apikey.'&amp;market=BTC-'.$symbol.'&amp;quantity='.$quant.'&amp;rate='.$rate.'&amp;nonce='.$nonce;
    $sign=hash_hmac('sha512',$uri,$apisecret);
    $ch = curl_init($uri);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('apisign:'.$sign));
    $execResult = curl_exec($ch);
    $obj = json_decode($execResult, true);
    return $obj;
}

    $symbolRate = fetchPairPrice("DOGE");
    $fetchPrice = $symbolRate["result"]["Ask"];
    $amountToBuy = 100;
    bittrexbuy($apikey, $apisecret, $symbol, $amountToBuy, $fetchPrice);

    //response
    //{"success":true,"message":"","result":{"uuid":"b5f891ab-a7b4-44aa-9488-94986d1d9551"}}
</code></pre>

CC BY-SA 3.0
2017-12-26T05:01:40.367Z
2017-12-26T05:01:40.367Z
m1xolyd1an
<p>I read the <a href="https://bittrex.com/home/api" rel="nofollow noreferrer">api documentation</a> but I could not find anythin related to market buy and sell commands. Where do I find this information?</p>

<p>Moreover, I read the following from the api site</p>

<p><a href="https://bittrex.com/api/v1.1/market/selllimit?apikey=API_KEY&amp;market=BTC-LTC&amp;quantity=1.2&amp;rate=1.3" rel="nofollow noreferrer">https://bittrex.com/api/v1.1/market/selllimit?apikey=API_KEY&amp;market=BTC-LTC&amp;quantity=1.2&amp;rate=1.3</a>  </p>

<p>My understand of this statement is that I use my 1.2 Bitcoin to buy 1.3X1.2 Litecoin. Is this correct?</p>

<p>If I want to use my Litecoin to buy Bitcoin, do I need to change the market from BTC-LTC to LTC-BTC??</p>

CC BY-SA 3.0
2017-12-26T02:17:04.217Z
I see someone has voted to close this using the "customer relationship" reason. Note that this should be a publicly answerable question about a public API and should not be closed for that reason. C.f. https://bitcoin.meta.stackexchange.com/questions/871/usage-of-the-off-topic-reason-customer-relationship
meshcollider
CC BY-SA 3.0
2017-12-26T03:00:05.273Z
If anyone know about how to use the conditional buy in api, that would help too.
Marco
<api>
Basic bittrex api question
Marco
# Basic bittrex api question

(Asked by: username_0 on 2017-12-25)

I read the [api documentation](https://bittrex.com/home/api) but I could not find anythin related to market buy and sell commands. Where do I find this information?

Moreover, I read the following from the api site

<https://bittrex.com/api/v1.1/market/selllimit?apikey=API_KEY&market=BTC-LTC&quantity=1.2&rate=1.3>

My understand of this statement is that I use my 1.2 Bitcoin to buy 1.3X1.2 Litecoin. Is this correct?

If I want to use my Litecoin to buy Bitcoin, do I need to change the market from BTC-LTC to LTC-BTC??

**Tags:** api

> **Comments:**
> **username_1**: I see someone has voted to close this using the "customer relationship" reason. Note that this should be a publicly answerable question about a public API and should not be closed for that reason. C.f. https://bitcoin.meta.stackexchange.com/questions/871/usage-of-the-off-topic-reason-customer-relationship  
> **username_0**: If anyone know about how to use the conditional buy in api, that would help too.  

---

## 1 answers

### Answer by username_2 on 2017-12-26. Score: 0

> My understand of this statement is that I use my 1.2 Bitcoin to buy
> 1.3X1.2 Litecoin. Is this correct?

The `quantity` parameter refers to how many of the coin you want to buy, and the `rate` parameter as to the limit price you want to buy/sell those coins at.

Example, buy 100 dogecoin at 0.00000400 BTC each.

```
https://bittrex.com/api/v1.1/market/buylimit?apikey=api_key&market=BTC-DOGE&quantity=100&rate=0.000004&nonce=nonce

```

> If I want to use my Litecoin to buy Bitcoin, do I need to change the
> market from BTC-LTC to LTC-BTC??

No, the market stays the same, just change part of the URI from `/buylimit?` to `/selllimit?` or vice-versa. Selling your litecoin for bitcion is the same as buying bitcoin with litecoin.

You can make it act like a market order by checking the current bid/ask and making your rate equal to the side your trading. For example if you want to market buy you can query the best ask price and then make that the rate.

```
function fetchPairPrice($pair){
    $pair = strtoupper($pair);
    $uri = "https://bittrex.com/api/v1.1/public/getticker?market=BTC-".$pair;
    $ch = curl_init($uri);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $execResult = curl_exec($ch);
    $obj = json_decode($execResult, true);
    return $obj;
}

function bittrexbuy($apikey, $apisecret, $symbol, $quant, $rate){
    $nonce=time();
    $uri='https://bittrex.com/api/v1.1/market/buylimit?apikey='.$apikey.'&market=BTC-'.$symbol.'&quantity='.$quant.'&rate='.$rate.'&nonce='.$nonce;
    $sign=hash_hmac('sha512',$uri,$apisecret);
    $ch = curl_init($uri);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('apisign:'.$sign));
    $execResult = curl_exec($ch);
    $obj = json_decode($execResult, true);
    return $obj;
}

    $symbolRate = fetchPairPrice("DOGE");
    $fetchPrice = $symbolRate["result"]["Ask"];
    $amountToBuy = 100;
    bittrexbuy($apikey, $apisecret, $symbol, $amountToBuy, $fetchPrice);

    //response
    //{"success":true,"message":"","result":{"uuid":"b5f891ab-a7b4-44aa-9488-94986d1d9551"}}

```


---

