Microsoft Kiota HTTP
microsoft-kiota-http provides the core abstractions and implementations for making HTTP requests in Kiota-generated Python SDKs. It offers request adapters that integrate with popular HTTP clients like `requests` and `httpx`, handling the underlying network communication and request serialization/deserialization. The library is part of the broader Microsoft Kiota ecosystem, receiving frequent updates to synchronize with other Kiota packages.
Warnings
- breaking Starting with version 1.10.0, support for Python 3.9 has been dropped. Ensure your environment uses Python 3.10 or higher.
- gotcha A `RequestAdapter` always requires an `AuthenticationProvider` during initialization, even if it's an `AnonymousAuthenticationProvider` for public/unauthenticated endpoints.
- gotcha This package provides *factories* and *adapters* for HTTP communication. It does not provide the generated API client itself. You need to use the Kiota CLI to generate your client library, which will then depend on `microsoft-kiota-http`.
- gotcha There are distinct adapters for different underlying HTTP libraries (e.g., `RequestsRequestAdapter` for `requests`, `HttpxRequestAdapter` for `httpx`). Choose the one that best fits your project's existing dependencies or performance needs.
Install
-
pip install microsoft-kiota-http -
pip install microsoft-kiota-http microsoft-kiota-authentication-anonymous
Imports
- RequestsRequestAdapter
from microsoft.kiota.http.requests_request_adapter import RequestsRequestAdapter
- HttpxRequestAdapter
from microsoft.kiota.http.httpx_request_adapter import HttpxRequestAdapter
Quickstart
import os
from microsoft.kiota.authentication.anonymous.anonymous_authentication_provider import AnonymousAuthenticationProvider
from microsoft.kiota.http.requests_request_adapter import RequestsRequestAdapter
# 1. Initialize an AuthenticationProvider.
# For real applications, you'd use a provider like AzureIdentityAuthenticationProvider.
auth_provider = AnonymousAuthenticationProvider()
# 2. Create a RequestAdapter using a Kiota HTTP client implementation.
# RequestsRequestAdapter uses the 'requests' library by default.
# Alternatively, use HttpxRequestAdapter for 'httpx'.
request_adapter = RequestsRequestAdapter(auth_provider)
# The 'request_adapter' can now be passed to a Kiota-generated API client.
# Example: my_client = MyGeneratedApiClient(request_adapter)
print("Kiota HTTP Request Adapter initialized successfully.")
print(f"Using adapter type: {type(request_adapter).__name__}")
# This quickstart does not perform an actual API call as it requires a generated client.