This is a simple Python API to access WeatherNext forecasting datasets stored in BigQuery.
-
Install dependencies:
pip install -r requirements.txt
-
Set up your environment:
Create a
.env
file in the root of the project and add your GCP Project ID:GCP_PROJECT_ID="your-gcp-project-id"
-
Authenticate with Google Cloud:
Make sure you have the
gcloud
CLI installed and authenticated:gcloud auth application-default login
-
Start the server:
uvicorn main:app --reload
-
Access the API documentation:
Once the server is running, you can access the interactive API documentation at http://127.0.0.1:8000/docs.
curl -X 'GET' \
'http://127.0.0.1:8000/forecast?init_date=2023-04-18&lat=40.416775&lon=-3.703790&model=gfs&variables=temperature_2m_above_ground,total_precipitation_surface' \
-H 'accept: application/json'
An example of how to use this API in a Jupyter Notebook can be found in the api_example_notebook.ipynb
file. This notebook can be run in Google Colab or a local Jupyter environment.
To run the unit tests, run the following command from the root of the project:
virtualenv/bin/python3 -m pytest