Skip to main content

NewTqnia Python SDK

CI PyPI Python Typing License

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

newtqnia-1.0.1.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

newtqnia-1.0.1-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file newtqnia-1.0.1.tar.gz.

File metadata

  • Download URL: newtqnia-1.0.1.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for newtqnia-1.0.1.tar.gz
Algorithm Hash digest
SHA256 c014853d118fd14916d7371cbfce32723640d833e01af25b18db7d332fb37687
MD5 6658e745918fcf30e039b296b50206e1
BLAKE2b-256 dc59c74f352292d0feb46758653c5ca8a36f36e34f5a13bb52b43375f0c80d47

See more details on using hashes here.

Provenance

The following attestation bundles were made for newtqnia-1.0.1.tar.gz:

Publisher: publish.yml on newtqnia/newtqnia-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file newtqnia-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: newtqnia-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for newtqnia-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 34218c5989cac2ed7d32b2a0d9580f2f803f3d47b200ad5af6c0a91d098ade9a
MD5 2ba54cb449fe788459d9ae8130178d68
BLAKE2b-256 4f2ffc5e2a49f1cf204699677ad3bca768d6db1c32ca77407fa1befda5072add

See more details on using hashes here.

Provenance

The following attestation bundles were made for newtqnia-1.0.1-py3-none-any.whl:

Publisher: publish.yml on newtqnia/newtqnia-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 files

1.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page