{"id":13983644,"url":"https://github.com/asvvvad1/exchange","last_synced_at":"2025-10-11T01:31:21.524Z","repository":{"id":144210663,"uuid":"260072803","full_name":"asvvvad1/exchange","owner":"asvvvad1","description":"Go library for getting current and historical exchange rates, Forex and Crypto currency conversion with no authentication using Free foreign exchange rates API","archived":false,"fork":false,"pushed_at":"2024-08-18T07:02:04.000Z","size":59,"stargazers_count":17,"open_issues_count":3,"forks_count":6,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-28T22:35:41.576Z","etag":null,"topics":["api","bitcoin","cryptocurrency","currency","currency-converter","exchange-rates","fluctuations","forex","free","go","go-library","golang","timeseries"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/asvvvad/exchange?tab=doc","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/asvvvad1.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-04-30T00:01:54.000Z","updated_at":"2024-10-31T09:18:55.000Z","dependencies_parsed_at":"2023-08-15T20:17:07.014Z","dependency_job_id":null,"html_url":"https://github.com/asvvvad1/exchange","commit_stats":null,"previous_names":["asvvvad/exchange"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asvvvad1%2Fexchange","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asvvvad1%2Fexchange/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asvvvad1%2Fexchange/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asvvvad1%2Fexchange/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/asvvvad1","download_url":"https://codeload.github.com/asvvvad1/exchange/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":236017234,"owners_count":19081877,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","bitcoin","cryptocurrency","currency","currency-converter","exchange-rates","fluctuations","forex","free","go","go-library","golang","timeseries"],"created_at":"2024-08-09T05:01:50.291Z","updated_at":"2025-10-11T01:31:21.191Z","avatar_url":"https://github.com/asvvvad1.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# exchange\n[![Go Report Card](https://goreportcard.com/badge/github.com/asvvvad/exchange)](https://goreportcard.com/report/github.com/asvvvad/exchange)\n\nGo library for current \u0026 historical exchange rates, forex \u0026 crypto currency conversion, fluctuation, and timeseries using the new [Free foreign exchange rates API](https://exchangerate.host/#/) by [arzzen](https://github.com/arzzen/) ([github](https://github.com/arzzen/exchangerate.host))\n\n## Features:\n- Currency conversion, historical \u0026 current exchange rates, timeseries and fluctuations\n- No authentication/token needed!\n- Select any base currency\n- 171 forex currency and 6000+ cryptocurrency!\n- Caching (optional, default) using [go-cache](https://github.com/patrickmn/go-cache)\n- Easy to use:\n\n## Usage:\n\n\u003e #### `go get -u github.com/asvvvad/exchange` \n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/asvvvad/exchange\"\n)\n\nfunc main() {\n\t// Create a new Exchange instance and set USD as the base currency for the exchange rates and conversion\n\tex := exchange.New(\"USD\")\n\t// convert 10 USD to EUR\n\tfmt.Println(ex.ConvertTo(\"EUR\", 10))\n\t// You can convert between 171 fiat and +6000 cryptocurrency aswelL!\n\t// convert 10 USD to BTC\n\tfmt.Println(ex.ConvertTo(\"BTC\", 10))\n\t// convert 10 USD to EUR at 2012-12-12 (date must be in the format YYYY-MM-DD)\n\tfmt.Println(ex.ConvertAt(\"2012-12-12\", \"EUR\", 10))\n\n\t// Get the available forex/fiat codes ([]string)\n\tforexCodes, _ := ex.ForexCodes()\n\t\n\t// Get the available crypto codes ([]string)\n\t// Warning: +6000\n\tcryptoCodes, _ := ex.CryptoCodes()\n\n\t// Get the forex codes data, includes code and description.\n\tforexData, _ := ex.ForexData()\n\n\t// Get the crypto codes data, includes code and description.\n\t// Warning: +6000\n\tcryptoData, _ := ex.CryptoData()\n\n\t// loop through the forex cpdes\n\tfor _, code := range forexCodes {\n\t\t// print the forex codes data in the format: USD: US Dollar\n\t\tfmt.Println(code+\":\", forexData[code][\"description\"])\n\t}\n\n\t// Change the base currency to euro\n\tex.SetBase(\"EUR\")\n\t// Get the latest exchange rates with all currencies (Base is EUR)\n\tfmt.Println(ex.LatestRatesAll())\n\n\t// Get the latest rates again, this time it will be loaded from in-memory cache\n\t// Cache last till midnight GMT because it's the time exchangerate.host update the rates\n\tfmt.Println(ex.LatestRatesAll())\n\t// disable caching\n\tex.SetCache(false)\n\n\t// Get the latest rates with multiple currencies, not all (USD and JPY only)\n\tfmt.Println(ex.LatestRatesMultiple([]string{\"USD\", \"JPY\"}))\n\n\t// Get the exchange rates at 2012-12-12 but only with USD\n\tfmt.Println(ex.HistoricalRatesSingle(\"2012-12-12\", \"USD\"))\n\n\t// Get historical rates between 2012 12 10 and 2012 12 12 for JPY and GBP\n\tfmt.Println(ex.TimeseriesMultiple(\"2012-12-10\", \"2012-12-12\", []string{\"USD\", \"JPY\"}))\n\n\t// Get the fluctuation between 2012 12 10 and 2012 12 12 with USD\n\tfluctuation, _ := ex.FluctuationSingle(\"2012-12-10\", \"2012-12-12\", \"USD\")\n\t// Print the change\n\tfmt.Println(fluctuation[\"change\"])\n}\n\n```\n\n### Results returned by each method:\n- ConvertTo, ConvertAt, HistoricalRatesSingle, LatestRatesSingle\n- - `big.Float`, error\n- LatestRatesAll, LatestRatesMultiple, HistoricalRatesAll, HistoricalRatesMultiple:\n- - `map[symbol(string)]rate(big.Float)`\n- ForexCodes\n- - `[]string{codes}`, error\n- ForexData\n- - `map[symbol]map[\n    code\n    description\n]string`, error\n- CryptoCodes\n- - `[]string{codes}`, error\n- CryptoData\n- - `map[symbol]map[\n    symbol\n    name\n]string`, error\n- FluctuationAll, FluctuationMultiple,\n- - `map[symbol]map[\n    start_rate\n    end_rate\n    change\n    change_pct\n]*big.Float`, error\n- FluctuationSingle\n- - `map[\n    start_rate\n    end_rate\n    change\n    change_pct\n]*big.Float`, error\n\n- TimeseriesAll, TimeseriesMultiple\n- - `map[date]map[symbols]*big.Float`, error\n- TimeseriesSingle\n- - `map[date]map[symbol]*big.Float`, error\n\n\u003e ## Notes:\n\n- You can use All, Multiple, Single with all of LatestRates, HistoricalRates, Timeseries and Fluctuation.\n- Oldest date for historical rates and conversion is 1999-01-04\n- Maximum allowed timeframe for Timeseries is 365 days\n\n#### Input validation with the appropriate errors for all methods is provided to help debug\n\n#### Any help and contribution is welcome!\nThis is my first Go library and I had trouble with JSON parsing (and I still do, didn't use bitly/simplejson to reduce dependencies) Theres a lot of room for improvement\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasvvvad1%2Fexchange","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fasvvvad1%2Fexchange","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasvvvad1%2Fexchange/lists"}