Simple dRofus Read/Write API in Python
This guide walks you through how to interact with the dRofus API using Python. We'll use the Client Credentials Authentication method to access the API.
Prerequisites
Before starting, set up your Python environment and install the required libraries by running:
pip install requests python-dotenv
1. Set up environment variables
In your project directory, create a .env
file that stores your API credentials:
DROFUS_CLIENT_ID=your_client_id_here
DROFUS_CLIENT_SECRET=your_client_secret_here
Replace your_client_id_here
and your_client_secret_here
with the actual credentials provided by Balazs.
2. Create the Python Script
You can use a script template provided in api_template.py (github.com), which provides a basic structure for authenticating.
Example Task: Fetch and Update Items
For example, to fetch all items named "Chair" and update their note field, refer to this code snippet in the following api_sample.py (github.com)