Metadata-Version: 2.4
Name: analog-sdk
Version: 0.5.4
Summary: Python SDK for Analog — instantly distill webpages into structured data.
Project-URL: Homepage, https://getanalog.io
Author-email: Marcus Campbell <marcus@getanalog.io>
License: MIT
License-File: LICENSE
Requires-Python: >=3.10
Requires-Dist: click>=8.1
Requires-Dist: httpx>=0.27
Requires-Dist: keyring>=24.0
Requires-Dist: lxml>=5.2
Requires-Dist: markdownify>=0.11
Requires-Dist: protego>=0.4
Requires-Dist: pydantic>=2.6
Requires-Dist: pyyaml>=6.0
Provides-Extra: fetcher
Requires-Dist: analog-fetcher<0.4.0,>=0.3.0; extra == 'fetcher'
Description-Content-Type: text/markdown

# analog-sdk

Python SDK for [Analog](https://getanalog.io) — instantly distill
webpages into structured data.

## Installation

```bash
pip install analog-sdk
```

For JS-heavy pages (single-page apps, infinite scroll, content that
hydrates client-side), also install the companion fetcher:

```bash
pip install "analog-sdk[fetcher]"
```

This gives you the `AnalogFetcher`, which is used as the default
automatically — cheap HTTP fetch on first contact, escalates to a
Playwright-rendered fetch only when the page actually needs it, and
caches the decision per-domain so subsequent visits skip the probe.

## Authenticate

New to Analog? `analog signup` opens the account-creation page
(invite code required during the private alpha). Then:

```bash
analog login
```

This opens your browser to sign in. The credential is minted straight
into a local store and never shown on screen, so the model driving your
session never sees it. Subsequent SDK and CLI usage picks it up
automatically; sign out any time with `analog logout`.

Signing in requires a browser on the machine running `analog login`.

Try it straight from the shell:

```bash
analog get https://news.ycombinator.com
```

Run `analog --help` to see all commands (`signup`, `login`,
`logout`, `whoami`, `status`, `get`).

If you don't want a globally-installed `analog` binary, use
`pipx install analog-sdk` or `uv tool install analog-sdk` instead
of plain `pip install`.

## Usage

```python
from analog import analog

result = analog("https://example.com")
```

Same one-liner whether or not the JS-aware fetcher is installed. When
it is, JS-heavy pages just work.

See https://getanalog.io for full documentation.

## Saved results

Every `analog(url)` call saves its result locally, so you can re-open or
re-export it later — without re-fetching or re-rendering the page:

```python
from analog import analog, history, latest

result = analog("https://example.com")
print(result.handle)        # "20260618-k7m2p9"

# Later — rehydrated from disk, no network:
again = latest()            # the most recent result
print(again.markdown)       # full-page markdown, stored alongside the data
for meta in history():      # everything saved, newest first
    print(meta.handle, meta.url)
```

Re-open a specific result with `analog.open(handle)`. Artifacts live
under your per-user cache directory (`~/.cache/analog/results`;
`~/Library/Caches/analog/results` on macOS; `ANALOG_CACHE_DIR` overrides)
and store only safe derivatives — the structured result and full-page
markdown, never raw HTML. Pass `analog(url, save=False)` to skip saving;
the store is size-bounded and drops least-recently-opened results.

From the shell, `analog get <url>` saves and prints the handle, and
`analog history` / `analog open <handle>` / `analog export <handle> -f csv`
/ `analog rm <handle>` manage saved results (`latest` works anywhere a
handle does).

## License

MIT — see [LICENSE](./LICENSE).
