List All Ledgers
This endpoint lists all ledgers and can be used in streaming mode. Streaming mode allows you to listen for new ledgers as they close. If called in streaming mode, Horizon will start at the earliest known ledger unless a cursor is set, in which case it will start from that cursor. By setting the cursor value to now, you can stream ledgers since your request time.
curl --request GET \
--url 'https://mainnet.stellar.validationcloud.io/v1/<YOUR_API_KEY_HERE>/ledgers'import requests
url = "https://mainnet.stellar.validationcloud.io/v1/<YOUR_API_KEY_HERE>/ledgers"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://mainnet.stellar.validationcloud.io/v1/<YOUR_API_KEY_HERE>/ledgers', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://mainnet.stellar.validationcloud.io/v1/<YOUR_API_KEY_HERE>/ledgers",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://mainnet.stellar.validationcloud.io/v1/<YOUR_API_KEY_HERE>/ledgers"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://mainnet.stellar.validationcloud.io/v1/<YOUR_API_KEY_HERE>/ledgers")
.asString();require 'uri'
require 'net/http'
url = URI("https://mainnet.stellar.validationcloud.io/v1/<YOUR_API_KEY_HERE>/ledgers")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"_embedded": {
"records": [
{
"_links": {
"effects": {
"href": "/ledgers/1/effects/{?cursor,limit,order}",
"templated": true
},
"operations": {
"href": "/ledgers/1/operations/{?cursor,limit,order}",
"templated": true
},
"self": {
"href": "/ledgers/1"
},
"transactions": {
"href": "/ledgers/1/transactions/{?cursor,limit,order}",
"templated": true
}
},
"id": "e8e10918f9c000c73119abe54cf089f59f9015cc93c49ccf00b5e8b9afb6e6b1",
"paging_token": "4294967296",
"hash": "e8e10918f9c000c73119abe54cf089f59f9015cc93c49ccf00b5e8b9afb6e6b1",
"sequence": 1,
"transaction_count": 0,
"successful_transaction_count": 0,
"failed_transaction_count": 0,
"operation_count": 0,
"tx_set_operation_count": 0,
"closed_at": "1970-01-01T00:00:00Z",
"total_coins": "100000000000.0000000",
"fee_pool": "0.0000000",
"base_fee_in_stroops": 100,
"base_reserve_in_stroops": 100000000,
"max_tx_set_size": 50
},
{
"_links": {
"effects": {
"href": "/ledgers/2/effects/{?cursor,limit,order}",
"templated": true
},
"operations": {
"href": "/ledgers/2/operations/{?cursor,limit,order}",
"templated": true
},
"self": {
"href": "/ledgers/2"
},
"transactions": {
"href": "/ledgers/2/transactions/{?cursor,limit,order}",
"templated": true
}
},
"id": "e12e5809ab8c59d8256e691cb48a024dd43960bc15902d9661cd627962b2bc71",
"paging_token": "8589934592",
"hash": "e12e5809ab8c59d8256e691cb48a024dd43960bc15902d9661cd627962b2bc71",
"prev_hash": "e8e10918f9c000c73119abe54cf089f59f9015cc93c49ccf00b5e8b9afb6e6b1",
"sequence": 2,
"transaction_count": 0,
"successful_transaction_count": 0,
"failed_transaction_count": 0,
"operation_count": 0,
"closed_at": "2015-07-16T23:49:00Z",
"total_coins": "100000000000.0000000",
"fee_pool": "0.0000000",
"base_fee_in_stroops": 100,
"base_reserve_in_stroops": 100000000,
"max_tx_set_size": 100
}
]
},
"_links": {
"next": {
"href": "/ledgers?order=asc&limit=2&cursor=8589934592"
},
"prev": {
"href": "/ledgers?order=desc&limit=2&cursor=4294967296"
},
"self": {
"href": "/ledgers?order=asc&limit=2&cursor="
}
}
}20 Compute Units.
Reference: Here
Query Parameters
A number that points to a specific location in a collection of responses and is pulled from the paging_token value of a record.
6606617478959105
A designation of the order in which records should appear. Options include asc (ascending) or desc (descending). If this argument isn’t set, it defaults to asc.
asc, desc The maximum number of records returned. The limit can range from 1 to 200 - an upper limit that is hardcoded in Horizon for performance reasons. If this argument isn’t designated, it defaults to 10.
10
Response
Success
Show child attributes
Show child attributes
curl --request GET \
--url 'https://mainnet.stellar.validationcloud.io/v1/<YOUR_API_KEY_HERE>/ledgers'import requests
url = "https://mainnet.stellar.validationcloud.io/v1/<YOUR_API_KEY_HERE>/ledgers"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://mainnet.stellar.validationcloud.io/v1/<YOUR_API_KEY_HERE>/ledgers', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://mainnet.stellar.validationcloud.io/v1/<YOUR_API_KEY_HERE>/ledgers",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://mainnet.stellar.validationcloud.io/v1/<YOUR_API_KEY_HERE>/ledgers"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://mainnet.stellar.validationcloud.io/v1/<YOUR_API_KEY_HERE>/ledgers")
.asString();require 'uri'
require 'net/http'
url = URI("https://mainnet.stellar.validationcloud.io/v1/<YOUR_API_KEY_HERE>/ledgers")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"_embedded": {
"records": [
{
"_links": {
"effects": {
"href": "/ledgers/1/effects/{?cursor,limit,order}",
"templated": true
},
"operations": {
"href": "/ledgers/1/operations/{?cursor,limit,order}",
"templated": true
},
"self": {
"href": "/ledgers/1"
},
"transactions": {
"href": "/ledgers/1/transactions/{?cursor,limit,order}",
"templated": true
}
},
"id": "e8e10918f9c000c73119abe54cf089f59f9015cc93c49ccf00b5e8b9afb6e6b1",
"paging_token": "4294967296",
"hash": "e8e10918f9c000c73119abe54cf089f59f9015cc93c49ccf00b5e8b9afb6e6b1",
"sequence": 1,
"transaction_count": 0,
"successful_transaction_count": 0,
"failed_transaction_count": 0,
"operation_count": 0,
"tx_set_operation_count": 0,
"closed_at": "1970-01-01T00:00:00Z",
"total_coins": "100000000000.0000000",
"fee_pool": "0.0000000",
"base_fee_in_stroops": 100,
"base_reserve_in_stroops": 100000000,
"max_tx_set_size": 50
},
{
"_links": {
"effects": {
"href": "/ledgers/2/effects/{?cursor,limit,order}",
"templated": true
},
"operations": {
"href": "/ledgers/2/operations/{?cursor,limit,order}",
"templated": true
},
"self": {
"href": "/ledgers/2"
},
"transactions": {
"href": "/ledgers/2/transactions/{?cursor,limit,order}",
"templated": true
}
},
"id": "e12e5809ab8c59d8256e691cb48a024dd43960bc15902d9661cd627962b2bc71",
"paging_token": "8589934592",
"hash": "e12e5809ab8c59d8256e691cb48a024dd43960bc15902d9661cd627962b2bc71",
"prev_hash": "e8e10918f9c000c73119abe54cf089f59f9015cc93c49ccf00b5e8b9afb6e6b1",
"sequence": 2,
"transaction_count": 0,
"successful_transaction_count": 0,
"failed_transaction_count": 0,
"operation_count": 0,
"closed_at": "2015-07-16T23:49:00Z",
"total_coins": "100000000000.0000000",
"fee_pool": "0.0000000",
"base_fee_in_stroops": 100,
"base_reserve_in_stroops": 100000000,
"max_tx_set_size": 100
}
]
},
"_links": {
"next": {
"href": "/ledgers?order=asc&limit=2&cursor=8589934592"
},
"prev": {
"href": "/ledgers?order=desc&limit=2&cursor=4294967296"
},
"self": {
"href": "/ledgers?order=asc&limit=2&cursor="
}
}
}