- Potlock Indexer (Django / Poetry / Celery / NEAR Lake Framework)
- Django w/ Poetry
- Celery for background indexer task
- NEAR Data Lake Framework for fetching/listening for blocks
- Set up env vars via
~/.bashrc
or~/.zshrc
(see below) - Install poetry
- Install redis
- Install postgres
- Create postgres database
potlock
for userpostgres
- Activate poetry shell (
poetry shell
) - Install dependencies (
poetry install
) - Run migrations (
python manage.py migrate
) - Update
indexer_app.tasks.listen_to_near_events
with desired network & start block (if desired) - Start celery worker with logger (
celery -A base worker --loglevel=info
) - Start indexer (
python manage.py runindexer
) - Kill indexer (
python manage.py killindexer
)- If for some reason this doesn't kill any active celery tasks, run
ps auxww | grep 'celery' | grep -v grep
and kill resulting PIDs
- If for some reason this doesn't kill any active celery tasks, run
Extra commands that might come in useful:
- Purge celery queue (
celery -A base purge
)
export PL_AWS_ACCESS_KEY_ID=
export PL_AWS_SECRET_ACCESS_KEY=
export PL_CACHALOT_ENABLED=False
export PL_DEBUG=True
export PL_ENVIRONMENT=local
export PL_LOG_LEVEL=debug
export PL_POSTGRES_DB=potlock
export PL_POSTGRES_HOST=127.0.0.1
export PL_POSTGRES_PASS=
export PL_POSTGRES_PORT=5432
export PL_POSTGRES_USER=$USER
export PL_REDIS_HOST=
export PL_REDIS_PORT=6379
export PL_SENTRY_DSN=
dev (mainnet): https://dev.potlock.io/api/v1/
testnet: https://test-dev.potlock.io/api/v1/
This is a public, read-only API and as such does not currently implement authentication or authorization.
Rate limits of 100 requests/min are enforced to ensure service for all users.
An error response (status code not within range 200-299) will always contain an object body with a message
string property containing more information about the error.
Possible Error Codes:
400
(Bad Request)- Error in client request
404
(Not found)- Requested resource could not be located
500
(Internal Error)- Check
message
string for more information
- Check
Pagination available using limit
and offset
query params on endpoints that specify paginated
. Default limit
is 30.
Endpoints that support pagination will return a success response containing the following:
count
(int) - total number of items availablenext
(str | null) - pre-populated endpoint link to the next page of resultsprevious
(str | null) - pre-populated endpoint link to the previous page of resultsresults
(any[]) - array of results
NB: These endpoints are what is required to integrate with BOS app & replace current RPC calls, but more endpoints can easily be added as needed.
Can specify status=live
query param to retrieve only pots that are currently active (live matching round)
Can specify status to filter by using status
query param if desired, e.g. status=Approved
Returns all accounts that have sent at least one donation.
Optional query params:
sort
(currently only allowed value ismost_donated_usd
, which returns results in the order of most to least donated in USD) e.g.?sort=most_donated_usd
NB: POT_ID
== on-chain Pot address
Returns:
total_donations_usd
total_payouts_usd
total_donations_count
total_donors_count
total_recipients_count