Registry / http-networking / microsoft-kiota-abstractions

microsoft-kiota-abstractions

JSON →
library1.12.0pypypi✓ verified 25d ago

The `microsoft-kiota-abstractions` library provides core interfaces and base classes for Python SDKs generated by Microsoft Kiota. These abstractions define how HTTP requests are built, how data is serialized and deserialized, and the fundamental structure for models used in API clients. It is currently at version 1.10.1 and follows a frequent release cadence, often synchronized with other Kiota Python packages.

pip install microsoft-kiota-abstractions
INSTALL
IMPORT
SIG · MICROSOFT-KIOTA-AB
M
microsoft-kiota-abstractions
http-networkingpythonv1.12.0
Install
2.1s avg
Import
182ms
Disk
21MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.12.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.192s · 22.4MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.1s · import 0.172s · 23MB
21MB installed
● package 21MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

RequestInformation
from kiota_abstractions.request_information import RequestInformation
RequestAdapter
from kiota_abstractions.request_adapter import RequestAdapter
Parsable
from kiota_abstractions.serialization import Parsable
ParseNode
from kiota_abstractions.serialization import ParseNode
SerializationWriter
from kiota_abstractions.serialization import SerializationWriter
HttpMethod
from kiota_abstractions.http.method import HttpMethod
BaseRequestBuilder
from kiota_abstractions.base_request_builder import BaseRequestBuilder

This quickstart demonstrates how to implement the `Parsable` interface, a core abstraction for data models in Kiota. While typically Kiota generates these implementations, understanding `get_field_deserializers` and `serialize` is fundamental when working with or extending Kiota-generated SDKs. This example defines a simple model with string and datetime fields.

import datetime from typing import Dict, Optional from kiota_abstractions.serialization import Parsable, ParseNode, SerializationWriter class MySimpleModel(Parsable): """Represents a simple data model implementing Parsable.""" def __init__(self) -> None: self._id: Optional[str] = None self._name: Optional[str] = None self._created_at: Optional[datetime.datetime] = None @property def id(self) -> Optional[str]: return self._id @id.setter def id(self, value: Optional[str]) -> None: self._id = value @property def name(self) -> Optional[str]: return self._name @name.setter def name(self, value: Optional[str]) -> None: self._name = value @property def created_at(self) -> Optional[datetime.datetime]: return self._created_at @created_at.setter def created_at(self, value: Optional[datetime.datetime]) -> None: self._created_at = value def get_field_deserializers(self) -> Dict[str, callable]: """The deserialization information for the current model""" return { "id": lambda n: setattr(self, 'id', n.get_str_value()), "name": lambda n: setattr(self, 'name', n.get_str_value()), "createdAt": lambda n: setattr(self, 'created_at', n.get_datetime_value()) } def serialize(self, writer: SerializationWriter) -> None: """Serializes information the current object""" if not writer: raise TypeError("writer cannot be None") writer.write_str_value("id", self.id) writer.write_str_value("name", self.name) writer.write_datetime_value("createdAt", self.created_at) # Example usage (typically handled by Kiota-generated code) model = MySimpleModel() model.id = "123" model.name = "Test Model" model.created_at = datetime.datetime.now(datetime.timezone.utc) print(f"Model ID: {model.id}, Name: {model.name}, Created At: {model.created_at}")
Debug
Known issues
breakingStarting with version 1.10.0, support for Python 3.9 has been officially dropped. The library now requires Python 3.10 or higher.
fix
Upgrade your Python environment to version 3.10 or newer to use `microsoft-kiota-abstractions` v1.10.0 and later.
affects: >=1.10.0
gotcha`microsoft-kiota-abstractions` alone does not provide a functional API client. It defines interfaces and base classes. To make actual API calls, you need additional Kiota packages like `microsoft-kiota-http` (for HTTP client implementations), `microsoft-kiota-serialization-json` (for JSON serialization), and an SDK generated by the Kiota tool.
fix
Ensure you install the full set of Kiota client libraries and use a Kiota-generated SDK for end-to-end API interaction. `microsoft-kiota-bundle` can simplify installation of common components.
affects: All
gotchaKiota is primarily a code generation tool. The `abstractions` library is consumed by the *generated* SDKs. Direct, manual implementation of interfaces like `Parsable` is usually only necessary when extending or customizing specific Kiota functionalities (e.g., custom serialization) rather than for general API client usage.
fix
Focus on understanding the generated code and using the Kiota tool to create your SDKs. Consult Kiota documentation for best practices on customizing generated clients.
affects: All
gotchaWhen implementing `Parsable`, pay close attention to the exact field names (case sensitivity) and types expected by the deserializers. Mismatches in `get_field_deserializers` can lead to runtime errors or incorrect data parsing.
fix
Always verify that the keys in the dictionary returned by `get_field_deserializers` exactly match the API's property names, and the lambda functions correctly map to your model's attributes with appropriate type conversions (e.g., `get_str_value()`, `get_datetime_value()`).
affects: All
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'microsoft.kiota.abstractions'
The 'microsoft-kiota-abstractions' Python package is not installed in the current environment.
fix
Install the package using pip: `pip install microsoft-kiota-abstractions`
Microsoft.Kiota.Abstractions: Content type text/html does not have a factory registered to be parsed.
The Kiota client received a response with a 'text/html' content type, but no deserialization factory is registered to handle it. This often occurs when an API returns an HTML error page instead of an expected data format like JSON.
fix
Ensure the API consistently returns a parsable content type (e.g., `application/json`) or register a custom deserialization factory for 'text/html' if it's an expected response.
Unhandled exception. Microsoft.Kiota.Abstractions.ApiException: The server returned an unexpected status code and the error registered for this code failed to deserialize: [status code]
The Kiota client encountered an HTTP response with an unexpected status code (e.g., 404, 500) that was either not defined in the OpenAPI specification's error mappings or whose response body could not be deserialized into the expected error model.
fix
Implement robust error handling by catching `ApiException` and inspecting `ResponseStatusCode`. Ensure your OpenAPI schema accurately defines error responses with schemas so Kiota can generate appropriate error models for deserialization.
Python codegen models of custom API errors do not map detail onto APIError's message attribute
When Kiota generates Python clients, custom error models containing a 'detail' field might not automatically map this content to the generic `APIError.message` attribute, unlike in other generated languages.
fix
Manually access the 'detail' attribute from the specific generated error model, or adjust your Kiota generation configuration to provide a custom mapping to populate the `APIError.message` from the 'detail' field in the Python client.
Upgrade
Version history
1.12.0latest on PyPI · released Aug 27, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
39 hits · last 30 days
node
34
OpenAI (training)
1
Resources
microsoft-kiota-abstractions — pip install microsoft-kiota-abstractions · libregistry