From 7157920e1e0f3e0a4b9541495ba689a4113e2a85 Mon Sep 17 00:00:00 2001 From: Redume Date: Fri, 8 Nov 2024 20:26:48 +0300 Subject: [PATCH] docs: Documentation for api endpoints --- docs/endpoints/create-chart.md | 130 +++++++++++++++++++++++++++ docs/endpoints/get-rate.md | 159 +++++++++++++++++++++++++++++++++ mkdocs.yml | 9 +- 3 files changed, 297 insertions(+), 1 deletion(-) create mode 100644 docs/endpoints/create-chart.md create mode 100644 docs/endpoints/get-rate.md diff --git a/docs/endpoints/create-chart.md b/docs/endpoints/create-chart.md new file mode 100644 index 0000000..acfc118 --- /dev/null +++ b/docs/endpoints/create-chart.md @@ -0,0 +1,130 @@ +Creating a currency rate chart. + +## Creating a graph for a certain period + +### Request +=== "Shell" + === "Curl" + ```bash + curl --request GET \ + --url https://kekkai-api.redume.su/api/getChart/week?from_currency=RUB&conv_currency=USD + ``` +=== "Python" + === "Request" + ```python + import requests + + res = requests.get('https://kekkai-api.redume.su/api/getChart/week', { + 'from_currency': 'USD', + 'conv_currency': 'RUB', + }, timeout=3) + + print(res.json()) + ``` + +=== "Node.JS" + === "Axios" + ```js + const axios = require('axios'); + + axios.get('https://kekkai-api.redume.su/api/getChart/week', { + timeout: 3000, + 'from_currency': 'USD', + 'conv_currency': 'RUB', + }) + .then((res) => { + console.log(res['data']); + }) + .catch((err) => { + console.error(err); + }); + ``` + +### Query params +| Parameter | Description | +|---------------|-------------------------------------------------------------------------| +| `from_currency` | `ISO 4217` code of the currency from which the conversion takes place | +| `conv_currency` | `ISO 4217` code of the currency to which the conversion is performed | + +### URL params +| Parameter | Description | +|---------------|-------------------------------------------------------------------------| +| `period` | Available parameters: `week`, `month`, `quarter`, `year` | + +### Response +!!! info "Output" + ```json + { + "status": 201, + "message": "http://kekkai-api.redume.su/static/charts/RUB_USD_20241108_DQVDN7.png" + } + ``` + + +## Creating a schedule for specific days + +### Request +=== "Shell" + === "Curl" + ```bash + curl --request GET \ + --url https://kekkai-api.redume.su/api/getChart/?from_currency=RUB&conv_currency=USD&start_date=2024-10-31&end_date=2024-11-08 + ``` +=== "Python" + === "Request" + ```python + import requests + + res = requests.get('https://kekkai-api.redume.su/api/getChart/', { + 'from_currency': 'USD', + 'conv_currency': 'RUB', + 'start_date': '2024-10-31', + 'end_date': '2024-11-08' + }, timeout=3) + + print(res.json()) + ``` + +=== "Node.JS" + === "Axios" + ```js + const axios = require('axios'); + + axios.get('https://kekkai-api.redume.su/api/getChart/', { + timeout: 3000, + 'from_currency': 'USD', + 'conv_currency': 'RUB', + 'start_date': '2024-10-31', + 'end_date': '2024-11-08' + }) + .then((res) => { + console.log(res['data']); + }) + .catch((err) => { + console.error(err); + }); + ``` + +### Query params +| Parameter | Description | +|---------------|-------------------------------------------------------------------------| +| `from_currency` | `ISO 4217` code of the currency from which the conversion takes place | +| `conv_currency` | `ISO 4217` code of the currency to which the conversion is performed | +| `start_date` | Start date of the period in the format `YYYYY-DD-MM` | +| `end_date` | Period end date in the format `YYYYY-DD-MM` | + +### Response +!!! info "Output" + ```json + { + "status": 400, + "message": "http://kekkai-api.redume.su/static/charts/RUB_USD_20241108_1T2RI3.png" + } + ``` + +## What the name of the chart file consists of +Example: ``.../RUB_USD_20241108_DQVDN7.png`` + +- `RUB_USD` - Name of currencies. +- `20241108` - Schedule request date in `YYYMMDD` format. +- `DQVDN7` - Random file character identifier. \ No newline at end of file diff --git a/docs/endpoints/get-rate.md b/docs/endpoints/get-rate.md new file mode 100644 index 0000000..30df6ce --- /dev/null +++ b/docs/endpoints/get-rate.md @@ -0,0 +1,159 @@ +Currencies are identified by standard three-letter `ISO 4217` currency codes. + +## Getting the currency rate for a certain day. + +### Request +=== "Shell" + === "Curl" + ```bash + curl --request GET \ + --url https://kekkai-api.redume.su/api/getRate/?from_currency=RUB&conv_currency=USD&date=2024-10-16 + ``` + +=== "Python" + === "Requests" + ```py + import requests + + res = requests.get('https://kekkai-api.redume.su/api/getRate/', { + 'from_currency': 'RUB', + 'conv_currency': 'USD', + 'date': '2024-10-16', + }, timeout=3) + + print(res.json()) + ``` + + +=== "Node.JS" + === "Axios" + ```js + const axios = require('axios'); + + axios.get('https://kekkai-api.redume.su/api/getRate/', { + timeout: 3000, + 'from_currency': 'RUB', + 'conv_currency': 'USD', + 'date': '2024-10-16', + } + ) + .then((res) => { + console.log(JSON.stringify(res.json())); + }) + .catch((err) => { + console.error(err); + }); + ``` + +### Query Parameters +| Parameter | Description | +|---------------|-------------------------------------------------------------------------| +| `from_currency` | `ISO 4217` code of the currency from which the conversion takes place | +| `conv_currency` | `ISO 4217` code of the currency to which the conversion is performed | +| `date` | Currency rate date in the format `YYYYY-DD-MM` | + +### Response +!!! info "Output" + ```json + [ + { + "from_currency": "RUB", + "conv_currency": "USD", + "rate": 0.01, + "date": "2024-10-17T00:00:00.000Z" + } + ] + ``` + +## Get currency exchange rate for a certain period +Getting the list of the array with currency rate for a certain period of time. + +### Request +=== "Shell" + === "Curl" + ```bash + curl --request GET \ + --url https://kekkai-api.redume.su/api/getRate/?from_currency=RUB&conv_currency=USD&start_date=2024-10-16&end_date=2024-10-20 + ``` + +=== "Python" + === "Requests" + ```py + import requests + + res = requests.get('https://kekkai-api.redume.su/api/getRate/', { + 'from_currency': 'RUB', + 'conv_currency': 'USD', + 'start_date': '2024-10-16', + 'end_date': '2024-10-20', + }, timeout=3) + + print(res.json()) + ``` + + +=== "Node.JS" + === "Axios" + ```js + const axios = require('axios'); + + axios.get('https://kekkai-api.redume.su/api/getRate/', { + timeout: 3000, + 'from_currency': 'RUB', + 'conv_currency': 'USD', + 'start_date': '2024-10-16', + 'end_date': '2024-10-20', + } + ) + .then((res) => { + console.log(res['data']); + }) + .catch((err) => { + console.error(err); + }); + ``` + +### Query params +| Parameter | Description | +|---------------|-------------------------------------------------------------------------| +| `from_currency` | `ISO 4217` code of the currency from which the conversion takes place | +| `conv_currency` | `ISO 4217` code of the currency to which the conversion is performed | +| `start_date` | Start date of the period in the format `YYYYY-DD-MM` | +| `end_date` | Period end date in the format `YYYYY-DD-MM` | + +### Response +!!! info "Output" + ```json + [ + { + "from_currency": "RUB", + "conv_currency": "USD", + "rate": 0.01, + "date": "2024-10-17T00:00:00.000Z" + }, + { + "from_currency": "RUB", + "conv_currency": "USD", + "rate": 0.01, + "date": "2024-10-18T00:00:00.000Z" + }, + { + "from_currency": "RUB", + "conv_currency": "USD", + "rate": 0.01, + "date": "2024-10-19T00:00:00.000Z" + }, + { + "from_currency": "RUB", + "conv_currency": "USD", + "rate": 0.01, + "date": "2024-10-20T00:00:00.000Z" + }, + { + "from_currency": "RUB", + "conv_currency": "USD", + "rate": 0.01, + "date": "2024-10-21T00:00:00.000Z" + } + ] + ``` \ No newline at end of file diff --git a/mkdocs.yml b/mkdocs.yml index c4386fa..0bd4930 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -14,6 +14,9 @@ nav: - Docker [Recommended]: getting-started/docker.md - Manual: getting-started/manual.md - Contributing: getting-started/contributing.md + - Endpoints: + - Get currency rate - /api/getRate: endpoints/get-rate.md + - Create Charts - /api/getChart: endpoints/create-chart.md - Config: - Configure config.yaml: config/config-yaml.md - Configure .env: config/config-env.md @@ -39,8 +42,11 @@ theme: features: - content.code.copy + - content.tabs.link markdown_extensions: + - pymdownx.tabbed: + alternate_style: true - pymdownx.highlight: anchor_linenums: true line_spans: __span @@ -50,4 +56,5 @@ markdown_extensions: - pymdownx.superfences - admonition - pymdownx.details - - pymdownx.superfences \ No newline at end of file + - pymdownx.superfences + - tables \ No newline at end of file