A Python client for interacting with the AEBroadcast API service.
This package provides authentication and methods to retrieve financial data, such as stock quotes, from the AEBroadcast platform.
- π Simple authentication with the AEBroadcast API
- π Stock quotes and financial data retrieval
- π Automatic authentication token management
- β‘ Synchronous HTTP client with
httpx - π SSL verification via
ssl.SSLContext(default CA bundle fromcertifi) - π§Ύ Optional custom CA bundle support via
ssl_pem_path - π‘οΈ Robust exception handling
- β 100% test coverage
pip install broadcast-datafeedpip install git+https://github.com/sylvioCampos/broadcast-datafeed.gitgit clone https://github.com/sylvioCampos/broadcast-datafeed.git
cd broadcast-datafeed
uv sync --locked --all-extras --devfrom broadcast_datafeed import Broadcast
# Initialize the client
client = Broadcast("your_username", "your_password")
# Get quotes for a list of symbols
quotes = client.get_quote(["PETR4", "VALE3"])
print(quotes)
# Logout when done
client.logout()# Initialize with keep_alive to keep the session active
client = Broadcast("your_username", "your_password", keep_alive=True)
# Session will be kept alive automatically
quotes = client.get_quote(["BBAS3", "ITUB4"])client = Broadcast("your_username", "your_password")
# Request only specific fields
quotes = client.get_quote(
symbols=["PETR4", "VALE3"],
fields=["ULT", "VAR", "VOLUME"]
)client = Broadcast("your_username", "your_password")
# Check current token
print(f"Token: {client.token}")
print(f"Refresh Token: {client.refresh_token}")
# Refresh token manually
result = client.token_refresh()
if result["success"]:
print("Token refreshed successfully")import httpx
from broadcast_datafeed import Broadcast
try:
client = Broadcast("username", "password")
quotes = client.get_quote(["PETR4"])
except httpx.RequestError as e:
print(f"Connection error: {e}")
except httpx.HTTPStatusError as e:
print(f"HTTP error {e.response.status_code}")Broadcast(
usr: str,
pwd: str,
keep_alive: bool = False,
verify_ssl: bool = True,
ssl_pem_path: str | None = None,
)Parameters:
usr(str): Username for authenticationpwd(str): Password for authenticationkeep_alive(bool, optional): IfTrue, keeps the session alive. Default:Falseverify_ssl(bool, optional): IfTrue, verifies SSL certificates. Default:Truessl_pem_path(str, optional): Path to a PEM-encoded CA bundle file to load into the SSL context (in addition tocertifi). Default:None
Raises:
httpx.RequestError: Connection or SSL errorhttpx.HTTPStatusError: HTTP error returned by the API
Perform login against the API and return authentication tokens.
Returns: Dictionary containing token and refreshToken
Log out from the API, invalidating the current token.
Returns: Response from the API after logout
Keep the current API session alive.
Returns: Response from the API for the keep-alive request
Refresh the authentication token using the refresh token.
Returns: Result of the refresh operation or False on error
Retrieve quotes for the requested financial instruments.
Parameters:
symbols(list[str]): List of instrument symbolsfields(list[str], optional): List of desired fields. Default: all fields
Returns: Quote payload or error message
# Install uv
pip install uv
# Sync dependencies
uv sync --locked --all-extras --dev# Run all tests with coverage
uv run pytest --cov=broadcast_datafeed --cov-report=term-missing
# Run specific test file
uv run pytest tests/test_datafeed.py -v# Check code with ruff
uv run ruff check .
# Auto-fix issues when possible
uv run ruff check . --fixbroadcast/
βββ src/
β βββ broadcast_datafeed/
β βββ __init__.py # Package exports
β βββ datafeed.py # Main Broadcast class
β βββ py.typed # PEP 561 marker
βββ tests/
β βββ test_datafeed.py # Unit tests
βββ .github/
β βββ workflows/ # CI/CD with GitHub Actions
βββ pyproject.toml # Project configuration
βββ pytest.ini # Pytest configuration
βββ LICENSE # MIT License
βββ README.md # This file
Contributions are welcome! Please see CONTRIBUTING.md for more details on how to contribute.
- Fork the project
- Create a branch for your feature (
git checkout -b feature/MyFeature) - Commit your changes (
git commit -m 'Add MyFeature') - Push to the branch (
git push origin feature/MyFeature) - Open a Pull Request
Important: The current version allows disabling SSL verification via verify_ssl=False, which should only be used in development environments. For production use, always keep SSL verification enabled (default behavior).
This project is licensed under the MIT License - see the LICENSE file for details.
Sylvio Campos Neto
- Email: sylvio.campos@gmail.com.br
- GitHub: @sylvioCampos
- AEBroadcast for the financial data API
- Python community and
httpxmaintainers
Note: This is an unofficial client for the AEBroadcast API.