35765-vm/core/etenders_api.py
Flatlogic Bot 1955ecf8b3 1.4
2025-11-15 19:14:03 +00:00

19 lines
581 B
Python

import requests
ETENDERS_API_URL = "https://www.etenders.gov.za/api/v1/tenders"
def get_tenders():
"""
Fetches a list of tenders from the eTenders API.
Returns:
list: A list of tenders as dictionaries, or None if an error occurs.
"""
try:
response = requests.get(ETENDERS_API_URL)
response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)
return response.json()
except requests.exceptions.RequestException as e:
print(f"Error fetching tenders from eTenders API: {e}")
return None