let request =NSMutableURLRequest(url: NSURL(string: "https://api.mainnet.aptoslabs.com/v1/")!as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod="GET"
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) ->Voidin
if(error != nil) {
print(error asAny)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
Get the latest ledger information, including data such as chain ID,
role type, ledger versions, epoch, etc.
Responses
200
The struct holding all data returned to the client by the
index endpoint (i.e., GET ”/”). Only for responding in JSON
object
chain_id
required
Chain ID of the current chain
integer format: uint8
epoch
required
A string containing a 64-bit unsigned integer.
We represent u64 values as a string to ensure compatibility with languages such
as JavaScript that do not parse u64s in JSON natively.
string format: uint64
32425224034
ledger_version
required
A string containing a 64-bit unsigned integer.
We represent u64 values as a string to ensure compatibility with languages such
as JavaScript that do not parse u64s in JSON natively.
string format: uint64
32425224034
oldest_ledger_version
required
A string containing a 64-bit unsigned integer.
We represent u64 values as a string to ensure compatibility with languages such
as JavaScript that do not parse u64s in JSON natively.
string format: uint64
32425224034
ledger_timestamp
required
A string containing a 64-bit unsigned integer.
We represent u64 values as a string to ensure compatibility with languages such
as JavaScript that do not parse u64s in JSON natively.
string format: uint64
32425224034
node_role
required
string
Allowed values: validator full_node
oldest_block_height
required
A string containing a 64-bit unsigned integer.
We represent u64 values as a string to ensure compatibility with languages such
as JavaScript that do not parse u64s in JSON natively.
string format: uint64
32425224034
block_height
required
A string containing a 64-bit unsigned integer.
We represent u64 values as a string to ensure compatibility with languages such
as JavaScript that do not parse u64s in JSON natively.
string format: uint64
32425224034
git_hash
Git hash of the build of the API endpoint. Can be used to determine the exact
software version used by the API endpoint.
string
Array<integer>
Headers
X-APTOS-CHAIN-ID
required
integer format: uint8
Chain ID of the current chain
X-APTOS-LEDGER-VERSION
required
integer format: uint64
Current ledger version of the chain
X-APTOS-LEDGER-OLDEST-VERSION
required
integer format: uint64
Oldest non-pruned ledger version of the chain
X-APTOS-LEDGER-TIMESTAMPUSEC
required
integer format: uint64
Current timestamp of the chain
X-APTOS-EPOCH
required
integer format: uint64
Current epoch of the chain
X-APTOS-BLOCK-HEIGHT
required
integer format: uint64
Current block height of the chain
X-APTOS-OLDEST-BLOCK-HEIGHT
required
integer format: uint64
Oldest non-pruned block height of the chain
X-APTOS-GAS-USED
integer format: uint64
The cost of the call in terms of gas
X-APTOS-CURSOR
string
Cursor to be used for endpoints that support cursor-based
pagination. Pass this to the start field of the endpoint
on the next call to get the next page of results.
400
application/json
This is the generic struct we use for all API errors, it contains a string
message and an Aptos API specific error code.
object
message
required
A message describing the error
string
error_code
required
These codes provide more granular error information beyond just the HTTP
status code of the response.