There are quite a few exchange rate APIs out there to get the latest and historic exchange rates. Google used to have a nice, simple and free one – the finance API, but that was disabled some time ago. You can still get exchange rates and lots of other things using the GoogFinance workbook function, but you’re going to need to be adding that as formula in your spreadsheet, as there’s not a public end point for that (but watch this space for a future post on a workaround for that).
Here's a fx library for Apps Script using
swop.cx