This API offers simple GET request, fetching currency values to Polish Zloty. It also allows to get sale statistics based date parameter. GET requests return in form of JSON.
This projects implements automatic database creation for currency values. It also provides sample database file sales.db for sales statistic API demonstration.
- Clone this repo:
git clone https://github.com/Rochala/skryptowe20.git
- ** Checkout to REST branch **
git checkout REST
- Install requirement
pip install -r requirements.txt
- Run initializing script
python3 init.py
- [OPTIONAL] Make sure models.py SalesStats contains every currency
- ** Configure Django project to your needs **
- Start django
python3 manage.py runserver
- Make sure NBP api supports it
- Add new currency symbol to constants.py Currency enum
- Run init.py script
python3 init.py
- Add new variable in models.py to SalesStats class following way:
{CURRENCY_SYMBOL_LOWERCASED} = models.FloatField()
Currency data range
http://127.0.0.1:8000/CurrencyRange/?symbol={CURRENCY SYMBOL}start={DATE START}&end={DATE END}
Example usage for USD between 2020-12-01 and 2020-12-16
http://127.0.0.1:8000/CurrencyRange/?symbol=USD&start=2020-12-01&end=2020-12-16
Sales statistics
http://127.0.0.1:8000/SaleStats/?date={SELECTED DATE}
Example usage for fetching sales from 2005-05-17
http://127.0.0.1:8000/SaleStats/?date=2005-05-17
You can also get whole range by using
http://127.0.0.1:8000/SaleStats/
User type | Limit |
---|---|
Anonymous user: | 10 / hour |
Standard User : | 1000 / hour |
Currency API is also limited by dates 2001-01-02 and 2020-12-17
Avaliable currencies are: 'USD', 'EUR', 'CHF'