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
{{ message }}
This repository was archived by the owner on Oct 14, 2023. It is now read-only.
Laravel currency is a simple package for currency conversion, latest and historical exchange rates based on the free API [exchangerate.host](https://exchangerate.host"exchangerate.host Homepage") - no API keys needed!
4
+
Laravel currency is a simple package for current and historical currency exchange rates & crypto exchange rates. based on the free API [exchangerate.host](https://exchangerate.host"exchangerate.host Homepage") - no API keys needed!
5
5
6
6
## Requirements
7
7
- PHP >= 7.2
8
8
- Laravel >= 6.0
9
9
- guzzlehttp >= 6.0
10
10
11
11
## Installation
12
+
12
13
```
13
14
composer require amrshawky/laravel-currency
14
15
```
15
16
16
17
## Usage
17
18
18
19
### 1. Currency Conversion
19
-
To convert from one currency to another you may chain the methods like so:
20
+
To convert from one currency to another you may chain the methods:
21
+
20
22
```php
21
23
use AmrShawky\Currency\Facade\Currency;
22
24
@@ -77,6 +79,7 @@ Currency::convert()
77
79
78
80
### 2. Latest Rates
79
81
To get latest rates you may chain the methods:
82
+
80
83
```php
81
84
use AmrShawky\Currency\Facade\Currency;
82
85
@@ -88,6 +91,7 @@ This will return an `array` of all available currencies or `null` on failure.
88
91
89
92
#### Available Methods
90
93
- Just like currency conversion you may chain any of the available methods:
94
+
91
95
```php
92
96
use AmrShawky\Currency\Facade\Currency;
93
97
@@ -97,17 +101,18 @@ Currency::rates()
97
101
->base('GBP') //Changing base currency (default: EUR). Enter the three-letter currency code of your preferred base currency.
98
102
->amount(5.66) //Specify the amount to be converted
99
103
->round(2) //Round numbers to decimal places
100
-
->source('ecb') //Switch data source between forex `default` or bank view
104
+
->source('ecb') //Switch data source between forex `default`, bank view or crypto currencies.
101
105
->get();
102
106
```
103
107
104
108
### 3. Historical Rates
105
109
Historical rates are available for most currencies all the way back to the year of 1999.
110
+
106
111
```php
107
112
use AmrShawky\Currency\Facade\Currency;
108
113
109
114
Currency::rates()
110
-
->historical('2020-01-01') //`YYYY-MM-DD` Required date parameter to get the rates for
115
+
->historical('2020-01-01') //`YYYY-MM-DD` Required date parameter to get the rates for
111
116
->get();
112
117
```
113
118
Same as latest rates you may chain any of the available methods:
@@ -116,13 +121,30 @@ use AmrShawky\Currency\Facade\Currency;
116
121
117
122
Currency::rates()
118
123
->historical('2020-01-01')
119
-
->symbols(['USD', 'EUR', 'EGP'])
124
+
->symbols(['USD', 'EUR', 'CZK'])
120
125
->base('GBP')
121
126
->amount(5.66)
122
127
->round(2)
123
128
->source('ecb')
124
129
->get();
125
130
```
131
+
### 4. Timeseries Rates
132
+
Timeseries are for daily historical rates between two dates of your choice, with a maximum time frame of 365 days.
133
+
This will return an `array` with keys as dates and values as an `array` of rates or `null` on failure.
134
+
135
+
```php
136
+
use AmrShawky\Currency\Facade\Currency;
137
+
138
+
Currency::rates()
139
+
->timeSeries('2021-05-01', '2021-05-04') //`YYYY-MM-DD` Required dates range parameters
140
+
->symbols(['USD', 'EUR', 'EGP']) //[optional] An array of currency codes to limit output currencies
141
+
->base('GBP') //[optional] Changing base currency (default: EUR). Enter the three-letter currency code of your preferred base currency.
142
+
->amount(5.66) //[optional] Specify the amount to be converted (default: 1)
143
+
->round(2) //[optional] Round numbers to decimal places
144
+
->source('ecb') //[optional] Switch data source between forex `default`, bank view or crypto currencies.
145
+
->get();
146
+
```
147
+
126
148
### Throwing Exceptions
127
149
The default behavior is to return `null` for errors that occur during the request _(connection timeout, DNS errors, client or server error status code, missing API success parameter, etc.)_.
128
150
@@ -203,8 +225,5 @@ More information regarding list of bank sources [here](https://api.exchangerate.
203
225
204
226
For a list of all supported symbols [here](https://api.exchangerate.host/symbols"List of supported symbols")
205
227
206
-
## More features
207
-
Coming soon!
208
-
209
228
## License
210
229
The MIT License (MIT). Please see [LICENSE](../master/LICENSE) for more information.
Copy file name to clipboardExpand all lines: composer.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
{
2
2
"name": "amrshawky/laravel-currency",
3
-
"description": "A Laravel package for currency conversion, latest and historical exchange rates based on the free API provided by exchangerate.host",
3
+
"description": "A Laravel package for current and historical currency exchange rates & crypto exchange rates based on the free API provided by exchangerate.host",
Laravel currency is a simple package for currency conversion, latest and historical exchange rates based on the free API [exchangerate.host](https://exchangerate.host"exchangerate.host Homepage") - no API keys needed!
4
+
Laravel currency is a simple package for current and historical currency exchange rates & crypto exchange rates. based on the free API [exchangerate.host](https://exchangerate.host"exchangerate.host Homepage") - no API keys needed!
5
5
6
6
## Requirements
7
7
- PHP >= 7.2
8
8
- Laravel >= 6.0
9
9
- guzzlehttp >= 6.0
10
10
11
11
## Installation
12
+
12
13
```
13
14
composer require amrshawky/laravel-currency
14
15
```
15
16
16
17
## Usage
17
18
18
19
### 1. Currency Conversion
19
-
To convert from one currency to another you may chain the methods like so:
20
+
To convert from one currency to another you may chain the methods:
21
+
20
22
```php
21
23
use AmrShawky\Currency\Facade\Currency;
22
24
@@ -85,7 +87,6 @@ Currency::rates()
85
87
->latest()
86
88
->get();
87
89
```
88
-
89
90
This will return an `array` of all available currencies or `null` on failure.
90
91
91
92
#### Available Methods
@@ -100,7 +101,7 @@ Currency::rates()
100
101
->base('GBP') //Changing base currency (default: EUR). Enter the three-letter currency code of your preferred base currency.
101
102
->amount(5.66) //Specify the amount to be converted
102
103
->round(2) //Round numbers to decimal places
103
-
->source('ecb') //Switch data source between forex `default` or bank view
104
+
->source('ecb') //Switch data source between forex `default`, bank view or crypto currencies.
104
105
->get();
105
106
```
106
107
@@ -111,23 +112,39 @@ Historical rates are available for most currencies all the way back to the year
111
112
use AmrShawky\Currency\Facade\Currency;
112
113
113
114
Currency::rates()
114
-
->historical('2020-01-01') //`YYYY-MM-DD` Required date parameter to get the rates for
115
+
->historical('2020-01-01') //`YYYY-MM-DD` Required date parameter to get the rates for
115
116
->get();
116
117
```
117
118
Same as latest rates you may chain any of the available methods:
118
-
119
119
```php
120
120
use AmrShawky\Currency\Facade\Currency;
121
121
122
122
Currency::rates()
123
123
->historical('2020-01-01')
124
-
->symbols(['USD', 'EUR', 'EGP'])
124
+
->symbols(['USD', 'EUR', 'CZK'])
125
125
->base('GBP')
126
126
->amount(5.66)
127
127
->round(2)
128
128
->source('ecb')
129
129
->get();
130
130
```
131
+
### 4. Timeseries Rates
132
+
Timeseries are for daily historical rates between two dates of your choice, with a maximum time frame of 365 days.
133
+
This will return an `array` with keys as dates and values as an `array` of rates or `null` on failure.
134
+
135
+
```php
136
+
use AmrShawky\Currency\Facade\Currency;
137
+
138
+
Currency::rates()
139
+
->timeSeries('2021-05-01', '2021-05-04') //`YYYY-MM-DD` Required dates range parameters
140
+
->symbols(['USD', 'EUR', 'EGP']) //[optional] An array of currency codes to limit output currencies
141
+
->base('GBP') //[optional] Changing base currency (default: EUR). Enter the three-letter currency code of your preferred base currency.
142
+
->amount(5.66) //[optional] Specify the amount to be converted (default: 1)
143
+
->round(2) //[optional] Round numbers to decimal places
144
+
->source('ecb') //[optional] Switch data source between forex `default`, bank view or crypto currencies.
145
+
->get();
146
+
```
147
+
131
148
### Throwing Exceptions
132
149
The default behavior is to return `null` for errors that occur during the request _(connection timeout, DNS errors, client or server error status code, missing API success parameter, etc.)_.
133
150
@@ -208,8 +225,5 @@ More information regarding list of bank sources [here](https://api.exchangerate.
208
225
209
226
For a list of all supported symbols [here](https://api.exchangerate.host/symbols"List of supported symbols")
210
227
211
-
## More features
212
-
Coming soon!
213
-
214
228
## License
215
229
The MIT License (MIT). Please see [LICENSE](../master/LICENSE) for more information.
0 commit comments