https://github.com/refract-org/refract-py
Python SDK for Refract — the open claim-history layer for public knowledge
https://github.com/refract-org/refract-py
Last synced: 27 days ago
JSON representation
Python SDK for Refract — the open claim-history layer for public knowledge
- Host: GitHub
- URL: https://github.com/refract-org/refract-py
- Owner: refract-org
- Created: 2026-05-16T03:30:26.000Z (about 1 month ago)
- Default Branch: main
- Last Pushed: 2026-05-18T05:27:09.000Z (about 1 month ago)
- Last Synced: 2026-05-18T05:54:51.501Z (about 1 month ago)
- Language: Python
- Size: 9.77 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Agents: AGENTS.md
Awesome Lists containing this project
README
# refract-py
Python SDK for [Refract](https://github.com/refract-org/refract) — the open claim-history layer for public knowledge.
```bash
pip install refract-py
```
Requires the [Refract CLI](https://github.com/refract-org/refract):
```bash
npm install -g @refract-org/cli
```
## Usage
```python
from refract import Refract
r = Refract()
# Analyze a page, get typed dataclasses
events = r.analyze("Bitcoin", depth="brief")
for event in events:
print(event.eventType, event.timestamp)
# Export as pandas DataFrame
df = r.analyze("Bitcoin", depth="forensic", as_frame=True)
print(df.groupby("event_type").size())
# Export flattened CSV-compatible rows
df = r.export("Bitcoin", format="ndjson", flatten=True, as_frame=True)
```
## Integrations
| Tool | How |
|---|---|
| **pandas** | `as_frame=True` returns DataFrames with flattened provenance fields |
| **Jupyter** | Analyze pages, plot citation churn, export findings — all from a notebook |
| **LangChain** | `refract_langchain.py` loads events as `Document` objects with stability metadata for provenance-aware RAG |
| **DuckDB** | Export as NDJSON, query with SQL: `SELECT * FROM 'events.jsonl'` |
See the [Python SDK tutorial](https://refract-org.github.io/refract-docs/tutorials/python-sdk/) and [integrations docs](https://refract-org.github.io/refract-docs/integrations/) for full workflows.
## License
AGPL-3.0.