Metadata-Version: 2.5
Name: newtqnia
Version: 1.0.1
Summary: Official Python SDK for the NewTqnia technology news API
Project-URL: Homepage, https://newtqnia.com/en/developers
Project-URL: Documentation, https://newtqnia.com/en/developers
Project-URL: Repository, https://github.com/newtqnia/newtqnia-python
Project-URL: Issues, https://github.com/newtqnia/newtqnia-python/issues
Project-URL: Changelog, https://github.com/newtqnia/newtqnia-python/blob/main/CHANGELOG.md
Author-email: NewTqnia <hello@newtqnia.com>
License: MIT License
        
        Copyright (c) 2026 NewTqnia
        
        Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
License-File: LICENSE
Keywords: api,arabic,news,newtqnia,sdk,technology
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: httpx<1,>=0.25
Provides-Extra: dev
Requires-Dist: build>=1.2; extra == 'dev'
Requires-Dist: mypy>=1.11; extra == 'dev'
Requires-Dist: pytest-cov>=5; extra == 'dev'
Requires-Dist: pytest>=8; extra == 'dev'
Requires-Dist: ruff>=0.9; extra == 'dev'
Requires-Dist: twine>=5; extra == 'dev'
Description-Content-Type: text/markdown

# NewTqnia Python SDK

[![CI](https://github.com/newtqnia/newtqnia-python/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/newtqnia/newtqnia-python/actions/workflows/ci.yml?query=branch%3Amain)
[![PyPI](https://img.shields.io/pypi/v/newtqnia.svg?logo=pypi&logoColor=white&color=3775A9)](https://pypi.org/project/newtqnia/)
[![Python](https://img.shields.io/pypi/pyversions/newtqnia.svg?logo=python&logoColor=white&color=3776AB)](https://pypi.org/project/newtqnia/)
[![Typing](https://img.shields.io/badge/typing-typed-3776AB.svg)](https://github.com/newtqnia/newtqnia-python/blob/main/src/newtqnia/py.typed)
[![License](https://img.shields.io/badge/license-MIT-3776AB.svg)](https://github.com/newtqnia/newtqnia-python/blob/main/LICENSE)

The official Python SDK for the [NewTqnia technology news API](https://newtqnia.com/en/developers). It includes synchronous and asynchronous clients, typed immutable models, timeouts, retries, structured errors, and safe HTML/JSON-LD rendering.

> Applications displaying API content must preserve returned article URLs and visibly render the supplied **[Powered by NewTqnia](https://newtqnia.com/en)** attribution.

## Installation

```bash
pip install newtqnia
```

Python 3.10 or newer is supported.

## Quick start

```python
from newtqnia import NewTqnia

with NewTqnia() as client:
    digest = client.news.latest(locale="en", limit=5)
    for article in digest.articles:
        print(article.title, article.url)
```

Arabic and category filtering:

```python
digest = client.news.today(locale="ar", category="ai", limit=5)
```

The OpenAPI contract currently exposes only `today` and `latest`. The SDK deliberately does not invent search, article lookup, category listing, or pagination operations.

## Async

```python
import asyncio
from newtqnia import AsyncNewTqnia


async def main():
    async with AsyncNewTqnia() as client:
        digest = await client.news.latest(locale="en", limit=5)
        print(digest.articles)


asyncio.run(main())
```

## Render attributed news

`render_html()` produces escaped, accessible, RTL-aware markup. It preserves canonical article URLs and includes visible attribution by default:

```python
html = digest.render_html()
json_ld = digest.json_ld()
```

Pass `attribution=False` only if the page renders `digest.attribution.html()` visibly elsewhere. See [the rendering guide](https://github.com/newtqnia/newtqnia-python/blob/main/docs/rendering.md).

## Configuration

```python
client = NewTqnia(
    api_key=os.getenv("NEWTQNIA_API_KEY"),
    application="editorial-dashboard",
    website="https://example.com",
    timeout=15,
    retries=3,
    headers={"X-Trace-Source": "dashboard"},
)
```

No key is required. Optional keys are sent as `X-API-Key`. Temporary network failures and HTTP 429, 500, 502, 503, and 504 responses are retried with exponential backoff; `Retry-After` is honored.

## Errors

Catch `NewTqniaError` broadly or specialized `ValidationError`, `AuthenticationError`, `AuthorizationError`, `NotFoundError`, `ConflictError`, `RateLimitError`, `ServerError`, `TimeoutError`, and `NetworkError`. API errors expose `status`, `request_id`, `code`, `retry_after`, and `body`.

## Development and release

```bash
python -m pytest --cov=newtqnia
ruff check .
mypy src
python -m build
twine check dist/*
```

PyPI releases use GitHub Actions Trusted Publishing when a `v*` tag is pushed. Configure the `pypi` environment for `newtqnia/newtqnia-python` in PyPI before the first release.

See [CONTRIBUTING.md](https://github.com/newtqnia/newtqnia-python/blob/main/CONTRIBUTING.md), [SECURITY.md](https://github.com/newtqnia/newtqnia-python/blob/main/SECURITY.md), and [CHANGELOG.md](https://github.com/newtqnia/newtqnia-python/blob/main/CHANGELOG.md).
