A Python client for interacting with AskTheEU.org to create and manage freedom of information requests to EU institutions. This logic mostly follows previous work from the Data Investigations Team on monitoring meetings between the European Commission and the gas lobby – see here.
Note: it requires a Pro subscription.
- Python 3.9+
- Make
-
Clone the repository:
git clone https://github.com/yourusername/gw-asktheeu-client.git cd gw-asktheeu-client -
Copy the example environment file and configure your credentials:
cp .env.example .env # Edit .env with your credentials -
Install dependencies:
make setup
-
The
data/public-bodies.csvfile contains a mapping of institution URLs to their IDs. A sample file is provided, but you may need to update it with actual IDs from AskTheEU.org.
You can test your login credentials with:
make test-loginTo test creating a draft FOI request to the Secretariat General:
make test-draftThis will create a draft request (but not send it) and provide detailed debug information.
The client is flexible and will try multiple methods to create FOI requests:
- First attempts using the Alaveteli Pro interface
- If Pro access isn't available, falls back to standard interface
- Login matches the format shown in the example.txt file
- Supports draft creation and sending FOI requests
- Provides detailed debugging information when needed
Basic example of creating a draft FOI request:
from asktheeu_client import AskTheEUClient
# Create client (will use credentials from .env file)
client = AskTheEUClient()
# Log in to AskTheEU.org with debugging enabled
if client.login(debug=True):
# Create a draft FOI request (tries Pro interface first, then falls back to standard)
result = client.create_draft_request(
public_body_id="576", # ID of the institution (e.g., 576 for Secretariat General)
title="Request for documents related to X",
body="Dear Sir/Madam,\n\nUnder Regulation 1049/2001, I am requesting access to documents concerning X...\n\nYours faithfully,",
debug=True # Enable detailed debugging output
)
if result["success"]:
print(f"Draft created: {result['draft_url']}")
print(f"Interface used: {result.get('method', 'unknown')}")
# Optionally send the request
# Note: is_pro parameter should match the method used to create the draft
is_pro = result.get('method') == 'pro_interface'
send_result = client.send_request(result["draft_id"], is_pro=is_pro)
if send_result["success"]:
print(f"Request sent: {send_result['request_url']}")
else:
print(f"Error creating draft: {result.get('error')}")
else:
print("Login failed")