Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
name: CI
on:
push:
branches-ignore:
- 'generated'
- 'codegen/**'
- 'integrated/**'
- 'stl-preview-head/**'
- 'stl-preview-base/**'
branches:
- '**'
- '!integrated/**'
- '!stl-preview-head/**'
- '!stl-preview-base/**'
- '!generated'
- '!codegen/**'
- 'codegen/stl/**'
pull_request:
branches-ignore:
- 'stl-preview-head/**'
Expand All @@ -17,7 +19,7 @@ jobs:
timeout-minutes: 10
name: lint
runs-on: ${{ github.repository == 'stainless-sdks/brapi-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata')
steps:
- uses: actions/checkout@v6

Expand All @@ -36,7 +38,7 @@ jobs:
run: ./scripts/lint

build:
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata')
timeout-minutes: 10
name: build
permissions:
Expand All @@ -61,14 +63,18 @@ jobs:
run: rye build

- name: Get GitHub OIDC Token
if: github.repository == 'stainless-sdks/brapi-python'
if: |-
github.repository == 'stainless-sdks/brapi-python' &&
!startsWith(github.ref, 'refs/heads/stl/')
id: github-oidc
uses: actions/github-script@v8
with:
script: core.setOutput('github_token', await core.getIDToken());

- name: Upload tarball
if: github.repository == 'stainless-sdks/brapi-python'
if: |-
github.repository == 'stainless-sdks/brapi-python' &&
!startsWith(github.ref, 'refs/heads/stl/')
env:
URL: https://pkg.stainless.com/s
AUTH: ${{ steps.github-oidc.outputs.github_token }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.prism.log
.stdy.log
_dev

__pycache__
Expand Down
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "1.2.0"
".": "1.3.0"
}
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 11
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/alisson%2Fbrapi-76a60a630b8eaac37bdec27ffec5cbdf6640fb884186adb08211f1b81832c075.yml
openapi_spec_hash: 51fab4b9fd59ce7421f3fdf03644c987
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/alisson/brapi-e435f4c22e29023c8aad36810a131a9c61deb632426a335d47b4efd3acd33c34.yml
openapi_spec_hash: e7c3e281560ced3c46577c08902723cc
config_hash: 6f10a67950f65bf850612b59838ad03b
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
# Changelog

## 1.3.0 (2026-05-01)

Full Changelog: [v1.2.0...v1.3.0](https://github.com/brapi-dev/brapi-python/compare/v1.2.0...v1.3.0)

### Features

* **api:** api update ([3cd15f0](https://github.com/brapi-dev/brapi-python/commit/3cd15f03d4ef87c43d54a307b5de78cb1668d5fd))


### Chores

* format all `api.md` files ([691c9c6](https://github.com/brapi-dev/brapi-python/commit/691c9c699beb5779f2593de827024d861963eb73))
* **internal:** add request options to SSE classes ([c83d52b](https://github.com/brapi-dev/brapi-python/commit/c83d52b1acbd6d9f062aa08aea4633d2ff465ab3))
* **internal:** bump dependencies ([2afb698](https://github.com/brapi-dev/brapi-python/commit/2afb69816a7f44ee93344c61f94eb86f4c340e9f))
* **internal:** codegen related update ([1cd1130](https://github.com/brapi-dev/brapi-python/commit/1cd11301a9c48f7e87080f3c0fed1b7ffe65d24e))
* **internal:** codegen related update ([ca33256](https://github.com/brapi-dev/brapi-python/commit/ca33256ebbce63bc4d1704fed00dfec12fcaee3e))
* **internal:** codegen related update ([c544f50](https://github.com/brapi-dev/brapi-python/commit/c544f50c8fd0ffe00e9736da46380290f355ead6))
* **internal:** codegen related update ([6692c9b](https://github.com/brapi-dev/brapi-python/commit/6692c9b20d96d03d072e1db6b56bbcdfe1d852a5))
* **internal:** codegen related update ([b344fe8](https://github.com/brapi-dev/brapi-python/commit/b344fe8ef180aa53bcba7cae0ab1736031f79941))
* **internal:** codegen related update ([c48bfd7](https://github.com/brapi-dev/brapi-python/commit/c48bfd77ef22184d9befd319f68a4653e68f03b2))
* **internal:** fix lint error on Python 3.14 ([8f891ca](https://github.com/brapi-dev/brapi-python/commit/8f891ca4cd532ff0b5bc2ea4748868189d1ac5bf))
* **internal:** make `test_proxy_environment_variables` more resilient ([a298056](https://github.com/brapi-dev/brapi-python/commit/a298056128baf138f8493c80d34ecc8d67af02fa))
* **internal:** make `test_proxy_environment_variables` more resilient to env ([a2e60c5](https://github.com/brapi-dev/brapi-python/commit/a2e60c5bb3762cf3de9e7bb7d54a3e6b91a77fb4))
* **internal:** remove mock server code ([02c10f5](https://github.com/brapi-dev/brapi-python/commit/02c10f56762ea1456bc03934ebddd6c6f78fef81))
* update mock server docs ([4b7594f](https://github.com/brapi-dev/brapi-python/commit/4b7594fc083f530ddddeaa052a641efaccaf8d6b))

## 1.2.0 (2026-01-30)

Full Changelog: [v1.1.0...v1.2.0](https://github.com/brapi-dev/brapi-python/compare/v1.1.0...v1.2.0)
Expand Down
7 changes: 0 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,6 @@ $ pip install ./path-to-wheel-file.whl

## Running tests

Most tests require you to [set up a mock server](https://github.com/stoplightio/prism) against the OpenAPI spec to run the tests.

```sh
# you will need npm installed
$ npx prism mock path/to/your/openapi.yml
```

```sh
$ ./scripts/test
```
Expand Down
30 changes: 16 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@ pip install brapi
The full API of this library can be found in [api.md](api.md).

```python
import os
from brapi import Brapi

client = Brapi(
api_key=os.environ.get("BRAPI_API_KEY"), # This is the default and can be omitted
api_key="My API Key",
# defaults to "production".
environment="environment_1",
)
Expand All @@ -40,22 +39,16 @@ quote = client.quote.retrieve(
print(quote.requested_at)
```

While you can provide an `api_key` keyword argument,
we recommend using [python-dotenv](https://pypi.org/project/python-dotenv/)
to add `BRAPI_API_KEY="My API Key"` to your `.env` file
so that your API Key is not stored in source control.

## Async usage

Simply import `AsyncBrapi` instead of `Brapi` and use `await` with each API call:

```python
import os
import asyncio
from brapi import AsyncBrapi

client = AsyncBrapi(
api_key=os.environ.get("BRAPI_API_KEY"), # This is the default and can be omitted
api_key="My API Key",
# defaults to "production".
environment="environment_1",
)
Expand Down Expand Up @@ -87,15 +80,14 @@ pip install brapi[aiohttp]
Then you can enable it by instantiating the client with `http_client=DefaultAioHttpClient()`:

```python
import os
import asyncio
from brapi import DefaultAioHttpClient
from brapi import AsyncBrapi


async def main() -> None:
async with AsyncBrapi(
api_key=os.environ.get("BRAPI_API_KEY"), # This is the default and can be omitted
api_key="My API Key",
http_client=DefaultAioHttpClient(),
) as client:
quote = await client.quote.retrieve(
Expand Down Expand Up @@ -129,7 +121,9 @@ All errors inherit from `brapi.APIError`.
import brapi
from brapi import Brapi

client = Brapi()
client = Brapi(
api_key="My API Key",
)

try:
client.quote.retrieve(
Expand Down Expand Up @@ -172,6 +166,7 @@ from brapi import Brapi

# Configure the default for all requests:
client = Brapi(
api_key="My API Key",
# default is 2
max_retries=0,
)
Expand All @@ -192,12 +187,14 @@ from brapi import Brapi

# Configure the default for all requests:
client = Brapi(
api_key="My API Key",
# 20 seconds (default is 1 minute)
timeout=20.0,
)

# More granular control:
client = Brapi(
api_key="My API Key",
timeout=httpx.Timeout(60.0, read=5.0, write=10.0, connect=2.0),
)

Expand Down Expand Up @@ -244,7 +241,9 @@ The "raw" Response object can be accessed by prefixing `.with_raw_response.` to
```py
from brapi import Brapi

client = Brapi()
client = Brapi(
api_key="My API Key",
)
response = client.quote.with_raw_response.retrieve(
tickers="REPLACE_ME",
)
Expand Down Expand Up @@ -323,6 +322,7 @@ import httpx
from brapi import Brapi, DefaultHttpxClient

client = Brapi(
api_key="My API Key",
# Or use the `BRAPI_BASE_URL` env var
base_url="http://my.test.server.example.com:8083",
http_client=DefaultHttpxClient(
Expand All @@ -345,7 +345,9 @@ By default the library closes underlying HTTP connections whenever the client is
```py
from brapi import Brapi

with Brapi() as client:
with Brapi(
api_key="My API Key",
) as client:
# make requests here
...

Expand Down
8 changes: 2 additions & 6 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ Types:
```python
from brapi.types import (
BalanceSheetEntry,
CashflowEntry,
DefaultKeyStatisticsEntry,
FinancialDataEntry,
IncomeStatementEntry,
ValueAddedEntry,
QuoteRetrieveResponse,
QuoteListResponse,
)
Expand Down Expand Up @@ -71,7 +67,7 @@ from brapi.types.v2 import InflationRetrieveResponse, InflationListAvailableResp
Methods:

- <code title="get /api/v2/inflation">client.v2.inflation.<a href="./src/brapi/resources/v2/inflation.py">retrieve</a>(\*\*<a href="src/brapi/types/v2/inflation_retrieve_params.py">params</a>) -> <a href="./src/brapi/types/v2/inflation_retrieve_response.py">InflationRetrieveResponse</a></code>
- <code title="get /api/v2/inflation/available">client.v2.inflation.<a href="./src/brapi/resources/v2/inflation.py">list_available</a>(\*\*<a href="src/brapi/types/v2/inflation_list_available_params.py">params</a>) -> <a href="./src/brapi/types/v2/inflation_list_available_response.py">InflationListAvailableResponse</a></code>
- <code title="get /api/v2/inflation/available">client.v2.inflation.<a href="./src/brapi/resources/v2/inflation.py">list_available</a>() -> <a href="./src/brapi/types/v2/inflation_list_available_response.py">InflationListAvailableResponse</a></code>

## PrimeRate

Expand All @@ -84,4 +80,4 @@ from brapi.types.v2 import PrimeRateRetrieveResponse, PrimeRateListAvailableResp
Methods:

- <code title="get /api/v2/prime-rate">client.v2.prime_rate.<a href="./src/brapi/resources/v2/prime_rate.py">retrieve</a>(\*\*<a href="src/brapi/types/v2/prime_rate_retrieve_params.py">params</a>) -> <a href="./src/brapi/types/v2/prime_rate_retrieve_response.py">PrimeRateRetrieveResponse</a></code>
- <code title="get /api/v2/prime-rate/available">client.v2.prime_rate.<a href="./src/brapi/resources/v2/prime_rate.py">list_available</a>(\*\*<a href="src/brapi/types/v2/prime_rate_list_available_params.py">params</a>) -> <a href="./src/brapi/types/v2/prime_rate_list_available_response.py">PrimeRateListAvailableResponse</a></code>
- <code title="get /api/v2/prime-rate/available">client.v2.prime_rate.<a href="./src/brapi/resources/v2/prime_rate.py">list_available</a>() -> <a href="./src/brapi/types/v2/prime_rate_list_available_response.py">PrimeRateListAvailableResponse</a></code>
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "brapi"
version = "1.2.0"
version = "1.3.0"
description = "The official Python library for the brapi API"
dynamic = ["readme"]
license = "Apache-2.0"
Expand All @@ -11,7 +11,7 @@ authors = [
dependencies = [
"httpx>=0.23.0, <1",
"pydantic>=1.9.0, <3",
"typing-extensions>=4.10, <5",
"typing-extensions>=4.14, <5",
"anyio>=3.5.0, <5",
"distro>=1.7.0, <2",
"sniffio",
Expand Down Expand Up @@ -69,7 +69,7 @@ format = { chain = [
# run formatting again to fix any inconsistencies when imports are stripped
"format:ruff",
]}
"format:docs" = "python scripts/utils/ruffen-docs.py README.md api.md"
"format:docs" = "bash -c 'python scripts/utils/ruffen-docs.py README.md $(find . -type f -name api.md)'"
"format:ruff" = "ruff format"

"lint" = { chain = [
Expand Down Expand Up @@ -168,7 +168,7 @@ show_error_codes = true
#
# We also exclude our `tests` as mypy doesn't always infer
# types correctly and Pyright will still catch any type errors.
exclude = ['src/brapi/_files.py', '_dev/.*.py', 'tests/.*']
exclude = ["src/brapi/_files.py", "_dev/.*.py", "tests/.*"]

strict_equality = true
implicit_reexport = true
Expand Down
20 changes: 10 additions & 10 deletions requirements-dev.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
-e file:.
aiohappyeyeballs==2.6.1
# via aiohttp
aiohttp==3.13.2
aiohttp==3.13.3
# via brapi
# via httpx-aiohttp
aiosignal==1.4.0
# via aiohttp
annotated-types==0.7.0
# via pydantic
anyio==4.12.0
anyio==4.12.1
# via brapi
# via httpx
argcomplete==3.6.3
Expand All @@ -31,7 +31,7 @@ attrs==25.4.0
# via nox
backports-asyncio-runner==1.2.0
# via pytest-asyncio
certifi==2025.11.12
certifi==2026.1.4
# via httpcore
# via httpx
colorlog==6.10.1
Expand Down Expand Up @@ -61,15 +61,15 @@ httpx==0.28.1
# via brapi
# via httpx-aiohttp
# via respx
httpx-aiohttp==0.1.9
httpx-aiohttp==0.1.12
# via brapi
humanize==4.13.0
# via nox
idna==3.11
# via anyio
# via httpx
# via yarl
importlib-metadata==8.7.0
importlib-metadata==8.7.1
iniconfig==2.1.0
# via pytest
markdown-it-py==3.0.0
Expand All @@ -82,14 +82,14 @@ multidict==6.7.0
mypy==1.17.0
mypy-extensions==1.1.0
# via mypy
nodeenv==1.9.1
nodeenv==1.10.0
# via pyright
nox==2025.11.12
packaging==25.0
# via dependency-groups
# via nox
# via pytest
pathspec==0.12.1
pathspec==1.0.3
# via mypy
platformdirs==4.4.0
# via virtualenv
Expand All @@ -115,13 +115,13 @@ python-dateutil==2.9.0.post0
# via time-machine
respx==0.22.0
rich==14.2.0
ruff==0.14.7
ruff==0.14.13
six==1.17.0
# via python-dateutil
sniffio==1.3.1
# via brapi
time-machine==2.19.0
tomli==2.3.0
tomli==2.4.0
# via dependency-groups
# via mypy
# via nox
Expand All @@ -141,7 +141,7 @@ typing-extensions==4.15.0
# via virtualenv
typing-inspection==0.4.2
# via pydantic
virtualenv==20.35.4
virtualenv==20.36.1
# via nox
yarl==1.22.0
# via aiohttp
Expand Down
Loading