Skip to content
Merged
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Docs: Python API reference page (`python-api`) covering `openqbw.open`,
`Reader`, and its `tables()` / `indexes()` / `line_items()` /
`transactions()` methods, registered in the sidebar. Fixes #1. (@Nabejo)

## [0.1.4] - 2026-07-06

### Changed
Expand Down
77 changes: 77 additions & 0 deletions docs/docs/python-api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Python API reference

The `openqbw` wheel is a PyO3 extension built from the same Rust core
that backs the CLI. It exposes a small, read-only surface: open a file,
then pull the catalog, indexes, line items, and transaction headers as
lists of dicts.

```python
import openqbw

r = openqbw.open("/path/to/file.qbw")
print(r.page_count, "pages,", r.file_size, "bytes")
```

## `openqbw.open(path) -> Reader`

Opens a `.qbw` file, decodes the page store, and learns the additive
progression model needed to attribute pages to tables. Raises
`OSError` if the file cannot be opened.

## `Reader`

| Member | Type | Description |
|---|---|---|
| `path` | `str` | The filesystem path the reader was opened from. |
| `page_count` | `int` | Number of pages in the underlying page-store. |
| `file_size` | `int` | File size in bytes. |
| `tables()` | `list[dict]` | SYSTABLE catalog rows. |
| `indexes()` | `list[dict]` | SYSINDEX entries. |
| `line_items()` | `list[dict]` | Invoice line items, attributed to their source table. |
| `transactions()` | `list[dict]` | Transaction headers. |

### `tables()`

Each dict has `table_id`, `name`, `col_count`, `data_root_page`,
`last_page`, `page_number`.

```python
for t in r.tables()[:5]:
print(t["table_id"], t["name"])
```

### `indexes()`

Each dict has `name`, `table_id`, `root_page`, `page_number`.

```python
for idx in r.indexes()[:5]:
print(idx["name"], idx["table_id"])
```

### `line_items()`

Each dict has `invoice_id`, `item_qb_id`, `amount_cents`,
`amount_cents_signed`, `txn_date_days_since_unix`, `source_table`,
`page_number`, `page_offset`.

```python
for li in r.line_items()[:3]:
print(li["invoice_id"], li["amount_cents"], li["source_table"])
```

### `transactions()`

Each dict has `qb_id`, `source_table`, `txn_type`, `page_number`,
`page_offset`.

```python
for h in r.transactions()[:3]:
print(h["qb_id"], h["txn_type"])
```

## Next

- [Python quickstart](./quickstart-python)
- [CLI reference](./cli)
- [Format specification](./specification)
1 change: 1 addition & 0 deletions docs/sidebars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const sidebars: SidebarsConfig = {
'use-cases',
'migration-guide',
'cli',
'python-api',
],
},
{
Expand Down
Loading