Metadata-Version: 2.3
Name: dopememe
Version: 0.1.0a1
Summary: dope.meme for Python, and the dopememe CLI: find meme templates, fill them, get images and permanent URLs.
Keywords: memes,images,api,sdk,cli
Author: Patrick Higgins
Author-email: Patrick Higgins <patrick@nicena.me>
Classifier: Programming Language :: Python :: 3
Classifier: Typing :: Typed
Requires-Dist: httpx2>=2.16.0
Requires-Python: >=3.11
Project-URL: Homepage, https://dope.meme
Project-URL: Documentation, https://docs.dope.meme
Description-Content-Type: text/markdown

# dopememe

dope.meme for Python, and the `dopememe` command line: find meme templates, fill them,
and get images and permanent URLs.

```sh
pip install dopememe     # the library
uvx dopememe --help      # or just the CLI
```

## The library

```python
from dopememe import Client

client = Client()  # an API key is optional: DOPEMEME_API_KEY, or api_key=

# Find a template by what you want to say, and read what each slot is for.
page = client.list_templates(q="preferring the new thing", tag=["slots:2"])
drake = client.retrieve_template(page.data[0].ref)

# Fill it. The URL is permanent, and nothing is stored.
render = client.render_meme(
    {
        "template": "drake-hotline",
        "slots": {"reject": "Writing SDKs by hand", "prefer": "Generating them"},
    }
)
print(render.url, render.alt)

# The image itself, as bytes.
image = client.render_image({"template": "drake-hotline", "slots": {"reject": "a", "prefer": "b"}})
image.save("drake.webp")

# An embeddable URL, built without a request.
client.embed_url("drake-hotline", ["Writing SDKs by hand", "Generating them"])

# Save one for a short URL that keeps working.
meme = client.create_meme(recipe={"template": "drake-hotline", "slots": {"prefer": "this"}})
```

`AsyncClient` does the same with `await`. Lists page with `list_templates_all(…)`.
Errors are `dopememe.APIError`, with a stable `code` and every problem's `path` and
`hint`; `RateLimitError` says how long to wait. A `429` is retried after `Retry-After`,
and so are brief server errors when the request is safe to repeat.

Python 3.11 or newer. One dependency: `httpx2`.

## The command line

```sh
dopememe search "preferring the new thing"
dopememe show drake-hotline
dopememe render drake-hotline "Writing SDKs by hand" "Generating them"            # its URL
dopememe render drake-hotline "Writing SDKs by hand" "Generating them" -o drake.png
dopememe render drake-hotline --slot prefer="Generating them" --preview           # inline, in iTerm2, WezTerm or kitty
dopememe url drake-hotline "Writing SDKs by hand" "Generating them"               # /g/, no request
dopememe save drake-hotline "Writing SDKs by hand" "Generating them"
dopememe login                                                                     # save an API key
```

Texts fill the template's text slots in reading order; `--slot name=text` names them.
`--recipe file.json` (or `-` for stdin) takes a whole recipe. `--json` prints what the
API returned, for scripts and agents.
