Async PrivatBank API Client Usage
This FastAPI application serves as an asynchronous client for interacting with the PrivatBank API. It facilitates operations such as managing Privat model data, fetching currency rates, retrieving client information, checking account balances, managing account statements, and executing payments. Designed similar to the Django DRF app, the FastAPI app leverages asynchronous capabilities for higher performance.
Manage Privat Model (CRUD Operations)
Perform Create, Read, Update, and Delete (CRUD) actions on the Privat model.
POST - Add Privat model entry
POST /privat HTTP/1.1
Content-Type: application/json
Host: example.com
Request Body Example:
{
"name": "Example",
"description": "Sample entry"
}
Response Example:
{
"id": 1,
"name": "Example",
"description": "Sample entry",
"created_at": "2023-11-01T12:00:00"
}
PUT - Update Privat model entry
PUT /privat/{id} HTTP/1.1
Content-Type: application/json
Host: example.com
Request Body Example:
{
"name": "Updated Name",
"description": "Updated description"
}
Response Example:
{
"id": 1,
"name": "Updated Name",
"description": "Updated description",
"updated_at": "2023-11-01T12:30:00"
}
DELETE - Remove Privat model entry
DELETE /privat/{id} HTTP/1.1
Host: example.com
Response Example:
{
"message": "Privat model entry deleted successfully."
}
Fetch Currency Rates
Retrieve current currency rates.
GET - /currencies
The /currencies endpoint supports fetching rates for both cash and non-cash transactions.
Request Example:
GET /currencies?type=cash HTTP/1.1
Host: example.com
Response Example:
{
"currencies": [
{
"currency": "USD",
"rate": 27.5,
"type": "cash"
},
{
"currency": "EUR",
"rate": 31.0,
"type": "cash"
}
]
}
Retrieve Client Information
Fetch detailed information about a client.
GET - /client_info
Request Example:
GET /client_info?client_id=123 HTTP/1.1
Host: example.com
Successful Response Example:
{
"client_id": 123,
"name": "John Doe",
"email": "john.doe@example.com",
"phone": "+380123456789"
}
Error Response Example:
{
"detail": "Client not found."
}
Fetch Account Balance
Retrieve the balance of a specific account.
GET - /balance
Request Example:
GET /balance?account_id=456 HTTP/1.1
Host: example.com
Response Example:
{
"account_id": 456,
"currency": "UAH",
"balance": 10000.50
}
Fetch Account Statements
Retrieve detailed account statements by posting request data.
Request Body Example:
POST /statement HTTP/1.1
Content-Type: application/json
{
"account_id": 456,
"start_date": "2023-10-01",
"end_date": "2023-10-31"
}
Successful Response Example:
{
"account_id": 456,
"statements": [
{
"date": "2023-10-01",
"amount": -500.0,
"description": "ATM withdrawal"
},
{
"date": "2023-10-05",
"amount": 2000.0,
"description": "Salary deposit"
}
]
}
Error Response Example:
{
"detail": "No statements found for the provided date range."
}
Execute Payment
Process a payment through the PrivatBank API.
Request Body Example:
POST /payment HTTP/1.1
Content-Type: application/json
{
"source_account": 456,
"destination_account": 789,
"amount": 1500.0,
"currency": "UAH",
"description": "Payment for services"
}
Successful Response Example:
{
"status": "success",
"transaction_id": "TRX12345678",
"description": "Payment successfully processed."
}
Error Response Example:
{
"status": "error",
"detail": "Insufficient funds."
}