GraphQL API 1.0 migration
Described changes are to be introduced in the end of August 2023. Learn how to make the transition seamless for your applications.
About coming changes
There will be several announcements prior to the actual API transition, which is planned for approximately the end of August 2023.
The transition will first happen on Venom testnet network, later followed by other supported networks.
To stay updated on the transition, you can monitor this page or join this channel for announcements.
As TVM blockchains adoption grows, and with it blockchain load, so does the load on GraphQL API. To be able to cope with large amounts of data, GraphQL API is being refactored.
Major changes
The Collections API for blocks, transactions and messages in the new version will only provide data from the last 7 days. To retrieve older (archive) data of blocks, transactions end messages, you need to use the
blockchain{...}
API witharchive: true
mode on.
☝ The access to archive data will have rps limits, so make sure you don’t implement many requests per second if you specify archive: true
. Limit yourself with maximum of 5 requests of archive data per second from one ip address. If you need higher rate contact @EkaterinaPantaz
The Accounts collection will not provide account boc, code and data anymore. Use
blockchain{account(address:"address"){info{boc}}
} for that.
Specification
Take a look at the updated API. Read comments carefully.
Detailed documentation of Blockchain API is available here.
Migration guide
To prepare for the transition from current functionality to the new one, and make sure it happens seamlessly, developers should migrate their queries as soon as possible - before the actual release of the new API, which will happen in the end of August 2023.
We have released a flag called 'archive
' for this purpose. Currently, this flag has no functionality (the API works the same way whether archive=true
or false
), but it helps in migrating to the new API. When you migrate, the switch from the old API to the new one will be under the hood and invisible to your application.
Be sure to specify the archive=true
flag only in places where you need to retrieve blocks, transactions end messages data older than 7 days. If you do not require old data, do not include the flag.
Accounts data is still available in full. You do not need the archive
flag to get data of accounts created more than 7 days ago.
Note: If you could not find a suitable query for your use case in the blockchain API, please message @EkaterinaPantaz in Telegram, and we will see what we can do to prepare for migration in your individual case.
The Evercloud team has collected and analyzed API usage statistics and developed an updated blockchain API that covers over 95% of use cases involving archive data. If your use case falls within the <5% where the new API is or seems entirely inapplicable, please also contact @Ekaterina Pantaz, and we will work together to adapt your use case to the API or vice versa.
Query migration samples
Get account data
Get account information
Old query:
New query:
Get external outbound messages from account to :external_address
Retrieve the last 2 external outbound messages from src_address
to the “:external address
”
Old query:
New query:
Get the last 2 src_address
' s ExtOut
messages filtered by ":external_address
" counterparty and save the last message cursor for the next reads.
Get account messages after timestamp
Get 100 messages of account $p3 of type $p2 created after timestamp $p1 with value>0 sorted by creation timestamp ASC.
Old query
Pagination is implemented by created_at field. To get the next 50 messages one needs to get pass the created_at value $p1 of the last message into the created_at:{gt:$p1} filter.
☝ Pagination was implemented by created_at timestamp. Please, note that this pagination is not correct and may end up with data loss in case of several messages (more than 50) created per 1 second, which may happen in highly loaded blockchains.
New query
☝ This approach is reliable without data loss
Now query first page (one page is 50 messages) messages of needed types starting from $start with min value=1 nanotoken.
Available message types are
ExtIn
(External inbound),ExtOut
(External outbound),IntIn
(Internal inbound),IntOut
(Internal outbound).
And now the second page after endCursor
= “59e5c7c0059f9522070001”
Get account transactions
Get last 100 account transactions in descending order
Old query
New query
☝ Note that sorting order in blockchain
api is always in ascending order, so if you need to process the data in descending order on the client, sort it by cursor field in descending order on the client side
Here we get last 50 transactions of account
and now in the second query we get last 50 transactions before the startCursor
from the result of the previous query
Get transaction/message/block data (including historic)
Old queries
New queries:
☝ Make sure to specify archive
flag according to your use-case
Last updated