amrshawky / laravel-currency

Laravel package for current and historical currency exchange rates & crypto exchange rates. based on the free API exchangerate.host
MIT License
332 stars 44 forks source link

Now API key is needed in exchangerate.host #19

Open asntcrz opened 11 months ago

asntcrz commented 11 months ago

All calls now prompt the following error:

AmrShawky\Exceptions\RequestException { "success": false, "error": { "code": 101, "type": "missing_access_key", "info": "You have not supplied an API Access Key. [Required format: access_key=YOUR_ACCESS_KEY]" } }

Could it be possible to include an option to use an API key?

Thank you!

dbsrb commented 11 months ago

Any news? Will you extend this package?

amrshawky commented 11 months ago

Thanks for reporting this, yes I will extend the package please wait for a new release. meanwhile please use the withOptions method and add the api key as a query param https://docs.guzzlephp.org/en/stable/request-options.html#query

dbsrb commented 11 months ago

Thanks bro! It seems that they have a problem on their side because every time I try to send a request with the basic plan I get the response "Access Restricted - Your current Subscription Plan does not support this API Function", and I try to send just a basic request which should be included in basic plan :)

amrshawky commented 11 months ago

No worries, looks like there are a few plans and the higher the plan the more functions you get, nothing stay free forever right :D

https://exchangerate.host/product

asntcrz commented 11 months ago

Thanks for reporting this, yes I will extend the package please wait for a new release. meanwhile please use the withOptions method and add the api key as a query param https://docs.guzzlephp.org/en/stable/request-options.html#query

Thanks for checking in so quick. Yeah, apparently their service has changed even their website is different, it is still free for 1K requests/month, but now an API key is needed: https://exchangerate.host/

About your workaround, I tried but it still gave me the same error, not sure if I'm missing something?

Currency::convert()->from('USD')->to('EUR')->amount(1)->withOptions(['query' => ['access_key' => env('CURRENCY_API_ID')]])->throw()->get();

image

Thank you for the package and support!

amrshawky commented 11 months ago

Oh shot okay thanks, other options works no idea why the query doesn't, maybe you should call the api directly for now using Laravel HTTP client

Thank you for reporting again

sapnabindal commented 11 months ago

Probably this is not working for a trial version Screenshot 2023-09-28 172212

elliottcoe commented 11 months ago

Probably this is not working for a trial version Screenshot 2023-09-28 172212

Annoying I just purchased the basic plan and currency switching still doesn't work even though it is stated on the plan.

chelev commented 11 months ago

@asntcrz just so you know.

I made it work with changing for the free version the end point to not be secured and use http instead of https.

In order for this to be fixed I believe you must add settings for both - api key and the endpoint it self.

Hope this helps.

bed-beard commented 11 months ago

@asntcrz just so you know.

I made it work with changing for the free version the end point to not be secured and use http instead of https.

In order for this to be fixed I believe you must add settings for both - api key and the endpoint it self.

Hope this helps.

How/where exactly did you update the endpoint to use http instead of https?

bed-beard commented 11 months ago

Probably this is not working for a trial version Screenshot 2023-09-28 172212

How are you passing the API key to get this error? When I try it just tells me I haven't even supplied an API key. Looks like for you it is seeing your API key but telling you that your plan doens't support the function.

ClaraLeigh commented 11 months ago

I needed a quick drop in replacement for the convert() function. Here is something thats working for me, very much a quick fix that uses a free conversion endpoint: https://gist.github.com/ClaraLeigh/7a325b8c12138167b8a3eb7e6976700a

MoEmam203 commented 11 months ago

You can use this API to get all the exchange rates from a specific currency

https://open.er-api.com/v6/latest/USD

(change USD to the base you want)

dgillier commented 11 months ago

@amrshawky Could you accept, or check the last pull request regarding this topic ?

thanks a lot!

amrshawky commented 11 months ago

The tests in the PR https://github.com/amrshawky/currency/pull/3 are failing

It's easier guys to use Laravel Http client for now, I just don't have the time now, The package is not only for conversion and the provider seems to change a lot of things so I have to go through all of their docs.