Python Library to connect to the NEAR Lake S3 and stream the data
Project description
NEAR Lake Framework for Python
Available in programming languages: Rust | Javascript | Python3
NEAR Lake Framework is a small library companion to NEAR Lake. It allows you to build your own indexer that subscribes to the stream of blocks from the NEAR Lake data source and create your own logic to process the NEAR Protocol data.
Official NEAR Lake Framework launch announcement has been published on the NEAR Gov Forum Greetings from the Data Platform Team! We are happy and proud to announce an MVP release of a brand new word in indexer building approach - NEAR Lake Framework.
Example
import asyncio
from near_lake_framework import LakeConfig, streamer
async def main():
config = LakeConfig.mainnet()
config.start_block_height = 69130938
config.aws_access_key_id = "YOUR_AWS_ACCESS_KEY"
config.aws_secret_key = "YOUR_AWS_SECRET_KEY"
stream_handle, streamer_messages_queue = streamer(config)
while True:
streamer_message = await streamer_messages_queue.get()
print(
f"Received Block #{streamer_message.block.header.height} from Lake Framework"
)
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
How to use
Dependencies
Install near-lake-framework
$ pip3 install near-lake-framework
Credentials
To be able to access the data from NEAR Lake you need to provide credentials. Please, see the Credentials article
Configuration
Everything should be configured before the start of your indexer application via LakeConfig
struct.
Available parameters:
s3_bucket_name: str
- provide the AWS S3 bucket name (near-lake-testnet
,near-lake-mainnet
or yours if you run your own NEAR Lake)s3_region_name: str
- provide the region for AWS S3 bucketstart_block_height: BlockHeight
- block height to start the stream fromblocks_preload_pool_size: int
- provide the number of blocks to preload (default: 200)
Cost estimates
TL;DR approximately $18.15 per month (for AWS S3 access, paid directly to AWS) for the reading of fresh blocks
Explanation:
Assuming NEAR Protocol produces accurately 1 block per second (which is really not, the average block production time is 1.3s). A full day consists of 86400 seconds, that's the max number of blocks that can be produced.
According the Amazon S3 prices list
requests are charged for $0.005 per 1000 requests and get
is charged for $0.0004 per 1000 requests.
Calculations (assuming we are following the tip of the network all the time):
86400 blocks per day * 5 requests for each block / 1000 requests * $0.0004 per 1k requests = $0.173 * 30 days = $5.19
Note: 5 requests for each block means we have 4 shards (1 file for common block data and 4 separate files for each shard)
And a number of list
requests we need to perform for 30 days:
86400 blocks per day / 1000 requests * $0.005 per 1k list requests = $0.432 * 30 days = $12.96
$5.19 + $12.96 = $18.15
The price depends on the number of shards
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for near-lake-framework-0.0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3305a1ae3ab6c16d4e15be3a460500801cb98b5a11ce0bda7f74c2bf8b07bc50 |
|
MD5 | 63e2df25c932a567730e708c56d241ad |
|
BLAKE2b-256 | cec926bc76f35bad0f5907f2a876894540f654409bc25b09e12a26739bd428b4 |
Hashes for near_lake_framework-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0b9748b821d4f0edf79355e5b329101988eabcb76f8fc92c7e3d84dbd51c8298 |
|
MD5 | 6f9b5e565a26d752101035d054076f31 |
|
BLAKE2b-256 | 615fd5a150e193e0a2559ec48e356c636de61e341cadda1b7e45bd9790eafbc6 |