Skip to main content

Authenticated API client for the NFON Service Portal 3

Project description

NFON Service Portal API Client

EN:
Starter client for authenticated access to the NFON Service Portal API.
DE:
Einfacher Einstieg in die authentifizierte Nutzung der NFON Service Portal API.

📄 Link to official docs:
https://www.nfon.com/en/service/documentation/manuals/web-applications/nfon-service-portal-api/nfon-service-portal-api-manual/

Installation

Clone this repository or install as part of your project.

Example Usage

from nfon_api_client import NfonApiBaseClient

napi = NfonApiBaseClient(
    uid="KXXXX",
    api_key="your_key",
    api_secret="your_secret",
    api_base_url="https://nfon.example.com"
)

# Use .ep(key, **kwargs) to resolve endpoints
endpoint = napi.ep('customers')
response = napi.get(endpoint)

# Use a customer-specific endpoint
customer_id = "K1234"
endpoint = napi.ep('customer_basic_data', customer_id=customer_id)
response = napi.get(endpoint)
print(response.json())

Or start building your own Subclass to fit your needs:

from nfon_api_client import NfonApiBaseClient

class NfonApiClient(NfonApiBaseClient):
    def __init__(self, user_id, key, secret, base_url):
        super().__init__(user_id, key, secret, base_url)

    @staticmethod
    def list_to_dict(data):
        return {item['name']: item['value'] for item in data}

    @staticmethod
    def dict_to_list(data, key='name', value='value'):
        return [{key: k, value: v} for k, v in data.items()]
  # etc...etc...

Error Handling

This library defines custom exceptions to help you handle different failure modes cleanly:

  • NFONApiError – Base class for all API-related errors
  • AuthHeaderError – Raised when the authentication header cannot be generated
  • RequestFailed – Raised when an HTTP request fails (e.g., network issue or server error)
  • EndpointFormatError – Raised when .ep() is called with missing or incorrect arguments

Example:

from nfon_api_client import NfonApiBaseClient
from nfon_api_client.exceptions import RequestFailed, AuthHeaderError

napi = NfonApiBaseClient("KXXXX", "your_key", "your_secret", "https://nfon.example.com")

try:
    response = napi.get(napi.ep('version'))
    print(response.json())
except RequestFailed as e:
    print("Request failed:", e)
except AuthHeaderError as e:
    print("Header generation failed:", e)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nfon_api_client-0.1.0.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

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

nfon_api_client-0.1.0-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

Details for the file nfon_api_client-0.1.0.tar.gz.

File metadata

  • Download URL: nfon_api_client-0.1.0.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for nfon_api_client-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d64ff592ea67566d0f001178818be447f0a68405e729c85d06cc7be38ad29e18
MD5 d1c613bae5563b0f1bf7b181ccfc0a08
BLAKE2b-256 ce0c29a389460ddcf62bfeca6863bed97d7cff7e229d6dfa6eea63295115eacc

See more details on using hashes here.

File details

Details for the file nfon_api_client-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for nfon_api_client-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e62c92e5bea063ed4f74e53e9878fe34cbf7d203b802c3444d9dfdd21adf6000
MD5 1a53b54ddd2e3bae715f788c9c5c6d0e
BLAKE2b-256 1d2b081d375e1b046727c2effbacc541e2c24ad407f52a4d1f5e537bdd185c4c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page