lineofflight / frankfurter

💱 Currency data API
https://frankfurter.dev
MIT License
517 stars 92 forks source link

Same Currency Conversion Returns "Not Found" #51

Open dudi-w opened 5 months ago

dudi-w commented 5 months ago

Description:

I encountered an issue with the API when trying to convert the same currency. Specifically, when I send a query to convert EUR to EUR, the API returns a "not found" message instead of the expected conversion rate. I should mention that I really do sometimes send the same coins for conversion because I don't know which coins are actually fed into my system

Steps to Reproduce:

  1. Send a GET request to https://api.frankfurter.app/2024-10-02?amount=10&from=EUR&to=EUR.
  2. Observe the response.

Expected Behavior:

The API should return a response indicating that 1amount EUR is equal to 1amount EUR. For example:

{
    "amount": 10,
    "base": "EUR",
    "date": "2024-10-02",
    "rates": {
        "EUR": 10
    }
}

Actual Behavior:

The API returns the following response:

{
    "message": "not found"
}

Additional Information:

This behavior is observed across different dates and for different currencies. It seems to be a general issue with handling same-currency conversions.

Thank you for your attention to this matter. I appreciate the work you are doing with the Frankfurter project and hope this feedback helps improve the API.

Best regards, dudi

hakanensari commented 1 week ago

@dudi-w Thanks for raising this issue!

Returning the base currency in this edge case feels inconsistent, as we normally exclude it from responses. That said, the 404 Not Found error is misleading. I’ve made a small change to return a 422 status instead to align with how we handle other invalid inputs (e.g., bad dates, non-positive amounts).

Hope this resolves the issue!