Registry / http-networking / pyodata

pyodata

JSON →
library1.11.2pypypiunverified

pyodata is an enterprise-ready Python OData client that provides a comfortable and Python-agnostic way to communicate with OData services. It abstracts away OData protocol implementation details, primarily supporting OData V2, with future plans for V4 support. The library is actively maintained, with frequent minor releases, and its current version is 1.11.2.

pip install -U pyodata
INSTALL
IMPORT
SIG · PYODATA
P
pyodata
http-networkingpythonv1.11.2
Install
2.1s avg
Import
145ms
Disk
29MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v1.11.2 · 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.10–3.910 runs
installs and imports cleanly · install 0.0s · import 0.149s · 30.5MB
glibc
py 3.10–3.910 runs
installs and imports cleanly · install 2.1s · import 0.141s · 31MB
29MB installed
● package 29MB
Code
Verified usage

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

Client
✓ import pyodata # ... client = pyodata.Client(...)
The primary entry point for interacting with an OData service.
GetEntitySetFilter
✓ from pyodata.v2.service import GetEntitySetFilter as esf
Used for advanced filtering of entity sets in a more Pythonic/ORM-like style.
HttpError
✓ from pyodata.exceptions import HttpError
Base exception for HTTP errors (status codes >= 400) returned by the OData service.

Initializes an OData client using `requests.Session` and queries the 'Products' entity set from the Northwind OData V2 sample service. This demonstrates basic client setup and data retrieval.

import requests import pyodata import os # Replace with your OData service URL SERVICE_URL = os.environ.get('PYODATA_SERVICE_URL', 'http://services.odata.org/V2/Northwind/Northwind.svc/') session = requests.Session() # For services requiring authentication # username = os.environ.get('PYODATA_USERNAME', '') # password = os.environ.get('PYODATA_PASSWORD', '') # if username and password: # session.auth = (username, password) # Create instance of OData client client = pyodata.Client(SERVICE_URL, session) # Example: Query all products products_request = client.entity_sets.Products.get_entities() products = products_request.execute() print(f"Found {len(products)} products:") for product in products[:3]: # Print first 3 products print(f"- {product.ProductName} (ID: {product.ProductID})")
Debug
Known issues
breakingPython 3.7 and 3.8 are no longer supported. The library now requires Python >= 3.9.
fix
Upgrade your Python environment to 3.9 or newer.
affects: >=1.11.0
gotchaWhen creating or updating entities (POST/PATCH requests), OData services often require CSRF tokens. You must correctly initialize your `requests.Session` to handle these, typically by fetching a token with a HEAD request first.
fix
Before making a POST/PATCH request, execute a HEAD request to the service URL to obtain the 'x-csrf-token' and 'set-cookie' headers, then include them in subsequent requests. Example: `session.head(SERVICE_URL, headers={'x-csrf-token': 'fetch'})`.
affects: All
gotchaThe metadata parser can encounter errors with non-fully valid metadata documents. This can lead to issues if the service is not under your control. By default, missing properties might be filled with type-specific default values.
fix
Configure the metadata parser to recover from problems using `pyodata.Client`'s `config` parameter. You can specify parser policies (e.g., `PolicyWarning`, `PolicyIgnore`) and set `retain_null=False` to prevent substitution by default values.
affects: All
deprecatedDirectly setting custom XML namespaces via the client initialization is deprecated.
fix
Use the `config` object (e.g., `pyodata.client.config`) to manage XML namespaces and other parser settings instead.
affects: <=1.x
gotchaOData services may require non-standard URL query parameters (e.g., 'sap-client') or specific path encoding. The default behavior might not always match specific service implementations.
fix
Use the `.custom(name, value)` method on entity requests to add custom query parameters. To disable URL path encoding, set `encode_path=False` during client initialization or on the request.
affects: All
Upgrade
Version history
1.11.2latest on PyPI · released Apr 26, 2025
Audit
Dependencies
requestsrequiredPyOData requires an external HTTP library with an API compatible with `requests.Session` for all HTTP communication.
Agent activity
16 hits · last 30 days
node
12
Amazon
1
Resources
pyodata — pip install pyodata · libregistry