sdk.credit.transactions()
elements.sdk.api.credit
Get credit transactions.
Retrieves the detailed view of all transactions associated with a department. Can filter for a time range or transaction type.
Parameters
- credit_source_id (str) - The credit source (department) ID
- transaction_type (Transaction.TransactionType) - Type of transaction to filter by
- start_date (Timestamp) - Start date for the time range filter
- end_date (Timestamp) - End date for the time range filter
- algorithm_computation_id (str) - Filter by specific algorithm computation
- pagination (Pagination) - Pagination settings
Returns
CreditTransactionsResponse - Response containing list of transactions
Example(s)
from google.protobuf.timestamp_pb2 import Timestamp
from elements_api.models.credit_pb2 import Transaction
from elements_api.models.common_models_pb2 import Pagination
# Set up date range
start_date = Timestamp()
start_date.FromJsonString("2024-01-01T00:00:00Z")
end_date = Timestamp()
end_date.FromJsonString("2024-12-31T23:59:59Z")
# Get transactions
response = await sdk.credit.transactions(
credit_source_id="department-uuid",
transaction_type=Transaction.TransactionType.CONSUMPTION,
start_date=start_date,
end_date=end_date,
algorithm_computation_id="",
pagination=Pagination(page_size=100)
)
# Output contains list of transactions
for transaction in response.transactions:
print(f"Amount: {transaction.amount}, Reason: {transaction.reason}")Updated 6 months ago