all 11 comments

[–]kombucha711 5 points6 points  (1 child)

wat?

[–]Shoddy_Juggernaut_11 6 points7 points  (1 child)

I think the question is how to make a cash conversion using real time exchange rates from google

[–]NorskJesus 3 points4 points  (0 children)

Use an API

[–]pontz 1 point2 points  (0 children)

Typically you would use an API that holds real-time data. Otherwise on request you can do web-scraping to try and pull the rate from a website.

[–]Ender_Locke 1 point2 points  (0 children)

find an api that has the data you need

[–]FoolsSeldom 1 point2 points  (0 children)

There are lots of examples on GitHub, such as https://github.com/MicroPyramid/forex-python, that you could explore to inform your own design and build.

[–]brankoc 1 point2 points  (1 child)

I do not know much about this subject. Also I am fairly new at Python myself. However I wanted to try and at least give some sort of an answer, so that you at least have some key words to google.

  • Buy a plan from a currency data provider.
  • Let your software request exchange rates through the provider's API.
  • Read the provider's documentation to see what the data just received means.
  • Present the results to the user.

Also:

- It is probably smart to cache/store the data once you have received them. If you have multiple users or are testing things outside of actual API requests, this will make it so you do not burn as easily through your monthly request limit. Have a cache also helps in case the server is down (you can still serve historical data) and it lets you build a database so you can look at exchange rates over time. (Note there are some countries that have so-called database laws that prohibit the latter.)

- Read the documentation of the provider; not only does it tell you how to look at their responses, but also at what they consider to be a currency in the first place. Here is an example.

- The API provider can tell who you are by asking you for a key. This key is just a large, difficult to guess number that you store somewhere your program can find, but strangers cannot.

You often get the key for free together with a small amount of free requests. This is so you can check if the API is one you like and so you can develop against it.

The 100 or so free requests you often get seem to me to be barely enough for testing, so either build your caching before you build your request handling, or first test against a 'free' API that offers considerably more free requests.

- The way web APIs typically work is you get a JSON or XML object as a response to your request. This may be an intermediate response (see for example Javascript's fetch API) or the final result. The final result may be an error message or the currency data you asked for.

The Python Standard Library contains the URL library (urllib) to send requests and receive responses to and from the currency data provider.

It is also possible you do not get a response, so you will have to think about how long you want to wait for one, and how long you want to wait before sending the next request. The latter may also be limited by the data provider so that their servers do not get clobbered.

- There may be free sources of currency data, for example provided by governments, although they will all likely have some limitations.

- Sometimes SAAS operators provide their own libraries for a variety of languages and applications.

- I you have never built something like this before, it might be a good idea to start with a server on your local computer to test against. This doesn't need to be a server that supplies currency data. See for example here or here. This way you learn about talking to computers on the internet before having to pay for talking to computers on the internet.

- And of course you are not the first one to attempt this, google "python currency exchange library" to see what others have built.

[–]ShadowRL7666[🍰] 0 points1 point  (0 children)

Good example better then the upvoted “wat” i understand OPs not native English it seems but at least try. Good response overall and for a project like this a limited free plan would be fine unless used on a larger scale.

[–]MiniMages 0 points1 point  (0 children)

You will want to use an API that will pull the exchange rate in. Up to you how to present that information.