Code Monkey home page Code Monkey logo

exchange-api's Introduction

Free Currency Exchange Rates API

Publish-Currencies

Features:

  • Free & Blazing Fast response
  • No Rate limits
  • 150+ Currencies, Including Common Cryptocurrencies
  • Daily Updated

URL Structure:

https://cdn.jsdelivr.net/npm/@fawazahmed0/currency-api@{date}/{apiVersion}/{endpoint}

Formats:

date

The date should either be latest or in YYYY-MM-DD format

The Endpoints Supports HTTP GET Method and returns the data in two formats:

/{endpoint}.json

/{endpoint}.min.json

Endpoints:

  • /currencies

Lists all the available currencies in prettified json format:
https://cdn.jsdelivr.net/npm/@fawazahmed0/currency-api@latest/v1/currencies.json

Get a minified version of it:
https://cdn.jsdelivr.net/npm/@fawazahmed0/currency-api@latest/v1/currencies.min.json

  • /currencies/{currencyCode}

Get the currency list with EUR as base currency:
https://cdn.jsdelivr.net/npm/@fawazahmed0/currency-api@latest/v1/currencies/eur.json

Get the currency list with EUR as base currency on date 2024-03-06:
https://cdn.jsdelivr.net/npm/@fawazahmed0/currency-api@2024-03-06/v1/currencies/eur.json

Get the currency list with BTC as base currency:
https://cdn.jsdelivr.net/npm/@fawazahmed0/currency-api@latest/v1/currencies/btc.json

Get the currency list with BTC as base currency in minified format:
https://cdn.jsdelivr.net/npm/@fawazahmed0/currency-api@latest/v1/currencies/btc.min.json

Additional Fallback URL on Cloudflare:

https://{date}.currency-api.pages.dev/{apiVersion}/{endpoint}

Get the currency list with EUR as base currency:
https://latest.currency-api.pages.dev/v1/currencies/eur.json

Get the currency list with EUR as base currency on date 2024-03-06:
https://2024-03-06.currency-api.pages.dev/v1/currencies/eur.json

Warning: Please include Fallback mechanism in your code, for example if cdn.jsdelivr.net link fails, fetch from currency-api.pages.dev

Migrating from Previous Currency API: Read this

exchange-api's People

Contributors

fawazahmed0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

exchange-api's Issues

Root directories are getting bigger everyday

Dear @fawazahmed0 ,

You have done a fantastic job with the project. As you can see the root directory is increasing everyday with the date. Is there any plan for a refactoring?

Suggestion could be:
/{year}/{month}/{day}/currencies/{from_currency}/{to_currency}.json
This is more manageable as directory structuring.

However the bigger challenge is to provide backward compatibility with current directory pattern to support currently by application! Possibly by a new API version?

What are you thoughts around this?

Best Regards.

Currency Exchange rates other sources

BYN currency issues

this returns wrong result

https://cdn.jsdelivr.net/gh/fawazahmed0/currency-api@1/latest/currencies/usd/byn.json

there is no BYN currency here

https://cdn.jsdelivr.net/gh/fawazahmed0/currency-api@1/latest/currencies.json

BYN is a new code of Belarussia Ruble. There is only old code (BYR) which is not used for about 5 years and has wrong exchange rates in this repo.

CI Failing fix

First increasing swap using this
and if doesn't work, then also below
add git config --global gc.auto 0 to disable gc & reduce ram usage,

Include fallback mechanism in your code to avoid issues

This API have multiple fallback urls:

Fallback URL:

https://currency-api.pages.dev/{apiVersion}/{endpoint}

Pseudo code:
For example, if you want to fetch eur rate:

Fetch https://cdn.jsdelivr.net/npm/@fawazahmed0/currency-api@latest/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://currency-api.pages.dev/v1/currencies/eur.min.json
If above url fails, then try fetching https://currency-api.pages.dev/v1/currencies/eur.json

Adding new cryto currency

Steps to add new crypto currency in this API:

  1. Go Here
  2. In topCryptoCurrency variable, add your crypto symbol.
  3. Commit & Create a PR.

Getting jsons with wrong dates

Sometimes I get jsons with the wrong date on the "latest" request.
Today is 2022-02-19

Example:

https://cdn.jsdelivr.net/gh/fawazahmed0/currency-api@1/latest/currencies/cny.json

console.log on the project showing:

{
  "date": "2022-02-18",               <--- ❌ -1 day
  "cny": {
          "1inch": 0.094996,
          "ada": 0.154334,
          "aed": 0.579573,
          ...
          "zwl": 50.807804
          }
}

Also I tried to get xxx.min.json instead of xxx.json

If we open URL https://cdn.jsdelivr.net/gh/fawazahmed0/currency-api@1/latest/currencies/rub.min.json everything is okay

date: "2022-02-19"               <--- ✔️
...

But when I console.log it on my project it shows

date: "2022-02-17"               <--- ❌ -2 days ??
...

Can you tell me what the problem is?

I'm trying to get the difference of exchange rates between the last two days - latest and (today - 1) day.
So this is the problem for me.

use for travel app?

What is the source of your exchange rates? location / company
What time are the rates updated daily?

I am interested in using the rates in a travel app.
I had things working in SwiftUI until the date was added to the JSON file, now I'm stuck.

[email protected]

Error when getting `latest` via explicit date

Assuming today is 25th December, the following URL fails:

https://cdn.jsdelivr.net/gh/fawazahmed0/currency-api@1/2021-12-25/currencies/gbp/usd.json

Package size exceeded the configured limit of 50 MB. Try https://github.com/fawazahmed0/currency-api/tree/1/2021-12-25/currencies/gbp/usd.json instead.*:

However, the below works, while still returning data for 2021-12-25
https://cdn.jsdelivr.net/gh/fawazahmed0/currency-api@1/latest/currencies/gbp/usd.json

Getting the previous date's data also works:
https://cdn.jsdelivr.net/gh/fawazahmed0/currency-api@1/2021-12-24/currencies/gbp/usd.json

Reduce git repo size as historical data increases size of this repo

jsdelivr caches the git repo , after someone requests the url through jsdelivr.

So curl all the urls for caching and then delete the date from git repo and run BFG cleanerto reduce git repo size, to avoid burden on github

or by adding date tag, we can access previous commits of same folder, without having to make datewise folder, but this will cause api design to change for accessing historical data

DepShield encountered errors while building your project

The project could not be analyzed because of build errors. Please review the error messages here. Another build will be scheduled when a change to a manifest file* occurs. If the build is successful this issue will be closed, otherwise the error message will be updated.

This is an automated GitHub Issue created by Sonatype DepShield. GitHub Apps, including DepShield, can be managed from the Developer settings of the repository administrators.

* Supported manifest files are: pom.xml, package.json, package-lock.json, npm-shrinkwrap.json, Cargo.lock, Cargo.toml, main.rs, lib.rs, build.gradle, build.gradle.kts, settings.gradle, settings.gradle.kts, gradle.properties, gradle-wrapper.properties, go.mod, go.sum

How do I get the exchange rate of the US dollar against all currencies

Hi, I really appreciate everything you've done. This project has been very useful to me,

But I have a question, i want to know how to get the exchange rate for US dollars against all currencies..

I did not find the corresponding API in the description.

Example : https://cdn.jsdelivr.net/gh/fawazahmed0/currency-api@1/latest/currencies/usd.json , I just need the reverse result of what this sample API returns.

I am looking forward to your reply, and thank you again for everything.

Better usable JSON format

Hi,
I use your very nice API for a Discord.js bot, it is very simple to use, even if it would be prettier if the JSON format of the conversion URL (https://cdn.jsdelivr.net/gh/fawazahmed0/currency-api@1/latest/currencies/eur/jpy.json for example) response looked like :
{ "date": "2021-06-22", "change": { "currency " : "jpy", "amount" : "131.418702"} }
I think it would be more useful; if you want this from me, I can contribute by sending you a PR
Thank you for your work !

[Question] Where does this API pull the its currency data from?

Hello 👋🏻
Asking the question in the title, if it is possible to be answered. If not then it's also fine. 😁

I wanted to know, from which site/location did you pull all your currency data from? This is just to improve the validity of the data presented to me.

I found that your currscript.js does indicate that you use CoinMarketCap as your data source. Is this perhaps correct?

Add some currencies in the api

Hi

Firstly, Thanks for your job

I would know if it's possible that you add some currencies:
VET
ONE
EGLD
CHZ
GRT
1INCH
INJ
ENJ
KSM

Thank you :)

Regards

Add timestamp for latest api

Incredibly amazing project, thank you. The situation around forex rate apis is frankly ridiculous. You built exactly what I imagined should exist. Kudos.

I'd mention that bing and google are the sources and that the data updates daily in the readme (just to make it obvious).

No it's possible that this system will break in the future for some reason. Could you add a way to find out when is the latest data from? I could then do something like if latest.date - now > 50 days { show warning to user }.

Thanks again!

Other options for cdn

npm support(max tar.gz package size 200mb):
jsdelivr (doesn't work if package size > 100mb)
unpkg.com (this works fine)
cdnjs (not great, they store package in their repo)

cloudflare pages (20k files,25mb/file size limit) (not great, 20k files limit)

Add monero

Hi, thanks for this project, it's fantastic :-).

I just wanted to ask whether you'd be willing to add monero to the list of supported currencies?

cryptos & cleanup (later)

add support for all cryptos in currency-api (need to add all crypto names in json, to avoid issues)
add script in currapi to delete the days folders automatically, everyday, & also clean removing from github repo, using bfg-cleaner
https://rtyley.github.io/bfg-repo-cleaner/

do this before gh marks your account for heavy usage, as they did with opengapps (see other repo file sizes, to avoid using more space < 5gb)

[Question] What time (in UTC) does the currency data get polled?

When is the currency data queried each day? Is the data queried at the same time each day? If not, is there a way to get the timestamp that each conversion was measured when querying rates?

Conversion rates change throughout the day and I'd like to be able to advertise a timestamp when the data was polled.

No data for 2022-05-01

Data for May 1 seems to be missing for both the main and fallback URLs. Is it possible to patch?

Adding index of missing days?

Hi,

For now, I only know of 3 missing dates/ranges:

  • anytime before 2020-11-22
  • 2021-09-14
  • 2022-05-01

Would it make sense to have a json file that automatically lists the missing dates? This would enable clients to programmatically know about and handle missing days rather than relying on heuristics.

wrong historical data

few currencies have wrong historical data, due to bug in code, refer closed issues to know which ones were wrong

PR

Estimation + 30min

Planning Phase

  • Research/Designing - 30min (Time took 12mins)
  • Estimation & breaking task -25min (Time took 10 mins)

Understanding for project documentation

Hi Ramy,

As I have understood on same,

you need to get the currency details from the shared API endpoints and after getting the data currencies should be visible in sorted format into the application and the end-user can also download the result as required into the CSV/ Excel format.
If I am correct on the same then please reply to me or provide me guidance to understand if I am on the wrong path.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.