A Guide to Bitquery's Litecoin APIs
Among various cryptocurrencies, Litecoin stands out as one of the most established and reliable digital assets. Because of its decentralized nature, it enables secure transactions for low fees. The system uses math to make sure everything is safe, and it gives people more control over their money.
The Litecoin blockchain complements Bitcoin and can process more transactions than Bitcoin because it generates blocks more frequently. This means it can handle a larger volume of transactions without any major software modifications.
Since it’s open source, it facilitates developers to run or make changes to software as required.
In this article, let’s discuss how developers can leverage Bitquery APIs to understand more about the Litecoin blockchain for their own applications.
What is Litecoin?
Litecoin is a peer-to-peer system of cryptocurrency and an open-source software project. It was actually forked from the Bitcoin blockchain. Inspired by and technically similar to Bitcoin, Litecoin was created by Charlie Lee, an engineer in Google, in 2011 as a "lite" version of Bitcoin, offering faster transaction confirmation times and a different hashing algorithm (Scrypt) for mining.
Litecoin aims to provide a faster and more efficient alternative for everyday transactions while maintaining the principles of decentralization and security inherent in blockchain technology.
The native cryptocurrency of Litecoin is LTC, similar to Bitcoin (BTC) and it uses a proof-of-work algorithm. The architecture of Litecoin is similar to Bitcoin, although Litecoin uses Scrypt and Bitcoin uses SHA-256. Scrypt provides speedy transactions and is more energy efficient than SHA-256.
Litecoin vs. Bitcoin
Litecoin is often referred to as “silver” to Bitcoin’s “gold”. Here are some advantages of Litecoin over Bitcoin:
- Incurs less blockchain fees than Bitcoin
- Provides higher transaction speeds than Bitcoin
- Serves as a testnet for Bitcoin network
- Is used for making day-to-day micro purchases, such as gas or groceries
- Supply is capped at 84 million as opposed to Bitcoin’s supply, which is at 21 million
- Uses Scrypt, which is faster than Bitcoin’s SHA-256
- Produces more blocks (almost 4 times more) than Bitcoin
- Applications of Litecoin
Litecoin is commonly used for:
- Digital payments
- NFTs, collectibles
- Charity donations
- Micro transactions or purchases
Litecoin APIs
The Litecoin API provides developers with a comprehensive set of tools and functionalities for interacting with the Litecoin blockchain. Whether you're building a wallet application, a payment gateway, or a decentralized exchange, the Litecoin API offers a suite of functions that streamline blockchain integration.
Here are some Litecoin APIs provided by Bitquery:
- Litecoin Blockchain Explorer API
- Litecoin Transactions API
- Litecoin Mining API
- Litecoin Coinpath API
- Litecoin AddressStats API
Litecoin Block Explorer API: Overview of Litecoin
Bitquery provides a simple and easy-to-use interface to extract real-time or historic blockchain data. Use the Bitquery Explorer to track Litecoin transactions, transfers, transaction fees, gas spent, blocks, Litecoin halving, money flow, and more.
To embed queries in your applications, simply click the Get API on the bottom right of the screen (check the above image). To write your own queries, use Bitquery’s in-built GraphQL IDE.
Let’s use Bitquery APIs to check Litecoin blockchain activity.
Address Stats API
Obtaining statistics of a Litecoin address
This API retrieves statistics related to Litecoin addresses,such as the number of inbound/outbound transactions, unspent balance, unique transfers, and more.
To obtain the statistics for a specific address, use the following query in IDE. For example, let’s get the statistics of a specific address, LaYPLuQEanVCYM9TztR9FuT3ZbTJM6wHEZ. Specify the network as “litecoin” and the address as shown here.
{
bitcoin(network: litecoin) {
addressStats(address: {is: "LaYPLuQEanVCYM9TztR9FuT3ZbTJM6wHEZ"}) {
address {
address
annotation
balance
inboundTransactions
inflows
outboundTransactions
outflows
uniqueDaysWithTransfers
uniqueReceivers
uniqueSenders
}
}
}
}
Blocks API
Viewing details of all blocks on the Litecoin blockchain
Get the details of all blocks on the Litecoin chain by using this API. For example, to retrieve the details of all the Litecoin blocks for a period of 15 days in February, use this query. Specify the network as “litecoin” and the dates as applicable (02/01 to 02/15).
query ($network: BitcoinNetwork!, $limit: Int!, $offset: Int!, $from: ISO8601DateTime, $till: ISO8601DateTime) {
bitcoin(network: $network) {
blocks(
options: {desc: "height", limit: $limit, offset: $offset}
date: {since: $from, till: $till}
) {
timestamp {
time(format: "%Y-%m-%d %H:%M:%S")
}
height
difficulty
transactionCount
blockSizeBigInt
blockHash
blockSize
blockSizeBigInt
blockStrippedSize
blockVersion
blockWeight
chainwork
difficulty
}
}
}
Obtaining details of a specific block
Alternatively, if you want to check for details of a specific block, simply specify the “height” parameter with the required block ID in the above query. For example, let’s check the details of the block, 2636351 in this query. Specify the network as “litecoin” and the height parameter as “2636351” as given here.
query ($network: BitcoinNetwork!, $height: Int!) {
bitcoin(network: $network) {
blocks(height: {is: $height}) {
timestamp {
time(format: "%Y-%m-%d %H:%M:%S")
}
medianTime {
time(format: "%Y-%m-%d %H:%M:%S")
}
blockHash
blockSizeBigInt
blockStrippedSize
blockVersion
blockWeight
chainwork
difficulty
transactionCount
}
}
}
Coinpath API
Tracing money flow
You can track the flow of funds and transactions between addresses by using the Coinpath API. This will retrieve data related to the transaction amount, number of transactions, amount sent or received, senders, and receivers.
For example, here we’ll track the inputs and outflow of money for this Litecoin address, LUazv9uUA4rmdmm54HjzTH72vRahHaKJSc
for a period of say, 15 days in February. Check this query. Specify the network as “litecoin”, address as “LUazv9uUA4rmdmm54HjzTH72vRahHaKJSc “, and the dates as applicable.
query ($network: BitcoinNetwork!, $address: String!, $inboundDepth: Int!, $outboundDepth: Int!, $limit: Int!, $from: ISO8601DateTime, $till: ISO8601DateTime) {
bitcoin(network: $network) {
inbound: coinpath(
initialAddress: {is: $address}
depth: {lteq: $inboundDepth}
options: {direction: inbound, asc: "depth", desc: "amount", limitBy: {each: "depth", limit: $limit}}
date: {since: $from, till: $till}
) {
sender {
address
annotation
}
receiver {
address
annotation
}
amount
depth
count
}
outbound: coinpath(
initialAddress: {is: $address}
depth: {lteq: $outboundDepth}
options: {asc: "depth", desc: "amount", limitBy: {each: "depth", limit: $limit}}
date: {since: $from, till: $till}
) {
sender {
address
annotation
}
receiver {
address
annotation
}
amount
depth
count
}
}
}
Here’s a visual representation of the same query.
Inputs API
Extracting input details of a transaction
Here, we’ll obtain the inputs of a transaction on a particular Litecoin block by using this API. For example, let’s retrieve the input details including the traded value of block 2636355, after 1st of January 2024, in this query.
Specify the network as “litecoin, height as “ 2636355“, and the dates as applicable.
{
bitcoin(network: litecoin) {
inputs(
options: {limit: 50, desc: "block.timestamp.iso8601"}
date: {after: "2023-12-01T00:00:00Z"}
height: {is: 2636355}
) {
block {
height
timestamp {
iso8601
}
}
inputIndex
inputScript
inputAddress {
address
annotation
}
outputTransaction {
hash
}
transaction {
hash
}
value
}
}
}
Outputs API
Fetching output details of a transaction
Similar to the Inputs API, the Outputs API fetches all the outputs of a transaction on the Litecoin network. Use the filters to obtain outputs of a specific block if needed. In this query, let’s get transaction outputs for the same block as above, 2636355, after 1st of February 2024. Specify the network as “litecoin” , height as “2636355” and the date as applicable.
{
bitcoin(network: litecoin) {
outputs(
date: {after: "2023-02-01"}
options: {limit: 20, desc: "block.timestamp.iso8601"}
height: {is: 2636355}
) {
block {
timestamp {
iso8601
}
}
date {
date
}
outputAddress {
address
annotation
}
outputDirection
outputIndex
reqSigs
transaction {
hash
index
}
value
}
}
}
Transactions API
This API allows you to track transactions on the Litecoin network.
Viewing daily Litecoin transaction count
Let’s obtain the number of daily transactions on Litecoin per day, for the last 10 days, using this simple query. Specify the network as “litecoin” , and the count parameter as shown here.
{
bitcoin(network: litecoin) {
transactions(options: {desc: "date.date", limit: 10}) {
date {
date
}
count
}
}
}
Checking monthly transactions on the Litecoin network
Next, we’ll retrieve all the transactions on the Litecoin network after 1st of February 2024 using this query in IDE. Specify the date parameter “after” to “2024-02-01” and set the limit to 20 or as required.
{
bitcoin(network: litecoin) {
transactions(
date: {after: "2024-02-01"}
options: {desc: "block.timestamp.iso8601", limit: 20}
) {
block {
height
timestamp {
iso8601
}
}
feeValue(in: USD)
feeValueDecimal
hash
index
inputCount
inputCountBigInt
inputValue
inputValueDecimal
minedValue
minedValueDecimal
outputCount
outputCountBigInt
outputValue
outputValueDecimal
txCoinbase
txLocktime
txSize
txVersion
txVsize
txWeight
}
}
}
Similarly, to get transactions on a specific block, simply specify the height parameter in the above query.
Retrieving Litecoin transactions by date
Further, you can also get the count of transactions on a specific date. For example, let’s fetch the number of transactions on Litecoin for 19th Feb 2024. Build this query in IDE as shown. Set the “from” and “till”parameters to “2024-02-19”. Specify the network as “litecoin” to get the number of transactions on that day.
query ($network: BitcoinNetwork!, $dateFormat: String!, $from: ISO8601DateTime, $till: ISO8601DateTime) {
bitcoin(network: $network) {
transactions(options: {asc: "date.date"}, date: {since: $from, till: $till}) {
date: date {
date(format: $dateFormat)
}
count: countBigInt
}
}
}
Tracking Litecoin transaction fee by date
Let’s filter the above query to view the total transaction fees for transactions on 19th Feb 2024. Add the parameter “feeValue” to the query as shown. Set the date parameter as before.
query ($network: BitcoinNetwork!, $dateFormat: String!, $from: ISO8601DateTime, $till: ISO8601DateTime) {
bitcoin(network: $network) {
transactions(options: {asc: "date.date"}, date: {since: $from, till: $till}) {
date: date {
date(format: $dateFormat)
}
count: countBigInt
feeValue
avgFee: feeValue(calculate: average)
}
}
}
Retrieving Litecoin transaction scripts
Similar to Bitcoin, transaction scripts of Litecoin also specify how currencies are traded. These scripts are used to validate transactions on the Litecoin network. Through Bitquery’s Input and Output Scripts APIs, you can retrieve the transaction scripts of Litecoin easily.
Input Scripts
Let’s get the input script for a specific Litecoin transaction, 0eb381091066a31aa306737012c76f03478f31da566bc1314a7e9f6ebbeebac8. Set the address (hash) parameter to the required one in the query here as shown. Specify the network as “litecoin”.
query ($network: BitcoinNetwork!, $hash: String!, $limit: Int!, $offset: Int!) {
bitcoin(network: $network) {
inputs(
txHash: {is: $hash}
options: {asc: "inputIndex", limit: $limit, offset: $offset}
) {
inputIndex
address: inputAddress {
address
annotation
}
value
value_usd: value(in: USD)
outputTransaction {
hash
index
}
inputScriptType {
pattern
annotation
type
}
inputScript
}
}
}
Output Scripts
Similarly, you can query for output scripts by using the “outputs” parameter in the query.
query ($network: BitcoinNetwork!, $hash: String!, $limit: Int!, $offset: Int!) {
bitcoin(network: $network) {
outputs(
txHash: {is: $hash}
options: {asc: "outputIndex", limit: $limit, offset: $offset}
) {
outputIndex
address: outputAddress {
address
annotation
}
value
value_usd: value(in: USD)
outputDirection
outputScriptType {
annotation
pattern
type
}
outputScript
}
}
}
Extracting number of LTC transactions
To obtain transactions of LTC, the native crypto on the Litecoin network, use this API. This query returns the LTC transactions (both inbound and outbound) for the period from 1st Feb 2024 to 15th Feb 2024. Specify the network as “litecoin” and the dates as shown here.
query ($network: BitcoinNetwork!, $address: String!, $dateFormat: String!, $from: ISO8601DateTime, $till: ISO8601DateTime) {
bitcoin(network: $network) {
inputs(
date: {since: $from, till: $till}
inputAddress: {is: $address}
options: {asc: "date.date"}
) {
date {
date(format: $dateFormat)
}
value
}
outputs(
date: {since: $from, till: $till}
outputAddress: {is: $address}
options: {asc: "date.date"}
) {
date {
date(format: $dateFormat)
}
value
}
}
}
Getting data on inbound LTC transfers
Similarly, you can get all inbound transfers in LTC using this query. Specify the network as “litecoin” and the dates as shown here.
query ($network: BitcoinNetwork!, $address: String!, $dateFormat: String!, $from: ISO8601DateTime, $till: ISO8601DateTime) {
bitcoin(network: $network) {
outputs(
date: {since: $from, till: $till}
outputAddress: {is: $address}
options: {asc: "date.date"}
) {
date: date {
date(format: $dateFormat)
}
count: countBigInt(uniq: transactions)
value
}
}
}
Tracking gas spent on transactions
To know the amount of gas spent on transactions on Litecoin, use this query. For example, here we are retrieving gas spent on a specific Litecoin transaction, ltc1q52xhq67je0d2pq5wn52pxqrgx9mjfkuejwggf4, during 1st February to 15th February 2024. Specify the network as “litecoin” , address as “ltc1q52xhq67je0d2pq5wn52pxqrgx9mjfkuejwggf4” and the dates as shown here.
query ($network: BitcoinNetwork!, $dateFormat: String!, $address: String!, $from: ISO8601DateTime, $till: ISO8601DateTime) {
bitcoin(network: $network) {
transactions(
options: {asc: "date.date"}
date: {since: $from, till: $till}
inputAddress: {is: $address}
) {
date: date {
date(format: $dateFormat)
}
count: countBigInt
feeValue
}
}
}
Mining API
The Litecoin Mining API extracts mining information on Litecoin blockchain, including the number of miners, blocks produced by them, mining rewards and so on.
Obtaining unique miners on Litecoin
If you want to know the number of miners or number of unique miners on Litecoin, build this query in IDE. For example, this query retrieves the number of unique miners for a period of 1 week, from 1st Feb to 7th Feb 2024. Specify the network as “litecoin” and the dates as applicable.
query ($network: BitcoinNetwork!, $dateFormat: String!, $from: ISO8601DateTime, $till: ISO8601DateTime) {
bitcoin(network: $network) {
outputs(
options: {asc: "date.date"}
date: {since: $from, till: $till}
txIndex: {is: 0}
outputDirection: {is: mining}
outputScriptType: {notIn: ["nulldata", "nonstandard"]}
) {
date: date {
date(format: $dateFormat)
}
count: countBigInt(uniq: addresses)
value
}
}
}
**Checking mined value **
To get the daily mined value of blocks on Litecoin, use this query. For example, let’s retrieve the daily mined value of blocks from 1st February 2024 till date. Specify the network as “litecoin” and the dates as shown here.
query ($network: BitcoinNetwork!, $dateFormat: String!, $from: ISO8601DateTime, $till: ISO8601DateTime) {
bitcoin(network: $network) {
transactions(options: {asc: "date.date"}, date: {since: $from, till: $till}) {
date: date {
date(format: $dateFormat)
}
count: countBigInt(uniq: blocks)
minedValue
}
}
}
You can also obtain mined value per block by specifying “uniq: blocks” for the count parameter in the above query.
**Viewing number of mined blocks **
This API also allows you to get data on the number of blocks produced by miners over a period of time.
To check how many blocks were mined during a specified time period, build this query. For example,let’s get the number of blocks mined from 1st February 2024 onwards till date. Specify the network as “litecoin” and the dates as applicable.
query ($network: BitcoinNetwork!, $dateFormat: String!, $from: ISO8601DateTime, $till: ISO8601DateTime) {
bitcoin(network: $network) {
outputs(
options: {asc: "date.date"}
date: {since: $from, till: $till}
txIndex: {is: 0}
outputDirection: {is: mining}
outputScriptType: {notIn: ["nulldata", "nonstandard"]}
) {
address: outputAddress {
address
annotation
}
date {
date(format: $dateFormat)
}
reward: value
count(uniq: blocks)
}
}
}
Retrieving number of Litecoin block rewards
With this API, you can also get information on Litecoin mining rewards. That is, you can get data on the number of miner rewards for each unique miner. For example, this query fetches the mining reward data from 15th February 2024 till date. Specify the network as “litecoin”, and dates as applicable.
query ($network: BitcoinNetwork!, $dateFormat: String!, $from: ISO8601DateTime, $till: ISO8601DateTime) {
bitcoin(network: $network) {
outputs(
options: {asc: "date.date"}
date: {since: $from, till: $till}
txIndex: {is: 0}
outputDirection: {is: mining}
outputScriptType: {notIn: ["nulldata", "nonstandard"]}
) {
address: outputAddress {
address
annotation
}
date {
date(format: $dateFormat)
}
reward: value
count(uniq: blocks)
}
}
}
Similarly, you can also obtain reward data for a specific block by specifying the height parameter as required.
Litecoin Halving
Litecoin's halving event occurs approximately every four years or for 840,000 blocks, reducing block rewards by 50% and impacting the issuance of new LTC. This process, integral to Litecoin's protocol, will continue until the year 2142 when all LTC coins will have been mined.
The recent Litecoin halving event took place on August 2 2023 and the next one is scheduled to occur in 2027, where the block rewards will be reduced further.
Let’s demonstrate this using the Mining API.
Query 1: In this query, let’s get the mining rewards for block 1680328 on 5th August 2019 (the 3rd halving event of Litecoin). Specify the network as “litecoin”, the height parameter as “1680328” and the date as "2019-08-05". Run the query and note the reward amount for the block as shown in the Results column.
query ($network: BitcoinNetwork!, $dateFormat: String!, $from: ISO8601DateTime, $till: ISO8601DateTime) {
bitcoin(network: $network) {
outputs(
options: {asc: "date.date"}
date: {since: $from, till: $till}
txIndex: {is: 0}
outputDirection: {is: mining}
outputScriptType: {notIn: ["nulldata", "nonstandard"]}
height: {is: 1680328}
) {
address: outputAddress {
address
annotation
}
date {
date(format: $dateFormat)
}
reward: value
count(uniq: blocks)
}
}
}
Query 2: Now, let’s run the query for the next halving event of Litecoin, which was on August 2, 2023, using the same API. For example, build this query to obtain the mining reward for the block 2520218 on August 2, 2023. Specify the network as “litecoin”, the height parameter as “2520218”, and the date as "2023-08-02”. Run the query and note the reward amount for this block as shown in the Results column.
query ($network: BitcoinNetwork!, $dateFormat: String!, $from: ISO8601DateTime, $till: ISO8601DateTime) {
bitcoin(network: $network) {
outputs(
options: {asc: "date.date"}
date: {since: $from, till: $till}
txIndex: {is: 0}
outputDirection: {is: mining}
outputScriptType: {notIn: ["nulldata", "nonstandard"]}
height: {is: 2520218}
) {
address: outputAddress {
address
annotation
}
date {
date(format: $dateFormat)
}
reward: value
count(uniq: blocks)
}
}
}
These results show that the Litecoin mining rewards from 2019 to 2023 have been cut in half.
About Bitquery
Bitquery is your comprehensive toolkit designed with developers in mind, simplifying blockchain data access. Our products offer practical advantages and flexibility.
-
APIs - Explore API: Easily retrieve precise real-time and historical data for over 40 blockchains using GraphQL. Seamlessly integrate blockchain data into your applications, making data-driven decisions effortless.
-
Coinpath® - Try Coinpath: Streamline compliance and crypto investigations by tracing money movements across 40+ blockchains. Gain insights for efficient decision-making.
-
Data in Cloud - Try Demo Bucket: Access indexed blockchain data cost-effectively and at scale for your data pipeline. We currently support Ethereum, BSC, Solana, with more blockchains on the horizon, simplifying your data access.
-
Explorer - Try Explorer: Discover an intuitive platform for exploring data from 40+ blockchains. Visualize data, generate queries, and integrate effortlessly into your applications.
Bitquery empowers developers with straightforward blockchain data tools. If you have questions or need assistance, connect with us on our Telegram channel or via email at sales@bitquery.io. Stay updated on the latest in cryptocurrency by subscribing to our newsletter below.
This article has been written by guest writer Aparna Sridhar
Subscribe to our newsletter
Subscribe and never miss any updates related to our APIs, new developments & latest news etc. Our newsletter is sent once a week on Monday.