{"id":32403994,"url":"https://github.com/benmajor/exchangeratesapi","last_synced_at":"2026-03-01T17:02:49.104Z","repository":{"id":34069998,"uuid":"168295208","full_name":"benmajor/ExchangeRatesAPI","owner":"benmajor","description":"An unofficial SDK for the ExchangeRatesAPI.","archived":false,"fork":false,"pushed_at":"2024-05-08T21:04:05.000Z","size":81,"stargazers_count":35,"open_issues_count":0,"forks_count":19,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-02-25T05:33:29.921Z","etag":null,"topics":["api","exchange-rate","exchangeratesapi","sdk"],"latest_commit_sha":null,"homepage":"https://exchangeratesapi.io/","language":"PHP","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/benmajor.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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-01-30T06:59:36.000Z","updated_at":"2024-05-08T21:03:10.000Z","dependencies_parsed_at":"2024-05-08T22:24:03.495Z","dependency_job_id":"dfe921b4-b584-4f08-b8b7-97180a790cde","html_url":"https://github.com/benmajor/ExchangeRatesAPI","commit_stats":{"total_commits":27,"total_committers":7,"mean_commits":3.857142857142857,"dds":0.6296296296296297,"last_synced_commit":"662196ba06b73da5bb15de1875558716183cda35"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/benmajor/ExchangeRatesAPI","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benmajor%2FExchangeRatesAPI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benmajor%2FExchangeRatesAPI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benmajor%2FExchangeRatesAPI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benmajor%2FExchangeRatesAPI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/benmajor","download_url":"https://codeload.github.com/benmajor/ExchangeRatesAPI/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benmajor%2FExchangeRatesAPI/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29976272,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-01T16:35:47.903Z","status":"ssl_error","status_checked_at":"2026-03-01T16:35:44.899Z","response_time":124,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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","exchange-rate","exchangeratesapi","sdk"],"created_at":"2025-10-25T10:57:29.953Z","updated_at":"2026-03-01T17:02:49.097Z","avatar_url":"https://github.com/benmajor.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ExchangeRatesAPI - Currency Exchange Rates API SDK\n\n[![Latest Version](https://img.shields.io/packagist/v/benmajor/exchange-rates-api.svg?style=flat-square)](https://packagist.org/packages/benmajor/exchange-rates-api)\n[![Packagist](https://img.shields.io/packagist/dm/benmajor/exchange-rates-api.svg)](https://packagist.org/packages/benmajor/exchange-rates-api)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)\n\n\n\u003cstrike\u003eThis is an unofficial wrapper for the awesome, free [ExchangeRatesAPI](https://exchangeratesapi.io/), which provides exchange rate lookups courtesy of the [Central European Bank](https://www.ecb.europa.eu/stats/policy_and_exchange_rates/euro_reference_exchange_rates/html/index.en.html). It features a number of useful functions and can be installed easily using [Composer](https://getcomposer.org/).\u003c/strike\u003e\n\n**4.0.0 update:**  \nFollowing pricing changes for [ExchangeRatesAPI](https://exchangerate.host/), this project now uses ExchangeRates.host as its API provider. This should now be considered an unofficial SDK for . 4.0.0 should be backwards compatible with older versions which relied on the no-longer-free ExchangeRatesAPI. \n\n## Table of Contents:\n\n1. [Installation](#1-installation)\n2. [Getting Started](#2-getting-started)\n3. [API Reference](#3-api-reference)\n4. [Supported Currencies](#4-supported-currencies)\n5. [Requirements](#6-requirements)\n6. [Bugs \u0026 Features](#7-bugs-features)\n7. [License](#8-license)\n\n---\n\n### 1. Installation:\n\nThe easiest installation method is to use Composer:\n\n```\n$ composer require benmajor/exchange-rates-api\n```\n\nAlternatively, you can download all files from the `src/` directory and include them in your project. **Important note:** if you're manually installing the SDK, you must also install [Guzzle Client](https://github.com/guzzle/guzzle).\n\n### 2. Getting Started:\n\nSince the CurrencyExchangeAPI does not require API keys or authentication in order to access and interrogate its API, getting started with this library is easy. The following examples show how to achieve various functions using the library.\n\n\n**Basic usage:**\u003cbr /\u003e\nFetch the latest exchange rates from the European Central Bank:\n\n```\nuse \\BenMajor\\ExchangeRatesAPI\\ExchangeRatesAPI;\nuse \\BenMajor\\ExchangeRatesAPI\\Response;\nuse \\BenMajor\\ExchangeRatesAPI\\Exception;\n\n$access_key = '\u003cYOUR ACCESS KEY\u003e';\n$use_ssl = false; # Free plans are restricted to non-SSL only.\n\n$lookup = new ExchangeRatesAPI($access_key, $use_ssl);\n$rates  = $lookup-\u003efetch();\n```\n\n**Historical data:**\u003cbr /\u003e\nGet historical rates for any day since 1999:\n\n```\n$access_key = '\u003cYOUR ACCESS KEY\u003e';\n\n$lookup = new ExchangeRatesAPI($access_key);\n$rates  = $lookup-\u003esetFetchDate('2015-01-20')-\u003efetch();\n```\n\nGet historical rates for a time period:\n\n```\n$access_key = '\u003cYOUR ACCESS KEY\u003e';\n\n$lookup = new ExchangeRatesAPI($access_key);\n$rates  = $lookup-\u003eaddDateFrom('2015-01-20')-\u003eaddDateTo('2015-01-21')-\u003efetch();\n```\n\n**Set the base currency:**\u003cbr /\u003e\nBy default, the base currency is set to Euro (EUR), but it can be changed: \n\n```\n$access_key = '\u003cYOUR ACCESS KEY\u003e';\n\n$lookup = new ExchangeRatesAPI($access_key);\n$rates  = $lookup-\u003esetBaseCurrency('GBP')-\u003efetch();\n```\n\n**Fetch specific rates:**\u003cbr /\u003e\nIf you do not want all current rates, it's possible to specify only the currencies you want using `addRate()`. The following code fetches only the exchange rate between GBP and EUR:\n\n```\n$access_key = '\u003cYOUR ACCESS KEY\u003e';\n\n$lookup = new ExchangeRatesAPI($access_key);\n$rates  = $lookup-\u003eaddRate('EUR')-\u003esetBaseCurrency('GBP')-\u003efetch();\n```\n\nPlease refer to the [API website](https://exchangeratesapi.io/) for further information and full API docs.\n\n**Please note:** By default, the `fetch()` method will return a new `ExchangeRatesAPI\\Response` object. However, by passing a single argument of `true` to the `fetch()` method, you can retrieve a raw JSON resposne instead.\n\n### 3. API Reference:\n\nThe following API reference lists the publicly-available methods for the \n\n#### `ExchangeRatesAPI` Reference:\n\n`addDateFrom( string $from )`:\u003cbr /\u003e\nSet the date from which to retrieve historic rates. `$from` should be a string containing an ISO 8601 date.\n\n`getDateFrom()`:\u003cbr /\u003e\nReturns the specified date from which to retrieve historic rates. Returns `null` if none is specified.\n\n`removeDateFrom()`:\u003cbr /\u003e\nRemoves the specified start date for the retrieval of historic rates.\n\n`addDateTo( string $to )`:\u003cbr /\u003e\nSet the end date for the retrieval of historic rates. `$to` should be a string containing an ISO 8601 date.\n\n`getDateTo()`:\u003cbr /\u003e\nReturns the specified end date for the retrieval of historic rates. Returns `null` if none is specified.\n\n`getAccessKey()`:\u003cbr /\u003e\nReturns the `access_key` that is currently in use.\n\n`getUseSSL()`:\u003cbr /\u003e\nReturns a boolean flag that determines which API URL will be used to perform requests. Free plans are restricted to non-SSL usage.\n\n`removeDateTo()`:\u003cbr /\u003e\nRemoves the specified end date for the retrieval of historic rates.\n\n`currencyIsSupported( string $code )`:\u003cbr /\u003e\nChecks if a specific currency code is supported. `$code` should be passed as an ISO 4217 code (e.g. `EUR`).\u003cbr /\u003e\nReturns `true` if supported, or `false` if not.\n\n`setBaseCurrency( string $code )`:\u003cbr /\u003e\nSet the base currency to be used for exchange rates. `$code` should be passed an ISO 4217 code (e.g. `EUR`).\u003cbr /\u003e\n`$code` must be one of the [supported currency codes](#4-supported-currencies).\n\n`getBaseCurrency()`:\u003cbr /\u003e\nReturns the currently specified base currency. If `setBaseCurrency()` hasn't been called, this will return the default base currency `EUR`.\n\n`addRates( array $codes )`:\u003cbr /\u003e\nAdds multiple currencies to be retrieved. `$codes` should be an array of ISO 4217 codes (e.g. `[\"EUR\", \"GBP\", \"BGN\"]`).\u003cbr /\u003e\nEach code in the array must be of the [supported currency codes](#4-supported-currencies).\u003cbr /\u003e\n \n`addRate( string $code )`:\u003cbr /\u003e\nAdds a new currency to be retrieved. `$code` should be passed an ISO 4217 code (e.g. `EUR`).\u003cbr /\u003e\n`$code` must be one of the [supported currency codes](#4-supported-currencies).\u003cbr /\u003e\nIf no rates are added, **all** rates will be returned.\n\n`removeRates( array $codes )`:\u003cbr /\u003e\nRemoves multiple currencies that has already been added to the retrieval list.  `$codes` should be an array of ISO 4217 codes (e.g. `[\"EUR\", \"GBP\", \"BGN\"]`).\u003cbr /\u003e\n`$code` must be one of the [supported currency codes](#4-supported-currencies).\n\n`removeRate( string $code )`:\u003cbr /\u003e\nRemoves a currency that has already been added to the retrieval list.  `$code` should be passed an ISO 4217 code (e.g. `EUR`).\u003cbr /\u003e\n`$code` must be one of the [supported currency codes](#4-supported-currencies).\n\n`setAccessKey( string $access_key )`:\u003cbr /\u003e\nSets `access_key` to be used in all requests.\n\n`setUseSSL( bool $use_ssl )`:\u003cbr /\u003e\nSets the API URL according to the selected mode (SSL or non-SSL). Free plans are restricted to non-SSL usage.\n\n`fetch( bool $returnJSON = false, bool $parseJSON = true )`:\u003cbr /\u003e\nSend off the request to the API and return either a `Response` object, or the raw JSON response. If `$returnJSON` is set to `true`, a standard PHP object will be returned, rather than the `ExchangeRatesAPI\\Response` object. \n\n`convert( string $to, float $amount, int $rounding )`:\u003cbr /\u003e\nA convenience function to combine several methods in order to quickly perform a currency conversion:\n\n`$to`: should be specified as the ISO 4217 currency code to convert to.\u003cbr /\u003e\n`$amount`: the amount to be converted.\u003cbr /\u003e\n`$rounding`: the amount to round the conversion. Default is `2`.\n\nThis method call will return the converted currency amount in `$to` from the specified based currency. \n\n`getSupportedCurrencies( string $concat = null )`:\u003cbr /\u003e\nReturns a list of supported currency codes. If `$concat` is `null`, an array of currency codes is returned. If `$concat` is specified as a string, a string will be returned, joined by `$concat`.\n\n`getRates( string $concat = null )`:\u003cbr /\u003e\nReturns a list of the currently specified rates to retrieve. If `$concat` is `null`, an array of currency codes is returned. If `$concat` is specified as a string, a string will be returned, joined by `$concat`.\n\n#### `Response` Reference:\n\nThis is the default object that is returned from the `fetch()`. Here is a list of the available methods on the `Response` object:\n\n`getStatusCode()`:\u003cbr /\u003e\nReturns the status code of the request (generally `200`).\n\n`getTimestamp()`:\u003cbr /\u003e\nReturns the timestamp (formatted in ISO 8601 notation) the response was generated.\n\n`getBaseCurrency()`:\u003cbr /\u003e\nReturns the base currency of the request. If not base currency was specified using `setBaseCurrency` on the request, this will return the default (`EUR`).\n\n`getRates()`:\u003cbr /\u003e\nReturns a key/value pair array of the exchange rates that match against the request, for example:\n\n```\n[ 'GBP' =\u003e 1, 'EUR' =\u003e 1.1 ]\n```\n\n`getRate( string $code )`:\u003cbr /\u003e\nRetrieves the exchange rate for a specific currency, or returns the exchange rate if only one rate is present in the response.\n\n### 4. Supported Currencies:\n\nThe library supports any currency currently available on the European Central Bank's web service, which can be found [here](https://exchangeratesapi.io/currencies/).\n\n### 5. Requirements:\n\nThis library requires PHP \u003e= 7.0. No other platform requirements exist, but the library is dependent on [Guzzle](https://github.com/guzzle/guzzle).\n\n\n### 6. Bugs \u0026 Features:\n\nIf you have spotted any bugs, or would like to request additional features from the library, please file an issue via the Issue Tracker on the project's Github page: [https://github.com/benmajor/ExchangeRatesAPI/issues](https://github.com/benmajor/ExchangeRatesAPI/issues).\n\n### 7. License:\n\nLicensed under the **MIT License**:\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenmajor%2Fexchangeratesapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbenmajor%2Fexchangeratesapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenmajor%2Fexchangeratesapi/lists"}