pycon-rwanda / Endangered-Species-Tracker

The "Endangered Species Tracker" is a Python project aimed at raising awareness and providing information about endangered species around the world.
MIT License
4 stars 10 forks source link

Update tracker.py #18

Closed DevyRuxpin closed 1 month ago

DevyRuxpin commented 1 month ago

Full disclosure I have only been coding for last 6 months or so. I am trying to help open source repositories as part of hacktoberfest2024 . Apologies in advance if there are things I missed.

Improve Logging: Use [logger.exception] to capture stack trace in case of exceptions.

Optimize API Call: Add a timeout to the [requests.get] call to prevent hanging indefinitely.

Handle Missing API Key: Add a check to ensure the API key is loaded correctly. Validate API Response: Add checks to ensure the API response is valid JSON.