nbg-currencies-api


Namenbg-currencies-api JSON
Version 0.1.4 PyPI version JSON
download
home_pageNone
SummaryA Python wrapper over NBG official exchange rate of LARI against foreign currencies
upload_time2025-01-12 09:35:07
maintainerNone
docs_urlNone
authorIllia Stebelskyi
requires_pythonNone
licenseMIT License Copyright (c) 2025 Illia Stebelskyi Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords nbg currencies api exchange rates
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ![PyPI version](https://img.shields.io/pypi/v/nbg-currencies-api?color=blue&label=PyPI&logo=python&logoColor=white)
[![codecov](https://codecov.io/github/zelnkup/nbg-currencies-api/graph/badge.svg?token=M4R1VT9PFU)](https://codecov.io/github/zelnkup/nbg-currencies-api)
# NBG Currency Service

`NBGCurrencyService` is a Python library designed to fetch and normalize currency exchange rates from the National Bank of Georgia (NBG) API. It provides both synchronous and asynchronous functionality, making it suitable for various applications.

---

## Features

- Fetch exchange rates for the current date or a specific date.
- Retrieve rates for all currencies or a specific currency.
- Supports both synchronous and asynchronous modes.
- Easy-to-use interface with well-structured data models.

---

## Installation

### Install the package

```bash
pip install nbg-currency-api
```

### For Asynchronous Support

To enable async mode, install with the optional `aiohttp` dependency:

```bash
pip install nbg-currency-api[async]
```

---

## Usage

### Synchronous Mode

Fetch rates for all currencies on the current date:

```python
from nbg_currency_api import NBGCurrencyService

service = NBGCurrencyService()
data = service.fetch()
print(data)
```

Fetch rates for a specific currency on a specific date:

```python
from datetime import datetime
from nbg_currency_api import NBGCurrencyService, CurrencyEnum

service = NBGCurrencyService(
    date=datetime(2023, 12, 25), currency=CurrencyEnum.USD
)
data = service.fetch()
print(data)
```

---

### Asynchronous Mode

Fetch rates asynchronously for a specific currency:

```python
import asyncio
from nbg_currency_api import NBGCurrencyService, CurrencyEnum, ClientModeEnum

async def main():
    service = NBGCurrencyService(currency=CurrencyEnum.EUR, mode=ClientModeEnum.ASYNC)
    data = await service.afetch()
    print(data)

asyncio.run(main())
```

---

## Data Models

### `CurrencyDataResponse`

This is the structured response returned by the service after fetching and normalizing data.

| Field           | Type              | Description                     |
|------------------|-------------------|---------------------------------|
| `date`          | `datetime`        | The date for the rates          |
| `currencies`    | `List[CurrencyRateItem]` | List of currency rate items   |

### `CurrencyRateItem`

Represents details of a single currency rate.

| Field           | Type       | Description                     |
|------------------|------------|---------------------------------|
| `code`          | `str`      | ISO code of the currency        |
| `quantity`      | `int`      | Quantity for the rate           |
| `rateFormated`  | `str`      | Formatted rate string           |
| `diffFormated`  | `str`      | Formatted difference string     |
| `rate`          | `float`    | Exchange rate                  |
| `name`          | `str`      | Currency name                  |
| `diff`          | `float`    | Rate difference                |
| `date`          | `datetime` | Date of the rate               |
| `validFromDate` | `datetime` | Start date for the rate         |

---

## Configuration

### Supported Currencies

The `CurrencyEnum` includes all ISO codes of supported currencies, such as:
- `CurrencyEnum.USD`
- `CurrencyEnum.EUR`
- `CurrencyEnum.GBP`

### Modes

- **`SYNC`** (default): Use synchronous requests with the `fetch` method.
- **`ASYNC`**: Use asynchronous requests with the `afetch` method.

---

## Example Output

Fetching exchange rates for USD:

```python
from nbg_currency_api import NBGCurrencyService, CurrencyEnum

service = NBGCurrencyService(currency=CurrencyEnum.USD)
data = service.fetch()

print(data)
```

Sample output:

```python
CurrencyDataResponse(
    date=datetime.datetime(2025, 1, 7, 0, 0),
    currencies=[
        CurrencyRateItem(
            code='USD',
            quantity=1,
            rateFormated='3.20',
            diffFormated='+0.02',
            rate=3.2,
            name='US Dollar',
            diff=0.02,
            date=datetime.datetime(2025, 1, 7, 0, 0),
            validFromDate=datetime.datetime(2025, 1, 6, 0, 0)
        )
    ]
)
```

---

## License

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "nbg-currencies-api",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "nbg, currencies, api, exchange rates",
    "author": "Illia Stebelskyi",
    "author_email": "Illia Stebelskyi <illia.stebelski@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/9a/fb/4dfd7e903db4af9d25cd6a09cedb4ff1254bcece9cdcb6219427e73adfc2/nbg_currencies_api-0.1.4.tar.gz",
    "platform": null,
    "description": "![PyPI version](https://img.shields.io/pypi/v/nbg-currencies-api?color=blue&label=PyPI&logo=python&logoColor=white)\n[![codecov](https://codecov.io/github/zelnkup/nbg-currencies-api/graph/badge.svg?token=M4R1VT9PFU)](https://codecov.io/github/zelnkup/nbg-currencies-api)\n# NBG Currency Service\n\n`NBGCurrencyService` is a Python library designed to fetch and normalize currency exchange rates from the National Bank of Georgia (NBG) API. It provides both synchronous and asynchronous functionality, making it suitable for various applications.\n\n---\n\n## Features\n\n- Fetch exchange rates for the current date or a specific date.\n- Retrieve rates for all currencies or a specific currency.\n- Supports both synchronous and asynchronous modes.\n- Easy-to-use interface with well-structured data models.\n\n---\n\n## Installation\n\n### Install the package\n\n```bash\npip install nbg-currency-api\n```\n\n### For Asynchronous Support\n\nTo enable async mode, install with the optional `aiohttp` dependency:\n\n```bash\npip install nbg-currency-api[async]\n```\n\n---\n\n## Usage\n\n### Synchronous Mode\n\nFetch rates for all currencies on the current date:\n\n```python\nfrom nbg_currency_api import NBGCurrencyService\n\nservice = NBGCurrencyService()\ndata = service.fetch()\nprint(data)\n```\n\nFetch rates for a specific currency on a specific date:\n\n```python\nfrom datetime import datetime\nfrom nbg_currency_api import NBGCurrencyService, CurrencyEnum\n\nservice = NBGCurrencyService(\n    date=datetime(2023, 12, 25), currency=CurrencyEnum.USD\n)\ndata = service.fetch()\nprint(data)\n```\n\n---\n\n### Asynchronous Mode\n\nFetch rates asynchronously for a specific currency:\n\n```python\nimport asyncio\nfrom nbg_currency_api import NBGCurrencyService, CurrencyEnum, ClientModeEnum\n\nasync def main():\n    service = NBGCurrencyService(currency=CurrencyEnum.EUR, mode=ClientModeEnum.ASYNC)\n    data = await service.afetch()\n    print(data)\n\nasyncio.run(main())\n```\n\n---\n\n## Data Models\n\n### `CurrencyDataResponse`\n\nThis is the structured response returned by the service after fetching and normalizing data.\n\n| Field           | Type              | Description                     |\n|------------------|-------------------|---------------------------------|\n| `date`          | `datetime`        | The date for the rates          |\n| `currencies`    | `List[CurrencyRateItem]` | List of currency rate items   |\n\n### `CurrencyRateItem`\n\nRepresents details of a single currency rate.\n\n| Field           | Type       | Description                     |\n|------------------|------------|---------------------------------|\n| `code`          | `str`      | ISO code of the currency        |\n| `quantity`      | `int`      | Quantity for the rate           |\n| `rateFormated`  | `str`      | Formatted rate string           |\n| `diffFormated`  | `str`      | Formatted difference string     |\n| `rate`          | `float`    | Exchange rate                  |\n| `name`          | `str`      | Currency name                  |\n| `diff`          | `float`    | Rate difference                |\n| `date`          | `datetime` | Date of the rate               |\n| `validFromDate` | `datetime` | Start date for the rate         |\n\n---\n\n## Configuration\n\n### Supported Currencies\n\nThe `CurrencyEnum` includes all ISO codes of supported currencies, such as:\n- `CurrencyEnum.USD`\n- `CurrencyEnum.EUR`\n- `CurrencyEnum.GBP`\n\n### Modes\n\n- **`SYNC`** (default): Use synchronous requests with the `fetch` method.\n- **`ASYNC`**: Use asynchronous requests with the `afetch` method.\n\n---\n\n## Example Output\n\nFetching exchange rates for USD:\n\n```python\nfrom nbg_currency_api import NBGCurrencyService, CurrencyEnum\n\nservice = NBGCurrencyService(currency=CurrencyEnum.USD)\ndata = service.fetch()\n\nprint(data)\n```\n\nSample output:\n\n```python\nCurrencyDataResponse(\n    date=datetime.datetime(2025, 1, 7, 0, 0),\n    currencies=[\n        CurrencyRateItem(\n            code='USD',\n            quantity=1,\n            rateFormated='3.20',\n            diffFormated='+0.02',\n            rate=3.2,\n            name='US Dollar',\n            diff=0.02,\n            date=datetime.datetime(2025, 1, 7, 0, 0),\n            validFromDate=datetime.datetime(2025, 1, 6, 0, 0)\n        )\n    ]\n)\n```\n\n---\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details.\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2025 Illia Stebelskyi  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "A Python wrapper over NBG official exchange rate of LARI against foreign currencies",
    "version": "0.1.4",
    "project_urls": {
        "Home": "https://github.com/zelnkup/nbg-currencies-api"
    },
    "split_keywords": [
        "nbg",
        " currencies",
        " api",
        " exchange rates"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1bef9c0f2a636cf74d27478ceacc7f2bb6df8336caabf1f1c7171e7b0d38641d",
                "md5": "e79da36399ea0742872406156bfa2c96",
                "sha256": "dd156a1bc91536bb404e2a421a9e3067a4b1eb8991520a4d6180c33d4c72b6ed"
            },
            "downloads": -1,
            "filename": "nbg_currencies_api-0.1.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e79da36399ea0742872406156bfa2c96",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 10778,
            "upload_time": "2025-01-12T09:35:06",
            "upload_time_iso_8601": "2025-01-12T09:35:06.189783Z",
            "url": "https://files.pythonhosted.org/packages/1b/ef/9c0f2a636cf74d27478ceacc7f2bb6df8336caabf1f1c7171e7b0d38641d/nbg_currencies_api-0.1.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9afb4dfd7e903db4af9d25cd6a09cedb4ff1254bcece9cdcb6219427e73adfc2",
                "md5": "f65228436ac53689cdc80d38a343f468",
                "sha256": "e7ccd0cbfa6677ea7b315e0b50c8e3e79e8ba0622dc9f84977e2ee81db00eba1"
            },
            "downloads": -1,
            "filename": "nbg_currencies_api-0.1.4.tar.gz",
            "has_sig": false,
            "md5_digest": "f65228436ac53689cdc80d38a343f468",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 8116,
            "upload_time": "2025-01-12T09:35:07",
            "upload_time_iso_8601": "2025-01-12T09:35:07.164725Z",
            "url": "https://files.pythonhosted.org/packages/9a/fb/4dfd7e903db4af9d25cd6a09cedb4ff1254bcece9cdcb6219427e73adfc2/nbg_currencies_api-0.1.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-12 09:35:07",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "zelnkup",
    "github_project": "nbg-currencies-api",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "nbg-currencies-api"
}
        
Elapsed time: 1.14862s