You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Pseudo code:
For example, if you want to fetch eur:
Fetch https://cdn.jsdelivr.net/npm/@fawazahmed0/currency-api@latest/v1/currencies/eur.min.json
If above url fails, then try fetching https://latest.currency-api.pages.dev/v1/currencies/eur.min.json
If above url fails, then try fetching https://cdn.jsdelivr.net/npm/@fawazahmed0/currency-api@latest/v1/currencies/eur.json
If above url fails, then try fetching https://latest.currency-api.pages.dev/v1/currencies/eur.json
Reacted by Gowtham, ritunagar, Anusha Fatima Ali, Hammad Shafqat, V Baby Dora, Konstantin Merenkov, Sahil.shaikh.87, Shivam Kumar, bhartidhotre, Artem Tabenskii and 5 more
asyncfunctiongetUsdInrRate(){// This url will give you currencies UDS/XXXconsturl='https://cdn.jsdelivr.net/npm/@fawazahmed0/currency-api@latest/v1/currencies/usd.min.json'// Fetch data and get INR rateconstinr=awaitfetch(url).then(response=>response.json()).then(data=>data['usd'].inr)console.log(inr)}getUsdInrRate()
i face the same issue do you have its solution ???
check out my github page https://gowthamssr.github.io/currency_converter/ are u looking for this functionality @KerasirovED helped me
this is problem faced because the API is changed
refer this it may help u....
const updateExchangeRate=async()=>{
let amount=document.querySelector(".amount input");
let amtValue=amount.value;
if(amtValue===" " || amtValue<1){
amtValue=1;
amount.value="1";
}
const URL=`${Base_Url}/${fromCurr.value.toLowerCase()}/${toCurr.value.toLowerCase()}.json()`;
let response= await fetch(Base_Url);
let data= await response.json();
let rate= data[toCurr.value.toLowerCase()];
let finalamount =amtValue * rate;
msg.innerText=`${amtValue} ${fromCurr.value} = ${finalamount} ${toCurr.value}`;
console.log(rate);
console.log(data);
console.log(finalamount);
};
const updateflag=(element)=>{
let currcode= element.value;
let countrycode=countryList[currcode];
let newsrc=https://flagsapi.com/${countrycode}/flat/64.png;
let image=element.parentElement.querySelector("img");
image.src=newsrc;
};
//
btn.addEventListener("click",async(evt)=>{
evt.preventDefault();
updateExchangeRate();
});
@Aishaarain
const API_KEY = 'your_api_key_here'; // Replace with your actual API key
const Base_Url = https://api.exchangeratesapi.io/v1/latest?access_key=${API_KEY};
@Gowthamssr , i think there is another issue in my code , i have tried alot APIS but none is working, do you know why it is happened. this error is displayed=>
success: false,
error: {…}}error: {code: 101, type: 'invalid_access_key', info: 'You have not supplied a valid API Access Key. [Technical Support: support@apilayer.com]'}
success: false[[Prototype]]: Object
let response = await fetch(URL);
if (!response.ok) {
msg.innerText = "Error fetching exchange rate.";
return;
}
let data = await response.json();
let rate = data[toCurr.value.toLowerCase];
const updateflag=(element)=>{
let currcode= element.value;
let countrycode=countryList[currcode];
let newsrc=https://flagsapi.com/${countrycode}/flat/64.png;
let image=element.parentElement.querySelector("img");
image.src=newsrc;
};
//
btn.addEventListener("click",async(evt)=>{
evt.preventDefault();
updateExchangeRate();
});
for (let select of dropdowns){
for (let currCode in countryList){
let newOPtions = document.createElement('option');
newOPtions.innerText = currCode;
newOPtions.value = currCode;
Activity
e7raem commentedon Mar 5, 2024
Whats the difference between
eur.min.jsonvseur.json?fawazahmed0 commentedon Mar 6, 2024
eur.min.jsonhas no white space to reduce file sizegaganpreetsharma000 commentedon Mar 14, 2024
brother please help.. i am new to programing. just making currency converter.
you have migrated the files to github. I want to use this link https://cdn.jsdelivr.net/gh/fawazahmed0/currency-api@1/latest/currencies/eur/jpy.json in my code but i can't. so as per the given instructions i figured out a little bit and i was able to make this link https://cdn.jsdelivr.net/npm/@fawazahmed0/currency-api@latest/v1/currencies/inr.json but at the last of this link i need usd/inr.json Plz help me out
egogre commentedon Mar 15, 2024
@gaganpreetsharma000, have you seen the migration instruction? It's pretty clear.
By the url, https://cdn.jsdelivr.net/npm/@fawazahmed0/currency-api@latest/v1/currencies/inr.json you are fetching data in the rate INR/XXX, where XXX is another currecy from the got JSON, e.g. USD. In that case, one INR costs 0.012070684 USD.
As you need usd/inr, you have to fetch data USD/XXX: https://cdn.jsdelivr.net/npm/@fawazahmed0/currency-api@latest/v1/currencies/usd.json, where you'll get a cost of one USD in different currencies, and select the needed one from the received JSON, in your case INR.
Try
You'll get current rate
Tip
Use min versions of the files to get reduced files (whitespaces deleted), and faster responses, I assume.
Instead of 'https://cdn.jsdelivr.net/npm/@fawazahmed0/currency-api@latest/v1/currencies/usd.json'
Use 'https://cdn.jsdelivr.net/npm/@fawazahmed0/currency-api@latest/v1/currencies/usd.min.json'
I used the second one in the code
vandana-khatri8 commentedon Apr 22, 2024
i face the same issue do you have its solution ???
owaismohammed79 commentedon Jun 30, 2024
I've tried all the fallback URLs but I don't think they work when sent through a node environment. When I try the same on a browser they seem to work

Gowthamssr commentedon Jun 30, 2024
check out my github page https://gowthamssr.github.io/currency_converter/ are u looking for this functionality @KerasirovED helped me
this is problem faced because the API is changed
refer this it may help u....
................................................................................................................................................................................................................................
const BASE_URL ="https://cdn.jsdelivr.net/npm/@fawazahmed0/currency-api@latest/v1/currencies"//usd.min.json"
// "https://cdn.jsdelivr.net/gh/fawazahmed0/currency-api@1/latest/currencies";
const dropdowns = document.querySelectorAll(".dropdown select");
const btn = document.querySelector("form button");
const fromCurr = document.querySelector(".from select");
const toCurr = document.querySelector(".to select");
const msg = document.querySelector(".msg");
for (let select of dropdowns) {
for (currCode in countryList) {
let newOption = document.createElement("option");
newOption.innerText = currCode;
newOption.value = currCode;
if (select.name === "from" && currCode === "USD") {
newOption.selected = "selected";
} else if (select.name === "to" && currCode === "INR") {
newOption.selected = "selected";
}
select.append(newOption);
}
select.addEventListener("change", (evt) => {
updateFlag(evt.target);
});
}
const updateExchangeRate = async () => {
let amount = document.querySelector(".amount input");
let amtVal = amount.value;
if (amtVal === "" || amtVal < 1) {
amtVal = 1;
amount.value = "1";
}
const URL =
${BASE_URL}/${fromCurr.value.toLowerCase()}.min.json;///${toCurr.value.toLowerCase()}.json`;let response = await fetch(URL);
let data = await response.json();
console.log(data);
let from = fromCurr.value.toLowerCase();
console.log(from);
let to = toCurr.value.toLowerCase();
console.log(to);
let rate = data[from][to];
let finalAmount = amtVal * rate;
msg.innerText =
${amtVal} ${fromCurr.value} = ${finalAmount} ${toCurr.value};};
const updateFlag = (element) => {
let currCode = element.value;
let countryCode = countryList[currCode];
let newSrc =
https://flagsapi.com/${countryCode}/flat/64.png;let img = element.parentElement.querySelector("img");
img.src = newSrc;
};
btn.addEventListener("click",(evt) => {
evt.preventDefault();
// let amount = document.querySelector(".amount input");
// let amtVal = amount.value;
// if(amtVal === "" || amtVal < 1)
// {
// amtVal = 1;
// amount.value = "1";
// }
// const URL =
${BASE_URL}/${fromCurr.value.toLowerCase()}/${toCurr.value.toLowerCase()}.json// let response = await fetch(URL);
// let data = await response.json;
// let rate = data[toCurr.value.to.toLowerCase()];
// let finalAmount = amtVal*rate;
// msg.innerText =
${amtVal} ${fromCurr} = ${finalAmount} ${toCurr.value}updateExchangeRate();
});
window.addEventListener("load",() => {
updateExchangeRate();
});
follow me on https://www.linkedin.com/in/gowtham-ssr-1a5858280/
Gowthamssr commentedon Jun 30, 2024
i have posted just now
Aishaarain commentedon Jun 30, 2024
this URL is still not working , please any solution u can suggest to me, i have also tried all fallbacks url's, but still not working.
Aishaarain commentedon Jul 1, 2024
const Base_Url= "https://api.exchangeratesapi.io/v1/latest? access_key = API_KEY";
const dropdown=document.querySelectorAll(".drop_down select");
const btn=document.querySelector("form button");
const fromCurr=document.querySelector(".from select");
const toCurr=document.querySelector(".to select");
const msg=document.querySelector(".msg");
for(let select of dropdown){
for (currcode in countryList){
let newOption=document.createElement("option");
newOption.innerText=currcode;
newOption.value=currcode;
select.append(newOption);
if(select.name==="from" && currcode==="USD"){
newOption.selected="selected";
}
else if(select.name==="to" && currcode==="PKR"){
newOption.selected="selected";
}
}
select.addEventListener("change",(evt)=>{
updateflag(evt.target);
});
}
const updateExchangeRate=async()=>{
let amount=document.querySelector(".amount input");
let amtValue=amount.value;
if(amtValue===" " || amtValue<1){
amtValue=1;
amount.value="1";
}
const updateflag=(element)=>{
let currcode= element.value;
let countrycode=countryList[currcode];
let newsrc=
https://flagsapi.com/${countrycode}/flat/64.png;let image=element.parentElement.querySelector("img");
image.src=newsrc;
};
//
btn.addEventListener("click",async(evt)=>{
evt.preventDefault();
updateExchangeRate();
});
document.addEventListener("load",()=>{
updateExchangeRate();
});
this is my JS code i have tried different apis but it does not run, i am getting this error=>
401 (Unauthorized)
Gowthamssr commentedon Jul 1, 2024
@Aishaarain
const API_KEY = 'your_api_key_here'; // Replace with your actual API key
const Base_Url =
https://api.exchangeratesapi.io/v1/latest?access_key=${API_KEY};const dropdown = document.querySelectorAll(".drop_down select");
const btn = document.querySelector("form button");
const fromCurr = document.querySelector(".from select");
const toCurr = document.querySelector(".to select");
const msg = document.querySelector(".msg");
for (let select of dropdown) {
for (let currcode in countryList) {
let newOption = document.createElement("option");
newOption.innerText = currcode;
newOption.value = currcode;
select.append(newOption);
if (select.name === "from" && currcode === "USD") {
newOption.selected = "selected";
} else if (select.name === "to" && currcode === "PKR") {
newOption.selected = "selected";
}
}
}
const updateExchangeRate = async () => {
let amount = document.querySelector(".amount input");
let amtValue = amount.value;
if (amtValue === "" || amtValue < 1) {
amtValue = 1;
amount.value = "1";
}
};
const updateFlag = (element) => {
let currcode = element.value;
let countrycode = countryList[currcode];
let newsrc =
https://flagsapi.com/${countrycode}/flat/64.png;let image = element.parentElement.querySelector("img");
image.src = newsrc;
};
btn.addEventListener("click", async (evt) => {
evt.preventDefault();
updateExchangeRate();
});
document.addEventListener("DOMContentLoaded", () => {
updateExchangeRate();
});
Aishaarain commentedon Jul 2, 2024
Aishaarain commentedon Jul 2, 2024
@Gowthamssr , i think there is another issue in my code , i have tried alot APIS but none is working, do you know why it is happened. this error is displayed=>
success: false,
error: {…}}error: {code: 101, type: 'invalid_access_key', info: 'You have not supplied a valid API Access Key. [Technical Support: support@apilayer.com]'}
success: false[[Prototype]]: Object
this is my code=>
const Base_Url = "http://data.fixer.io/api/latest?access_key=7370ff2962d49abefc56c32f5bc74aa8";
const dropdown=document.querySelectorAll(".drop_down select");
const btn=document.querySelector("form button");
const fromCurr=document.querySelector(".from select");
const toCurr=document.querySelector(".to select");
const msg=document.querySelector(".msg");
for(let select of dropdown){
for (currcode in countryList){
let newOption=document.createElement("option");
newOption.innerText=currcode;
newOption.value=currcode;
select.append(newOption);
if(select.name==="from" && currcode==="USD"){
newOption.selected="selected";
}
else if(select.name==="to" && currcode==="PKR"){
newOption.selected="selected";
}
}
select.addEventListener("change",(evt)=>{
updateflag(evt.target);
});
}
const updateExchangeRate=async()=>{
let amount=document.querySelector(".amount input");
let amtValue=amount.value;
if(amtValue===" " || amtValue<1){
amtValue=1;
amount.value="1";
}
let response = await fetch(URL);
if (!response.ok) {
msg.innerText = "Error fetching exchange rate.";
return;
}
let data = await response.json();
let rate = data[toCurr.value.toLowerCase];
let finalAmount = amtValue * rate;
msg.innerText =
${amtValue} ${fromCurr.value} = ${finalAmount} ${toCurr.value};console.log(rate);
console.log(data);
console.log(finalAmount);
};
const updateflag=(element)=>{
let currcode= element.value;
let countrycode=countryList[currcode];
let newsrc=
https://flagsapi.com/${countrycode}/flat/64.png;let image=element.parentElement.querySelector("img");
image.src=newsrc;
};
//
btn.addEventListener("click",async(evt)=>{
evt.preventDefault();
updateExchangeRate();
});
document.addEventListener("load",()=>{
updateExchangeRate();
});
Narendrag20 commentedon Jul 17, 2024
Hello,
This link is not working Could you please help me to get a working URL?
https://cdn.jsdelivr.net/gh/fawazahmed0/currency-api@1/latest/currencies/eur/jpy.json
abadothali commentedon Sep 28, 2024
plese slove this problem, i can't convert...
const BASE_URL ="https://cdn.jsdelivr.net/npm/@fawazahmed0/currency-api@latest/v1/currencies";
const dropdowns = document.querySelectorAll('.dropdown select');
const btn = document.querySelector('form button');
const fromCurency = document.querySelector('.from select');
const toCurency = document.querySelector('.to select');
for (let select of dropdowns){
for (let currCode in countryList){
let newOPtions = document.createElement('option');
newOPtions.innerText = currCode;
newOPtions.value = currCode;
}
const updateFlg = (element)=>{
let currCode = element.value;
let countyCode = countryList[currCode];
let newSrc =
https://flagsapi.com/${countyCode}/flat/64.png;let img = element.parentElement.querySelector('img');
img.src = newSrc;
}
btn.addEventListener('click', async(evn)=>{
evn.preventDefault();
let amount = document.querySelector('.amount input');
let amountValue = amount.value;
});
rajawatajay commentedon Dec 28, 2024
firstly make your github account public then proivde the reference.
TahirAhmad88 commentedon Mar 2, 2025
Does anyone have a solution to this problem? If so, please let me know.