Export network history as CSV
Export CSV table data from network history between two block heights.
The requested block heights must fall on network history segment boundaries, which can be discovered by calling the API to list all network history segments. By default segments contain 1000 blocks. In that case ranges such as (1, 1000), (1001, 2000), (1, 3000) would all fall on segment boundaries and be valid.
The generated CSV file is compressed into a ZIP file and returned, with the file name in the following format: [chain id]-[table name]-[start block]-[end block].zip
In gRPC, results are returned in a chunked stream of base64 encoded data.
Through the REST gateway, the base64 data chunks are decoded and streamed as a
content-type: application/zip
HTTP response.
The CSV exported data uses a comma as a DELIMITER between fields, and " for QUOTE-ing fields.
If a value contains any of: DELIMITER, QUOTE, carriage return, or line feed then the whole value is prefixed and suffixed by the QUOTE character and any occurrence within the value of a QUOTE character preceded by another QUOTE.
A NULL is output as the NULL parameter string and is not quoted, while a non-NULL value matching the NULL parameter string is quoted.
For example, with the default settings, a NULL is written as an unquoted empty string, while an empty string data value is written with double quotes.
Note that CSV files produced may contain quoted values containing embedded carriage returns and line feeds. Thus the files are not strictly one line per table row like text-format files.
The first row of the CSV file is a header that describes the contents of each column in subsequent rows.
Usually the ZIP file will contain only a single CSV file. However it is possible that the (from_block, to_block) request spans over a range of blocks in which the underlying schema of the database changes. For example, a column may have been added, removed, or renamed.
If this happens, the CSV file will be split at the point of the schema change and the zip file will contain multiple CSV files, with a potentially different set of headers. The 'version' number of the database schema is part of the in the CSV filename:
[chain id]-[table name]-[schema version]-[start block]-[end block].zip
For example, a zip file might be called mainnet-sometable-000001-003000.zip
And contain two CSV files: mainnet-sometable-1-000001-002000.csv:
timestamp, value 1, foo 2, bar
And mainnet-sometable-2-002001-003000.csv:
timestamp, value, extra_value 3, baz, apple
It is worth noting that the schema will not change within a single network history segment. buf:lint:ignore RPC_RESPONSE_STANDARD_NAME buf:lint:ignore RPC_REQUEST_RESPONSE_UNIQUE
Query Parameters
Block to begin exporting from. Must be the first block of a history segment, which by default are 1000 blocks each; in that case - 1, 1001, 2001 etc. are valid values. This can be checked by first calling the API to list all network history segments.
Last block to export up to and including. Must be the last block of a history segment which by default are 1000 blocks each; in that case - 1000, 2000, 3000 etc. are valid values. This can be checked by first calling the API to list all network history segments.
Possible values: [TABLE_UNSPECIFIED
, TABLE_BALANCES
, TABLE_CHECKPOINTS
, TABLE_DELEGATIONS
, TABLE_LEDGER
, TABLE_ORDERS
, TABLE_TRADES
, TABLE_MARKET_DATA
, TABLE_MARGIN_LEVELS
, TABLE_POSITIONS
, TABLE_LIQUIDITY_PROVISIONS
, TABLE_MARKETS
, TABLE_DEPOSITS
, TABLE_WITHDRAWALS
, TABLE_BLOCKS
, TABLE_REWARDS
]
Default value: TABLE_UNSPECIFIED
Table to export data from.
- 200
- 500
- default
A successful response.(streaming responses)
Schema
error object
result object
{
"error": {
"code": 0,
"details": [
{
"@type": "string"
}
],
"message": "string"
},
"result": {
"contentType": "string",
"data": "string",
"extensions": [
{
"@type": "string"
}
]
}
}
An internal server error
Schema
details object[]
{
"code": 0,
"details": [
{
"@type": "string"
}
],
"message": "string"
}
An unexpected error response.
Schema
details object[]
{
"code": 0,
"details": [
{
"@type": "string"
}
],
"message": "string"
}
GET /api/v2/networkhistory/export
Request
Request
curl -L -X GET 'https://api.n06.testnet.vega.xyz/api/v2/networkhistory/export' \
-H 'Accept: application/json'
curl -L -X GET 'https://api.n06.testnet.vega.xyz/api/v2/networkhistory/export' \
-H 'Accept: application/json'
curl -L -X GET 'https://api.n06.testnet.vega.xyz/api/v2/networkhistory/export' \
-H 'Accept: application/json'
curl -L -X GET 'https://api.n06.testnet.vega.xyz/api/v2/networkhistory/export' \
-H 'Accept: application/json'