I'm in CS50w, lecture 5 (JavaScript)

I have a problem in lecture 5(JavaScript) time: 1:34:40.

Brian said using http://api.exchangeratesapi.io/latest?base=USD in code below:

<!DOCTYPE html>
<html lang="en">
        <title>Curency Exchange</title>
            document.addEventListener('DOMContentLoaded', function() {

                .then(Response => Response.json())
                .then(data => {

But returns error!

enter image description here

Then I get tried exploring the link above, so that redirected to https://apilayer.com/. I have tried signing up and signing in Exchange Rates Data API Currency, So this gets me an API key.

But I'm not succeed get results Brian said in lecture mentioned above.

Helps are appreciated.

3 Answers 3


You want to check out the documentation for that api. It can be found here.

According to the documentation, after you get your API Key, you add it to the url as a parameter as such:

? access_key = API_KEY

where API_KEY is your key. You can still use the base parameter too, which would look like:

? access_key = API_KEY
& base = USD
  • I have tried fetch('https://api.exchangeratesapi.io/v1/latest?access_key=cjUP2T7CmZ3DFUWWRCWOcA2lQekDDogW&base=USD') and still revived error: Object { code: "invalid_access_key", message: "You have not supplied a valid API Access Key." }
    – parmer_110
    Commented Mar 4, 2023 at 18:36
  • Still I have "invalid_access_key" error in using https://api.exchangeratesapi.io/v1/latest?access_key=cjUP2T7CmZ3DFUWWRCWOcA2lQekDDogW But What is the problem?
    – parmer_110
    Commented Mar 4, 2023 at 19:02

I have found out the structure of https://api.exchangeratesapi.iohad changed.

  1. Auto redirecting to the https://apilayer.com/
  2. The API_KEY now is apikey


enter image description here

Reff: https://apilayer.com/


This api is a drop-in replacement https://api.exchangerate.host/latest?base=USD'

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .