Leaderboard API provides access to data for Alien Worlds leaderboard.
The API is responsible to only serve the data which is populated into database by the history tools.
To learn more about history tools and how to read data from blockchain and populate into database, please refer to the respective repository leaderboard-api-history-tools.
The Leaderboard API is available in three environments - Production, Staging, and Development - each has its own purpose and is used for different stages of the development process.
-
Production (https://api.alienworlds.io) It is the live version of the API, used by end-users to access leaderboard data.
-
Staging (https://api-stage.alienworlds.io) It serves the upcoming release candidate API, where new features and changes are tested by the UI team before being deployed to Production environment.
-
Development (https://api-dev.alienworlds.io) It is used internally by the API development team to test new features and changes before deploying to staging environment. This environment may have more frequent updates and changes.
HTTP Method: GET
Endpoint: /v1/leaderboard/list
List leaderboard entries.
timeframe
- Possible values
daily
(default)weekly
monthly
- Possible values
sort
- Possible values
tlm_gains_total
(default)total_nft_points
avg_charge_time
avg_mining_power
avg_nft_power
lands_mined_on
planets_mined_on
unique_tools_used
- Possible values
order
- Possible values
-1
- Descending (default)1
- Ascending
- Possible values
offset
- Number of items to skip before starting to return result set.
- Default:
0
limit
- Number of result items to return.
- Default:
10
date
- Date within the specified
timeframe
. Based on this value, the start (fromDate
) and end (toDate
) of the timeframe will be calculated
- Date within the specified
fromDate
- Fixed timeframe start value in ISO 8601 format e.g.
2022-04-17T00:00:00.000Z
. - If
date
is also specified, thenfromDate
will override it
- Fixed timeframe start value in ISO 8601 format e.g.
toDate
- Fixed timeframe end value in ISO 8601 format e.g.
2023-02-12T00:00:00.000Z
. - If
date
is also specified, thentoDate
will override it
- Fixed timeframe end value in ISO 8601 format e.g.
HTTP Method: GET
Endpoint: /v1/leaderboard/find
Find leaderboard data for a specific user.
user
- Wallet Id of the user to find
timeframe
- Possible values
daily
(default)weekly
monthly
- Possible values
date
- Date within the specified
timeframe
. Based on this value, the start (fromDate
) and end (toDate
) of the timeframe will be calculated
- Date within the specified
fromDate
- Fixed timeframe start value in ISO 8601 format e.g.
2022-04-17T00:00:00.000Z
. - If
date
is also specified, thenfromDate
will override it
- Fixed timeframe start value in ISO 8601 format e.g.
toDate
- Fixed timeframe end value in ISO 8601 format e.g.
2023-02-12T00:00:00.000Z
. - If
date
is also specified, thentoDate
will override it
- Fixed timeframe end value in ISO 8601 format e.g.
HTTP Method: GET
Endpoint: /v1/leaderboard/health
Displays the current state of the api.
HTTP Method: GET
Endpoint: /v1/leaderboard/docs
Swagger API Documentation
Before running the API on your local machine, ensure that you have the following installed:
- Node.js
- Node package manager (yarn or npm)
- MongoDB native installation or running inside a Docker container
- Redis native installation or running inside a Docker container
Optionally, you can choose to install the following tools or any other alternatives.
- RedisInsight - Redis Client
- Compass - The GUI for MongoDB
- Docker to run MongoDB and Redis (if not installed natively)
git clone https://github.com/Alien-Worlds/leaderboard-api.git
You need a .env file which contains all necessary environment configuration for Leaderboard API. An example config file is available at .env-example.
You can copy the example config and create a .env file
cp .env-example .env
Afterwards, the newly created .env file can be modified according to your needs.
Run MongoDB either with native installation or using Docker.
To use Docker, an example Docker Compose file for MongoDB is available at docker-compose-mongodb.yml
Run Redis either with native installation or using Docker.
To use Docker, an example Docker Compose file for Redis is available at docker-compose-redis.yml
yarn
yarn build
yarn start
Please check Postman API collection
.postman/leaderboard-api.postman_collection.json
The respective environment files for local, dev, stage and prod are also placed under .postman/environments/leaderboard-*.postman_environment.json e.g.
.postman/environments/leaderboard-local.postman_environment.json
Swagger document is automatically generated based on Postman API collection using postman-to-openapi library.
After update in Postman collection (leaderboard-api.postman_collection.json), run the following command to update the Swagger document.
yarn docs:generate
Latest swagger document can be found at ./docs/leaderboard-api-oas.yaml.