File: usage.md

package info (click to toggle)
python-aioopenexchangerates 0.4.14-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 440 kB
  • sloc: python: 298; makefile: 13; javascript: 8
file content (28 lines) | stat: -rw-r--r-- 811 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Usage

To use this package, import the client and instantiate it. Then call the appropriate client method to get exchange rates data. The client methods will correspond to the [endpoints](https://docs.openexchangerates.org/) of the Open Exchange Rates API.

For example, to get the latest exchange rates:

```py
import asyncio

from aioopenexchangerates import Client, OpenExchangeRatesError


async def main() -> None:
    """Run main."""
    async with Client("your_api_key") as client:
        try:
            result = await client.get_latest()
        except OpenExchangeRatesError as err:
            print(err)
        else:
            print(result)


if __name__ == "__main__":
    asyncio.run(main())
```

You will need an API key from the [Open Exchange Rates API](https://openexchangerates.org/).