An API to query population, temperature etc. that returns pretty table and graphs
MIT License
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
-> Returns JSON response )/table
-> Returns table response )/graph
-> Returns graph response )/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,
Our website is live!
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.
# 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
$ cd EcoMetrics-API
$ 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)
$ git pull upstream main --rebase
$ git checkout -b <new_branch>
$ git add .
$ git commit -m "Commit message"
$ git push origin <new branch>
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.
population
database.GDP per capita
database.Forest Area percentage
database.Annual average temperature
database.