Generating newsletter from API data

How would you go about taking data from an API and then getting that into a newsletter template and then send it to Mailchimp/Malierlite or another newsletter system?