<p>Current versions of Abe support the getdifficulty API call.  For instance, <a href="http://yacexplorer.tk/chain/Yacoin/q/getdifficulty" rel="nofollow">http://yacexplorer.tk/chain/Yacoin/q/getdifficulty</a> returns the current Yacoin difficulty.  The problem with Litecoin is that both explorer.litecoin.net and litecoinscout.com are running outdated versions of Abe.</p>

<p>For these older versions of Abe, difficulty at the time a block is solved is available; it should usually be close enough to the current difficulty.  Here's an alternate approach I implemented to get Litecoin difficulty:</p>

<ol>
<li>get the blockchain height (/chain/name/q/getblockcount)</li>
<li>get block info (/search?q=blocknum)</li>
<li>get difficulty</li>
</ol>

<p>Step 2 returns HTML which you'll have to scrape. Here's some C# I knocked together:</p>

<pre><code>private double GetDifficultyAbeAlt(string url_prefix, string chain_name)
{
    WebClient wc = new WebClient();
    int blockcount = Convert.ToInt32(wc.DownloadString(url_prefix + "/chain/" + chain_name + "/q/getblockcount"));
    string blockinfo = wc.DownloadString(url_prefix + "/search?q=" + blockcount.ToString());
    double difficulty = 0;
    foreach (string line in blockinfo.Split(new char[] { '\n' }))
        if (line.Contains("Difficulty") &amp;&amp; !line.Contains("Cumulative"))
            difficulty = Convert.ToDouble(line.Split(new char[] { ' ' })[1]);
    return difficulty;
}
</code></pre>

<p>For the block reward, this is the approach I took that should work with any version of Abe:</p>

<ol>
<li>get the blockchain height (/chain/name/q/getblockcount)</li>
<li>get block info (/search?q=blocknum)</li>
<li>get the value of the generation transaction; subtract from it the fees paid by the other transactions in the block</li>
</ol>

<p>As above, step 2 returns HTML which you'll have to scrape. Here's some C# I knocked together:</p>

<pre><code>private decimal GetRewardAbe(string url_prefix, string chain_name)
{
    WebClient wc = new WebClient();
    int blockcount = Convert.ToInt32(wc.DownloadString(url_prefix + "/chain/" + chain_name + "/q/getblockcount"));
    string blockinfo = wc.DownloadString(url_prefix + "/search?q=" + blockcount.ToString());
    int tx_index = 0;
    decimal reward = 0;
    foreach (string line in blockinfo.Split(new char[] { '\n' }))
        if (line.Contains("&lt;tr&gt;") &amp;&amp; !line.Contains("&lt;table&gt;"))
        {
            string[] fields = line.Split(new string[] { "&lt;td&gt;", "&lt;/td&gt;", "&lt;tr&gt;", "&lt;/tr&gt;" }, StringSplitOptions.RemoveEmptyEntries);
            if (tx_index == 0)
            {
                reward = Convert.ToDecimal(fields[3].Split(new char[] { ' ' })[1]);
                if (fields[3].Contains("+"))
                    break;
            }
            else
                reward -= Convert.ToDecimal(fields[1]);
            tx_index++;
        }
    return reward * (decimal)100000000;
}
</code></pre>

<p>The value returned is in satoshis, consistent with what blockexplorer.com or blockchain.info return for Bitcoin.</p>

CC BY-SA 3.0
2013-05-28T22:23:13.607Z
2013-05-29T19:53:04.093Z
2013-05-29T19:53:04.093Z
salfter
<p>The litecoin wiki on github lists <a href="https://github.com/litecoin-project/litecoin/wiki/List-of-Litecoin-related-services#block-explorers" rel="nofollow">block explorer sites</a>.</p>

<p>The explorer.litecoin.net <a href="http://explorer.litecoin.net/q" rel="nofollow">API</a> seems to be what you are searching for, the corresponding difficulty could be retrieved by using the <code>nethash</code> command of the API. The specific page you are looking for should be <a href="http://explorer.litecoin.net/chain/Litecoin/q/nethash/1/-1" rel="nofollow">this URL</a>, see my comment for further explanations.</p>

CC BY-SA 3.0
2013-04-05T05:25:35.170Z
Thank but I don't understand what parameter I should pass to get current difficulty I tried this http://explorer.litecoin.net/q/nethash
working4coins
CC BY-SA 3.0
2013-04-05T07:31:26.983Z
Both http://explorer.litecoin.net/ and http://litecoinscout.com/ rely on the Abe API. To get the current difficulty query this URL: http://explorer.litecoin.net/chain/Litecoin/q/nethash/1/-1
The 'CHAIN' is 'Litecoin', the 'INTERVAL' is '1'(every block), and the START is '-1'(last block).
Your value(currently about 150) is between the second and third last comma. You will have to find a way to extract that in your calculator.
There does not seem to be a http://explorer.litecoin.net/chain/Litecoin/q/difficulty
ix5
CC BY-SA 3.0
2013-04-05T09:23:09.870Z
It will be a pain to parse that !!! why are not they using a JSON API ??? or YAML ?
working4coins
CC BY-SA 3.0
2013-04-05T11:02:03.963Z
@working4coins I have no idea, but you can contact the creators of the explorer sites. It *should* be easy to implement a ´difficulty´ API call. Otherwise you could run [abe](https://github.com/jtobey/bitcoin-abe) by yourself.
ix5
CC BY-SA 3.0
2013-04-06T20:21:00.813Z
I'm still looking for a way to know block reward (now it's 25 LTC) It was 50 LTC previously
working4coins
CC BY-SA 3.0
2013-04-07T16:25:17.230Z
The block reward will not change for a while. The current block count is around 330,000, and the reward is supposed to halve at 840,00. You should be good with setting 25 LTC as a static value for now.
ix5
CC BY-SA 3.0
2013-04-03T18:26:14.673Z
2013-04-05T07:34:28.917Z
2013-04-05T07:34:28.917Z
ix5
<p>You can view Litecoin difficulty in <a href="http://ltc.blockr.io" rel="nofollow">Litecoin block explorer - blockr.io</a></p>

CC BY-SA 3.0
2014-01-22T15:52:11.213Z
2014-01-22T15:52:11.213Z
Blockr.io
<p>The latest version of Abe supports getdifficulty, so you could run it yourself or convince the explorer administrator to upgrade.  But this will be the difficulty as of the last solved block.  I would expect "litecoind getinfo" to give a more accurate number during difficulty adjustments, and this does not require Abe or a website.</p>

<p>As for the block reward, Abe lacks bcperblock.  Perhaps the easiest route is to get the <a href="http://explorer.litecoin.net/chain/Litecoin/q/getblockcount" rel="nofollow">current block number</a> (also available via getinfo) and calculate the reward.  According to litecoin.org, the reward starts at 50 LTC and is halved every 840,000 blocks.  In Python:</p>

<pre><code>def reward(blocknumber):
    return 50.0 / (2 ** int((blocknumber + 1) / 840000))
</code></pre>

<p>Adding 1 to the block number gives you the <em>next</em> block's reward, which is what matters to miners.</p>

CC BY-SA 3.0
2013-04-08T15:31:06.803Z
2013-04-08T15:31:06.803Z
John Tobey
<p>How can I know <code>difficulty</code> value and <code>reward</code> for Litecoin network ?</p>

<p>I'm looking for website such as </p>

<ul>
<li><a href="http://blockexplorer.com/q/bcperblock" rel="nofollow">http://blockexplorer.com/q/bcperblock</a> </li>
<li><a href="http://blockexplorer.com/q/getdifficulty" rel="nofollow">http://blockexplorer.com/q/getdifficulty</a></li>
</ul>

<p>to get difficulty and reward for Litecoin network (instead of Bitcoin network)</p>

<p>I'm looking for a way to get difficulty and reward using an API that can be queried every 15 minutes to make my own mining profit calculator.</p>

<p>Current difficulty is around 100 and current reward is 25 LTC.</p>

<litecoin><alternatives><difficulty><mining-reward>
Litecoin difficulty and reward
working4coins
# Litecoin difficulty and reward

(Asked by: username_0 on 2013-04-01)

How can I know `difficulty` value and `reward` for Litecoin network ?

I'm looking for website such as

* <http://blockexplorer.com/q/bcperblock>
* <http://blockexplorer.com/q/getdifficulty>

to get difficulty and reward for Litecoin network (instead of Bitcoin network)

I'm looking for a way to get difficulty and reward using an API that can be queried every 15 minutes to make my own mining profit calculator.

Current difficulty is around 100 and current reward is 25 LTC.

**Tags:** litecoin, alternatives, difficulty, mining-reward


---

## 4 answers

### Answer by username_4 on 2013-04-08. Score: 3 | Accepted answer

The latest version of Abe supports getdifficulty, so you could run it yourself or convince the explorer administrator to upgrade. But this will be the difficulty as of the last solved block. I would expect "litecoind getinfo" to give a more accurate number during difficulty adjustments, and this does not require Abe or a website.

As for the block reward, Abe lacks bcperblock. Perhaps the easiest route is to get the [current block number](http://explorer.litecoin.net/chain/Litecoin/q/getblockcount) (also available via getinfo) and calculate the reward. According to litecoin.org, the reward starts at 50 LTC and is halved every 840,000 blocks. In Python:

```
def reward(blocknumber):
    return 50.0 / (2 ** int((blocknumber + 1) / 840000))

```

Adding 1 to the block number gives you the *next* block's reward, which is what matters to miners.


---

### Answer by username_1 on 2013-05-28. Score: 2

Current versions of Abe support the getdifficulty API call. For instance, <http://yacexplorer.tk/chain/Yacoin/q/getdifficulty> returns the current Yacoin difficulty. The problem with Litecoin is that both explorer.litecoin.net and litecoinscout.com are running outdated versions of Abe.

For these older versions of Abe, difficulty at the time a block is solved is available; it should usually be close enough to the current difficulty. Here's an alternate approach I implemented to get Litecoin difficulty:

1. get the blockchain height (/chain/name/q/getblockcount)
2. get block info (/search?q=blocknum)
3. get difficulty

Step 2 returns HTML which you'll have to scrape. Here's some C# I knocked together:

```
private double GetDifficultyAbeAlt(string url_prefix, string chain_name)
{
    WebClient wc = new WebClient();
    int blockcount = Convert.ToInt32(wc.DownloadString(url_prefix + "/chain/" + chain_name + "/q/getblockcount"));
    string blockinfo = wc.DownloadString(url_prefix + "/search?q=" + blockcount.ToString());
    double difficulty = 0;
    foreach (string line in blockinfo.Split(new char[] { '\n' }))
        if (line.Contains("Difficulty") && !line.Contains("Cumulative"))
            difficulty = Convert.ToDouble(line.Split(new char[] { ' ' })[1]);
    return difficulty;
}

```

For the block reward, this is the approach I took that should work with any version of Abe:

1. get the blockchain height (/chain/name/q/getblockcount)
2. get block info (/search?q=blocknum)
3. get the value of the generation transaction; subtract from it the fees paid by the other transactions in the block

As above, step 2 returns HTML which you'll have to scrape. Here's some C# I knocked together:

```
private decimal GetRewardAbe(string url_prefix, string chain_name)
{
    WebClient wc = new WebClient();
    int blockcount = Convert.ToInt32(wc.DownloadString(url_prefix + "/chain/" + chain_name + "/q/getblockcount"));
    string blockinfo = wc.DownloadString(url_prefix + "/search?q=" + blockcount.ToString());
    int tx_index = 0;
    decimal reward = 0;
    foreach (string line in blockinfo.Split(new char[] { '\n' }))
        if (line.Contains("<tr>") && !line.Contains("<table>"))
        {
            string[] fields = line.Split(new string[] { "<td>", "</td>", "<tr>", "</tr>" }, StringSplitOptions.RemoveEmptyEntries);
            if (tx_index == 0)
            {
                reward = Convert.ToDecimal(fields[3].Split(new char[] { ' ' })[1]);
                if (fields[3].Contains("+"))
                    break;
            }
            else
                reward -= Convert.ToDecimal(fields[1]);
            tx_index++;
        }
    return reward * (decimal)100000000;
}

```

The value returned is in satoshis, consistent with what blockexplorer.com or blockchain.info return for Bitcoin.


---

### Answer by username_2 on 2013-04-03. Score: 1

The litecoin wiki on github lists [block explorer sites](https://github.com/litecoin-project/litecoin/wiki/List-of-Litecoin-related-services#block-explorers).

The explorer.litecoin.net [API](http://explorer.litecoin.net/q) seems to be what you are searching for, the corresponding difficulty could be retrieved by using the `nethash` command of the API. The specific page you are looking for should be [this URL](http://explorer.litecoin.net/chain/Litecoin/q/nethash/1/-1), see my comment for further explanations.

> **Comments:**
> **username_0**: Thank but I don't understand what parameter I should pass to get current difficulty I tried this http://explorer.litecoin.net/q/nethash  
> **username_2**: Both http://explorer.litecoin.net/ and http://litecoinscout.com/ rely on the Abe API. To get the current difficulty query this URL: http://explorer.litecoin.net/chain/Litecoin/q/nethash/1/-1 The 'CHAIN' is 'Litecoin', the 'INTERVAL' is '1'(every block), and the START is '-1'(last block). Your value(currently about 150) is between the second and third last comma. You will have to find a way to extract that in your calculator. There does not seem to be a http://explorer.litecoin.net/chain/Litecoin/q/difficulty  
> **username_0**: It will be a pain to parse that !!! why are not they using a JSON API ??? or YAML ?  
> **username_2**: @username_0 I have no idea, but you can contact the creators of the explorer sites. It *should* be easy to implement a ´difficulty´ API call. Otherwise you could run [abe](https://github.com/jtobey/bitcoin-abe) by yourself.  
> **username_0**: I'm still looking for a way to know block reward (now it's 25 LTC) It was 50 LTC previously  
> **username_2**: The block reward will not change for a while. The current block count is around 330,000, and the reward is supposed to halve at 840,00. You should be good with setting 25 LTC as a static value for now.  

---

### Answer by username_3 on 2014-01-22. Score: 1

You can view Litecoin difficulty in [Litecoin block explorer - username_3](http://ltc.username_3)


---

