Skip to main content

QAnswer: Api Documentation

Project description

QAnswer Python SDK

PyPI version Python Versions License: MIT

Official Python SDK for the QAnswer API, automatically generated from the OpenAPI specification.

This SDK allows Python applications to interact with QAnswer's services programmatically without needing to craft raw HTTP requests.


🚀 Features

  • Full coverage of QAnswer API endpoints
  • Type-safe models via Pydantic
  • Easy configuration of authentication and base URL
  • Auto-generated and versioned with each API release

📦 Installation

You can install from PyPI:

pip install qanswer-sdk

Or add it to your requirements.txt

qanswer-sdk==3.1184.0

🔑 Authentication

Most endpoints require authentication. You can configure authentication in several ways:

API Key Authentication

from qanswer_sdk import Configuration, ApiClient
from qanswer_sdk.api.chatbot_api import ChatbotApi

# Configure API key authorization
config = Configuration(
    host="https://api.qanswer.eu",
    api_key={"QAnswer-Api-Key": "your-api-key-here"}
)

# Initialize client
with ApiClient(config) as client:
    api = ChatbotApi(client)
    # Use the API...

Bearer Token Authentication

from qanswer_sdk import Configuration, ApiClient
from qanswer_sdk.api.chatbot_api import ChatbotApi

# Configure Bearer token authorization
config = Configuration(
    host="https://api.qanswer.eu",
    access_token="your-jwt-token-here"
)

# Initialize client
with ApiClient(config) as client:
    api = ChatbotApi(client)
    # Use the API...

Basic Authentication

from qanswer_sdk import Configuration, ApiClient
from qanswer_sdk.api.chatbot_api import ChatbotApi

# Configure Basic authorization
config = Configuration(
    host="https://api.qanswer.eu",
    username="your-username",
    password="your-password"
)

# Initialize client
with ApiClient(config) as client:
    api = ChatbotApi(client)
    # Use the API...

📖 Usage Examples

Chatbot API

from qanswer_sdk import Configuration, ApiClient
from qanswer_sdk.api.chatbot_api import ChatbotApi
from qanswer_sdk.models.chatbot_chat_payload import ChatbotChatPayload

config = Configuration(
    host="https://api.qanswer.eu",
    api_key={"QAnswer-Api-Key": "your-api-key"}
)

with ApiClient(config) as client:
    api = ChatbotApi(client)
    
    # Create chat payload
    payload = ChatbotChatPayload(
        message="What is artificial intelligence?",
        # Add other required fields based on your model
    )
    
    # Send chat message
    response = api.free_text_chatbot_chat(payload)
    print(response.answer)  # Access response data

Chat Completion API

from qanswer_sdk.api.chat_completion_api import ChatCompletionApi

with ApiClient(config) as client:
    api = ChatCompletionApi(client)
    # Use chat completion endpoints...

Handle Different Response Types

# Get just the data
response_data = api.free_text_chatbot_chat(payload)

# Get full HTTP response info
full_response = api.free_text_chatbot_chat_with_http_info(payload)
print(full_response.status_code)
print(full_response.headers)
print(full_response.data)

# Get raw HTTP response for streaming
raw_response = api.free_text_chatbot_chat_without_preload_content(payload)

⚙️ Configuration Options

from qanswer_sdk import Configuration

config = Configuration(
    host="https://api.qanswer.eu",  # API base URL
    api_key={"QAnswer-Api-Key": "your-key"},  # API key auth
    access_token="jwt-token",  # Bearer token auth
    username="user",  # Basic auth username
    password="pass",  # Basic auth password
    verify_ssl=True,  # SSL verification
    ssl_ca_cert="/path/to/ca.pem",  # Custom CA certificate
    connection_pool_maxsize=10,  # Connection pool size
    retries=3,  # Number of retries
    debug=False,  # Enable debug logging
    proxy="http://proxy:8080"  # Proxy URL
)

🛠 Error Handling

from qanswer_sdk.exceptions import (
    ApiException, 
    BadRequestException,
    UnauthorizedException,
    NotFoundException
)

try:
    response = api.free_text_chatbot_chat(payload)
except UnauthorizedException:
    print("Invalid authentication credentials")
except BadRequestException as e:
    print(f"Bad request: {e}")
except ApiException as e:
    print(f"API error: {e.status} - {e.reason}")

📝 Models and Type Safety

All request and response objects are Pydantic models with full type safety:

from qanswer_sdk.models.chatbot_chat_payload import ChatbotChatPayload
from qanswer_sdk.models.chatbot_response import ChatbotResponse

# Create typed request payload
payload = ChatbotChatPayload(
    message="Hello",
    # IDE will provide autocomplete for available fields
)

# Response is fully typed
response: ChatbotResponse = api.free_text_chatbot_chat(payload)
# Access typed response fields with autocomplete
print(response.answer)

📌 Versioning

This SDK follows the version of the QAnswer API. The current version is: 3.1326.0 (branch: main)


🤝 Support

For issues related to:

  • SDK usage: Open an issue in this repository
  • API functionality: Contact QAnswer support
  • Authentication: Check your API key and permissions

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.


Made with ❤️ by The QA Company

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

qanswer_sdk-3.1326.0.tar.gz (225.4 kB view details)

Uploaded Source

Built Distribution

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

qanswer_sdk-3.1326.0-py3-none-any.whl (688.1 kB view details)

Uploaded Python 3

File details

Details for the file qanswer_sdk-3.1326.0.tar.gz.

File metadata

  • Download URL: qanswer_sdk-3.1326.0.tar.gz
  • Upload date:
  • Size: 225.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.3 Linux/6.8.0-86-generic

File hashes

Hashes for qanswer_sdk-3.1326.0.tar.gz
Algorithm Hash digest
SHA256 1887b42592a791e45c8a3bf88e30bdeb97f55e4407ba447f619ab40aaf5bd6f2
MD5 fb06254b73aa1388df70d2f6e7633270
BLAKE2b-256 11fc3d4b52239c69d5f621e1715cbf345c9c85524b2b246a0f9309e17dd49aea

See more details on using hashes here.

File details

Details for the file qanswer_sdk-3.1326.0-py3-none-any.whl.

File metadata

  • Download URL: qanswer_sdk-3.1326.0-py3-none-any.whl
  • Upload date:
  • Size: 688.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.3 Linux/6.8.0-86-generic

File hashes

Hashes for qanswer_sdk-3.1326.0-py3-none-any.whl
Algorithm Hash digest
SHA256 39b597bc9a3fc56c5e28b5fce29cdb733d784b07762f6929034b6ee95606222c
MD5 c65a4a769556e6f8a3c6009b3d1712d7
BLAKE2b-256 19f5a3dcb4de8ad4bc6fcb6576a2a3c5dc93f1a01a3d47a33514585a57c977b6

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