Metadata-Version: 2.1
Name: flyewin
Version: 0.1.0
Summary: Official client for the flye.win APIs. No dependencies.
License: MIT
Project-URL: Homepage, https://flye.win
Project-URL: Documentation, https://flye.win/docs
Keywords: flye,flye.win,api,sdk
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Typing :: Typed
Requires-Python: >=3.8
Description-Content-Type: text/markdown

# flyewin

Official Python client for the [flye.win](https://flye.win) APIs. No dependencies, Python 3.8+.

```sh
pip install flyewin
```

```python
from flyewin import Flye

flye = Flye()  # reads FLYE_API_KEY, or Flye("flye_sk_...")

print(flye.utils.uuid(count=2))
```

## Test keys

Keys that start with `flye_test_` answer with the documented examples, need no plan and
use no quota (30 requests/minute, 1,000/day). Use them while building and in CI, then
switch to a `flye_sk_` key. Create both at https://flye.win/dashboard/keys.

## Errors

Every failure raises `FlyeError` with a stable `code`:

```python
from flyewin import Flye, FlyeError

try:
    flye.utils.hash(text="hi")
except FlyeError as err:
    if err.code == "rate_limited":
        ...  # err.status == 429
```

Network errors and 5xx on GET requests are retried twice with backoff, and so is a `429`
with a short `Retry-After`. Change it with `Flye(max_retries=0)`.

Rate limit and quota headers of the last call are in `flye.last_response.headers`
(`x-ratelimit-remaining`, `x-quota-remaining`).

## Options

`Flye(api_key=None, *, base_url="https://flye.win/v1", timeout=30.0, max_retries=2)`

Every method also takes `timeout=` for that call.

## Methods

### Stickers — `flye.stickers`

Search stickers and animated GIFs, with ready-to-use links. Docs: https://flye.win/apis/stickers

| Method | HTTP | |
| ------ | ---- | - |
| `stickers.search()` | `GET /stickers/search` | Search stickers |
| `stickers.list_packs(q="gato")` | `GET /stickers/packs` | List packs |
| `stickers.get_pack("...")` | `GET /stickers/packs/{id}` | Stickers in a pack |

### CDN — `flye.cdn`

Image hosting with public links, organized in projects and folders. Docs: https://flye.win/apis/cdn

| Method | HTTP | |
| ------ | ---- | - |
| `cdn.upload(image=open("photo.jpg", "rb"), project="...")` | `POST /cdn/upload` | Upload an image |
| `cdn.list_projects()` | `GET /cdn/projects` | List projects |
| `cdn.create_project(name="...")` | `POST /cdn/projects` | Create a project |
| `cdn.get_project("...")` | `GET /cdn/projects/{project}` | List images |
| `cdn.get_image("...")` | `GET /cdn/images/{id}` | Image details |
| `cdn.delete_image("...")` | `DELETE /cdn/images/{id}` | Delete an image |
| `cdn.delete_project("...")` | `DELETE /cdn/projects/{project}` | Delete a project |
| `cdn.get_usage()` | `GET /cdn/usage` | Storage and limits |

### Utils — `flye.utils`

UUIDs, hashes, base64 and IP inspection in one call. Docs: https://flye.win/apis/utils

| Method | HTTP | |
| ------ | ---- | - |
| `utils.uuid()` | `GET /utils/uuid` | Generate UUIDs |
| `utils.hash(text="flye")` | `GET /utils/hash` | Compute a hash |
| `utils.base64(text="...")` | `POST /utils/base64` | Encode / decode base64 |
| `utils.ip()` | `GET /utils/ip` | Source IP |

Uploads take bytes, an open binary file, a path, or `(filename, bytes)`.

Full reference and the OpenAPI spec: https://flye.win/docs · https://flye.win/openapi.json
