Get Balance From API

Python ExamplesUpdated 12/17/2025

Before making any API requests, you must add the SolverifyAPI class to your project. This class handles authentication, request formatting, and error handling for the Solverify API.

Requirement: Python 3.8+ and the requests package.

  • Initialize the API client:
    After adding the class code, create an instance using your API key:

    api = SolverifyAPI("YOUR_API_KEY")
    

    This API key will be used to authenticate all requests made through the client.

  • Retrieve your account balance
    You can check your current balance by calling the get_balance() method:

    balance = api.get_balance()
    print(f"Your balance: {balance}")
    

Example output:

Your balance: 10.0001

The balance is returned as a floating-point number, rounded to 4 decimal places.

Error handling

If the API returns an error (for example, an invalid API key or insufficient balance), the method will raise an exception with a descriptive error message.
It is recommended to wrap calls in a try/except block for production use.

try:
    balance = api.get_balance()
    print(balance)
except Exception as e:
    print(f"API error: {e}")