This API allows us to query data from the Narodowy Bank Polski's public APIs and return relevant information from them.
- General Info
- Technologies Used
- Features
- Previews
- LoadTests
- Setup
- Project Status
- Room for Improvement
- Contact
- License
FLask Application and AWS API.
The documentation can be found
https://documenter.getpostman.com/view/24234549/2sA2xpTpBw
https://r2qw1eeeve.execute-api.eu-west-1.amazonaws.com/dev
User provides a date (formatted YYYY-MM-DD) and a currency code. Returns the average exchange rate.
GET /av_exchange_rate/{user_date}/{curr_code}
Headers
Name | value |
---|---|
Content-Type |
application/json |
Path Parameters
Name | Type | In | Required | Description |
---|---|---|---|---|
user_date |
string | path | Yes | Date |
curr_code |
string | path | Yes | Currency Code |
Status codes
Status code | Description |
---|---|
200 OK | Indicates a successful response. |
406 Not Acceptable | Indicates wrong header "Content-Type" |
422 Unprocessable Content | Request with wrong URL, or without required path parameters. |
Example Response:
{
"statusCode": 200,
"success": true,
"body": "\"You chose a currency code:EUR and a date (formatted YYYY-MM-DD): 2024-01-12. Average exchange rate is 4.3574.\""
}
https://r2qw1eeeve.execute-api.eu-west-1.amazonaws.com/dev/av_exchange_rate/{user_date}/{curr_code}
User gives 2 path parameters: {user_date} - a date (formatted YYYY-MM-DD) (example 2024-01-12) {curr_code} - a currency code (example EUR)
example:
https://r2qw1eeeve.execute-api.eu-west-1.amazonaws.com/dev/av_exchange_rate/2024-01-12/EUR
User provides a currency code and the number of last quotations N (N <= 255). Returns the max and min average value (every day has a different average).
GET /min_max_av/{curr_code}/{last_quo}
Headers
Name | value |
---|---|
Content-Type |
application/json |
Path Parameters
Name | Type | In | Required | Description |
---|---|---|---|---|
last_quo |
string | path | Yes | The number of last quotations |
curr_code |
string | path | Yes | Currency Code |
Status codes
Status code | Description |
---|---|
200 OK | Indicates a successful response. |
406 Not Acceptable | Indicates wrong header "Content-Type" |
422 Unprocessable Content | Request with wrong URL, or without required path parameters. |
Example Response:
{
"statusCode": 200,
"success": true,
"body": "\"You chose a currency code:GBP and the number of last quotations: 15. The max average value is 5.0812 and min average value is 4.966.\""
}
https://r2qw1eeeve.execute-api.eu-west-1.amazonaws.com/dev/ min_max_av/{curr_code}/{last_quo}
User gives 2 path parameters: {curr_code} - a currency code (example EUR) {last_quo} - the number of last quotations N (N <= 255) (example 15)
example:
https://r2qw1eeeve.execute-api.eu-west-1.amazonaws.com/dev/min_max_av/GBP/15
User provides a currency code and the number of last quotations N (N <= 255). Returns the major difference between the buy and ask rate (every day has different rates).
GET /major_diff/{curr_code}/{last_quo}
Headers
Name | value |
---|---|
Content-Type |
application/json |
Path Parameters
Name | Type | In | Required | Description |
---|---|---|---|---|
last_quo |
string | path | Yes | The number of last quotations |
curr_code |
string | path | Yes | Currency Code |
Status codes
Status code | Description |
---|---|
200 OK | Indicates a successful response. |
406 Not Acceptable | Indicates wrong header "Content-Type" |
422 Unprocessable Content | Request with wrong URL, or without required path parameters. |
Example Response:
{
"statusCode": 200,
"success": true,
"body": "\"You chose a currency code:USD and the number of last quotations: 10. The major difference between the buy and ask rate is 0.0820\""
}
https://r2qw1eeeve.execute-api.eu-west-1.amazonaws.com/dev/major_diff/{curr_code}/{last_quo}
User gives 2 path parameters: {curr_code} - a currency code (example USD) {last_quo} - the number of last quotations N (N <= 255) (example 10)
example
https://r2qw1eeeve.execute-api.eu-west-1.amazonaws.com/dev/major_diff/USD/10
- Python 3.11
- Flask 3.0.2
- Alembic 1.13.1
- SQLAlchemy 2.0.28
- Pytest 8.1.1
- Locust 2.27.0 - load tests
- PostgreSQL
- AWS (API Gateway + Lambda Funcitons)
- Postman
List the ready features here:
- Given a date (formatted YYYY-MM-DD) and a currency code (list: https://nbp.pl/en/statistic-and-financial-reporting/rates/table-a/), provide its average exchange rate.
- Given a currency code and the number of last quotations N (N <= 255), provide the max and min average value (every day has a different average).
- Given a currency code and the number of last quotations N (N <= 255), provide the major difference between the buy and ask rate (every day has different rates).
Load Tests made with Locust Library.
Full reports in html file -> Documentation/loadTests/reports_loadTests_html
- Clone repository NBP_API
git clone https://github.com/RockPiryt/NBP_API.git
- Enter Project Directory cd NBP_API
cd NBP_API
- Create database
- Rename .env.example to .env and set your calues
# SQLALCHEMY_DATABASE_URI template
SQLALCHEMY_DATABASE_URI = f"postgresql://{username_postdb}:{password_postdb}@{host_postdb}/{database_postdb}"
- Create a virtual evironment
python -m venv venv
- Activate Virtual Environment
source: venv/Scripts/activate
- Install packages from requirements.txt
pip install -r requirements.txt
- Migrate database
flask db upgrade
- Run command
flask run
Project is: in progress
Room for improvement:
- Unit/integration tests for Flask application.
- Docker image of the whole application.
- Swagger UI
- Created by @RockPiryt Github
- My Resume @RockPiryt Resume
Feel free to contact me!
This project is open source and available under the [aa]