This repository contains a collection of Python scripts intended as a starting point for developers looking to utilize the Global Forester API using Python and Swagger. These scripts can be used or combined as-is, or serve as inspiration for more complex implementations. To set up and run the scripts, follow the steps below.
See https://api.globalforester.com/swagger for more detailed information about the API.
The examples uses version 3 of the API, which is the recommended version.
Examples for version 2 of the API can be found here. Note that version 2 only supports fetching data. Version 1 of the API has ceased to be and is now history.
git clone https://github.com/peroper/GlobalForester-API.git
cd GlobalForester-API
It is recommended to install dependencies in a virtual environment. This will isolate project dependencies from other projects on the same computer. If you want to read more about virtual environments you can do so here: https://docs.python.org/3/library/venv.html
-
Create a virtual environment
python3 -m venv venv
-
Activate the virtual environment
source venv/bin/activate
-
Install dependencies
pip3 install -r requirements.txt
Via Homebrew:
brew install swagger-codegen
For other installation methods, see: https://github.com/swagger-api/swagger-codegen/tree/3.0.0
swagger-codegen generate -i https://api.globalforester.com/swagger/v3/swagger.json -o Swagger -l python
Scripts assume that the API Client is located in a folder called 'Swagger'
-
Enter your client ID and client secret in utils.py. Contact support if you don't have a client ID and client secret and API access is included in your Global Forester subscription.
-
Run any desired script with:
python3 name_of_script.py
-
To get more information about a script, run:
python3 name_of_script.py -h