NewTqnia Python SDK
The official Python SDK for the NewTqnia technology news API. 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 attribution.
Installation
pip install newtqnia
Python 3.10 or newer is supported.
Quick start
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:
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
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:
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.
Configuration
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
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, SECURITY.md, and CHANGELOG.md.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file newtqnia-1.0.0.tar.gz.
File metadata
- Download URL: newtqnia-1.0.0.tar.gz
- Upload date:
- Size: 10.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fcad63814e18395bdcf87de378fe323b842967146a42792304990d0ad181a09a
|
|
| MD5 |
02f0dcf70ce08939e31118537a27358d
|
|
| BLAKE2b-256 |
1408864d6559fb1a8ae2cd738489008f0c823c6496bffe9614cbde678f95d198
|
Provenance
The following attestation bundles were made for newtqnia-1.0.0.tar.gz:
Publisher:
publish.yml on newtqnia/newtqnia-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
newtqnia-1.0.0.tar.gz -
Subject digest:
fcad63814e18395bdcf87de378fe323b842967146a42792304990d0ad181a09a - Sigstore transparency entry: 2546753639
- Sigstore integration time:
-
Permalink:
newtqnia/newtqnia-python@d7da1cb557c9b7c22341285dceecfc361fdb712f -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/newtqnia
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d7da1cb557c9b7c22341285dceecfc361fdb712f -
Trigger Event:
push
-
Statement type:
File details
Details for the file newtqnia-1.0.0-py3-none-any.whl.
File metadata
- Download URL: newtqnia-1.0.0-py3-none-any.whl
- Upload date:
- Size: 9.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
10c4b12567ab6478a9995a4d7c86b5bb7b0f47b21d47b58bb070d1af8603cad4
|
|
| MD5 |
a383304e7ce55d97255b71b6c6b48a00
|
|
| BLAKE2b-256 |
6f28eed27afbac1e4867202d35eb090adf490b2f1ca1fd5d9ece9e0b03bfeac8
|
Provenance
The following attestation bundles were made for newtqnia-1.0.0-py3-none-any.whl:
Publisher:
publish.yml on newtqnia/newtqnia-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
newtqnia-1.0.0-py3-none-any.whl -
Subject digest:
10c4b12567ab6478a9995a4d7c86b5bb7b0f47b21d47b58bb070d1af8603cad4 - Sigstore transparency entry: 2546753698
- Sigstore integration time:
-
Permalink:
newtqnia/newtqnia-python@d7da1cb557c9b7c22341285dceecfc361fdb712f -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/newtqnia
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d7da1cb557c9b7c22341285dceecfc361fdb712f -
Trigger Event:
push
-
Statement type: