Updated the script to get data directly from the API.