Hi, everyone. Welcome to this API.
An API to query population, GDP per capita by years, countries, etc. that returns pretty tables and graphs.
This API has four primary endpoints:
- json (
/json
-> Returns JSON response ) - table (
/table
-> Returns table response ) - graph (
/graph
-> Returns graph response ) - stats (
/stats
-> Returns stats response )
It's a collaborative open-source project Raisa and I did (are doing) as a part of our code submission to Mercor Hackathon. We have exposed all of our APIs in our API documentation. Feel free to test APIs there (You will be able to try them on-screen).
This API might be (extremely!) slow, as both the backend server (deployed on Vercel) and database (hosted on Railway) are deployed using the free plan. Nevertheless, we tried to optimize the database queries to compensate for that (Apologies!).
To quickly jump to a subsection,
- The application is hosted on Vercel.
![image](https://private-user-images.githubusercontent.com/64671908/251644929-6c1114cd-803b-4a63-967f-5fa0274a3ebf.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ0NTg2MTgsIm5iZiI6MTcyNDQ1ODMxOCwicGF0aCI6Ii82NDY3MTkwOC8yNTE2NDQ5MjktNmMxMTE0Y2QtODAzYi00YTYzLTk2N2YtNWZhMDI3NGEzZWJmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MjQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODI0VDAwMTE1OFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWMxYTdjNWVlYTYwMjUxMTk4YThiNTY5Nzk0NmU4NzA2NTRjNjgzMGJmMTRjYTg5MzFjMjcwNWU1Mzk2YjlhZDUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.zEbLMkkj2PdB2xJ2Vj6SvbSsGDfaG0Yxdv8FkHwgfrE)
Note: You don't currently have database access. We will be working on giving read-only access to all the contributors.
Nevertheless, you can always create your database and populate it with dummy data. Schema is available in the models.py
.
Open the terminal at the destination folder:
# Cloning the repository
git clone https://github.com/Aritra8438/EcoMetrics-API.git
cd EcoMetrics-API
# Creating a virtual environment
pip install virtualenv
# linux users
virtualenv venv
source venv/bin/activate
# Windows users
python -m virtualenv venv
./venv\Scripts\activate
# Download packages
pip install -r requirements.txt
Your virtual environment should be ready.
To bring up the server:
flask --app api/index run --debug
The essential APIs are unit-tested using pytest
and linted using pylint
. If you are contributing to this repo, it's recommended that you run pytest
and pylint
before your pull request.
- Open the project folder and run:
# run pytest
pytest
pytest -s (to get the output of the tests if you've used print statement inside)
pytest -k test_abc (to run a particular test)
# run pylint
pip install pylint (Required to run once)
pylint $(git ls-files '*.py')
Alternatively, you can search Pylint at the extension marketplace (in VSCode) and install the linter. The lint errors will be highlighted if Pylint is installed.
Currently, All the tests are linked to client
@pytest.fixture, which is in conftest.py
. If you have made changes to the backend, we recommend adding a pytest for it.
We have enabled codecov
and dependabot
for this repo. To learn about the workflows, please visit the corresponding .yml
files.
Hello contributors, here is the contribution guideline you should follow:
-
First, create a fork of this repo. (Available at the top right corner of the repo)
-
Go to the forked repository and Clone the fork of your repo to the destination folder.
$ git clone https://github.com/YOUR_USERNAME/YOUR_FORK.git
- Navigate to the Project repository
$ cd EcoMetrics-API
- Add Upstream to your clone
$ git remote -v
> origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch)
> origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (push)
$ git remote add upstream https://github.com/Aritra8438/EcoMetrics-API.git
$ git remote -v
> origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch)
> origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (push)
> upstream https://github.com/Aritra8438/EcoMetrics-API.git (fetch)
> upstream https://github.com/Aritra8438/EcoMetrics-API.git (push)
- Before making any changes, sync your origin with upstream
$ git pull upstream main --rebase
- Make some changes to the project. After that, open a new branch and commit the changes.
$ git checkout -b <new_branch>
$ git add .
$ git commit -m "Commit message"
$ git push origin <new branch>
- There will be a visible change in your repo, click on that and create a new pull request.
Thank you for your contribution.
All of our APIs are available at this documentation. The documentation has a minimum design (Apologies!) but we intend to keep it as it is because It enables on-screen testing with HTML response.
Here is a screenshot of the same.
![image](https://private-user-images.githubusercontent.com/64671908/251658658-17d13fe3-ce00-45fe-a286-a675d52f2a8d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ0NTg2MTgsIm5iZiI6MTcyNDQ1ODMxOCwicGF0aCI6Ii82NDY3MTkwOC8yNTE2NTg2NTgtMTdkMTNmZTMtY2UwMC00NWZlLWEyODYtYTY3NWQ1MmYyYThkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MjQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODI0VDAwMTE1OFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTM2YWRiMDEyNjU2YjY3MGVjNjgwMDMzZWJjMzYwN2EyNDY4MTBjYWQ1OWQxOTE3MGRiMjhmNzBiNjIwMThhZmYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.AQ0D5-xDt-YOY1fKXHH2qulo8TtO-WtNdlLROBdgS84)
- Support for
population
database. - Support for effective querying.
- Support for
GDP per capita
database. - Support for comparing data from different databases.
- Support for the
Forest Area percentage
database. - Support for
Annual average temperature
database.
- Support for predicting data when input has future years as input.
- Support for extremely user-friendly and customizable graphs.