Raw endpoint interface for advanced KSeF integrations.
Klasy
AsyncRawAuthenticatedClient
Import: from ksef2.raw import AsyncRawAuthenticatedClient
class AsyncRawAuthenticatedClientAsyncRawAuthenticatedClient(
*,
transport: AsyncMiddleware,
authed_transport: AsyncMiddleware,
environment: Environment,
)Raw authenticated endpoint facade for advanced async integrations.
Metody
AsyncRawAuthenticatedClient.auth (właściwość)
auth: AsyncAuthEndpointsReturn raw authenticated authentication-session endpoints.
Zwraca
AsyncAuthEndpoints— Raw authenticated authentication-session endpoints.
AsyncRawAuthenticatedClient.certificates (właściwość)
certificates: AsyncCertificatesEndpointsReturn raw certificate lifecycle endpoints.
Zwraca
AsyncCertificatesEndpoints— Raw certificate lifecycle endpoints.
AsyncRawAuthenticatedClient.encryption (właściwość)
encryption: AsyncEncryptionEndpointsReturn raw public encryption-certificate endpoints.
Zwraca
AsyncEncryptionEndpoints— Raw public encryption-certificate endpoints.
AsyncRawAuthenticatedClient.invoices (właściwość)
invoices: AsyncInvoicesEndpointsReturn raw invoice and invoice-session endpoints.
Zwraca
AsyncInvoicesEndpoints— Raw invoice and invoice-session endpoints.
AsyncRawAuthenticatedClient.limits (właściwość)
limits: AsyncLimitEndpointsReturn raw limit endpoints.
Zwraca
AsyncLimitEndpoints— Raw limit endpoints.
AsyncRawAuthenticatedClient.collective_identifiers (właściwość)
collective_identifiers: AsyncCollectiveIdentifiersEndpointsReturn raw collective invoice identifier endpoints.
Zwraca
AsyncCollectiveIdentifiersEndpoints— Raw collective invoice identifier endpoints.
AsyncRawAuthenticatedClient.peppol (właściwość)
peppol: AsyncPeppolEndpointsReturn raw Peppol provider endpoints.
Zwraca
AsyncPeppolEndpoints— Raw Peppol provider endpoints.
AsyncRawAuthenticatedClient.permissions (właściwość)
permissions: AsyncRawPermissionsEndpointsReturn raw permission endpoint groups.
Zwraca
AsyncRawPermissionsEndpoints— Raw permission endpoint groups.
AsyncRawAuthenticatedClient.session (właściwość)
session: AsyncSessionEndpointsReturn raw online and batch session endpoints.
Zwraca
AsyncSessionEndpoints— Raw online and batch session endpoints.
AsyncRawAuthenticatedClient.testdata (właściwość)
testdata: AsyncTestDataEndpointsReturn raw TEST-only data seeding endpoints.
Zwraca
AsyncTestDataEndpoints— Raw TEST-only data seeding endpoints.
AsyncRawAuthenticatedClient.tokens (właściwość)
tokens: AsyncTokenEndpointsReturn raw token lifecycle endpoints.
Zwraca
AsyncTokenEndpoints— Raw token lifecycle endpoints.
AsyncRawClient
Import: from ksef2.raw import AsyncRawClient
class AsyncRawClientAsyncRawClient(transport: AsyncMiddleware, environment: Environment)Raw unauthenticated endpoint facade for advanced async integrations.
Metody
AsyncRawClient.auth (właściwość)
auth: AsyncAuthEndpointsReturn raw authentication endpoints.
Zwraca
AsyncAuthEndpoints— Raw authentication endpoints.
AsyncRawClient.encryption (właściwość)
encryption: AsyncEncryptionEndpointsReturn raw public encryption-certificate endpoints.
Zwraca
AsyncEncryptionEndpoints— Raw public encryption-certificate endpoints.
AsyncRawClient.peppol (właściwość)
peppol: AsyncPeppolEndpointsReturn raw Peppol provider endpoints.
Zwraca
AsyncPeppolEndpoints— Raw Peppol provider endpoints.
AsyncRawClient.testdata (właściwość)
testdata: AsyncTestDataEndpointsReturn raw TEST-only data seeding endpoints.
Zwraca
AsyncTestDataEndpoints— Raw TEST-only data seeding endpoints.
AsyncRawPermissionsEndpoints
Import: from ksef2.raw import AsyncRawPermissionsEndpoints
class AsyncRawPermissionsEndpointsAsyncRawPermissionsEndpoints(transport: AsyncMiddleware)Raw permission endpoint groups bound to one async transport.
Metody
AsyncRawPermissionsEndpoints.grant (właściwość)
grant: AsyncPermissionsGrantEndpointsReturn permission grant endpoints.
Zwraca
AsyncPermissionsGrantEndpoints— Permission grant endpoints.
AsyncRawPermissionsEndpoints.revoke (właściwość)
revoke: AsyncRevokePermissionsEndpointsReturn permission revocation endpoints.
Zwraca
AsyncRevokePermissionsEndpoints— Permission revocation endpoints.
AsyncRawPermissionsEndpoints.query (właściwość)
query: AsyncQueryPermissionsEndpointsReturn permission query endpoints.
Zwraca
AsyncQueryPermissionsEndpoints— Permission query endpoints.
AsyncRawPermissionsEndpoints.status (właściwość)
status: AsyncGetPermissionsEndpointsReturn permission operation status and role endpoints.
Zwraca
AsyncGetPermissionsEndpoints— Permission operation status and role endpoints.
RawAuthenticatedClient
Import: from ksef2.raw import RawAuthenticatedClient
class RawAuthenticatedClientRawAuthenticatedClient(
*,
transport: Middleware,
authed_transport: Middleware,
environment: Environment,
)Raw authenticated endpoint facade for advanced integrations.
Metody
RawAuthenticatedClient.auth (właściwość)
auth: AuthEndpointsReturn raw authenticated authentication-session endpoints.
Zwraca
AuthEndpoints— Raw authenticated authentication-session endpoints.
RawAuthenticatedClient.certificates (właściwość)
certificates: CertificatesEndpointsReturn raw certificate lifecycle endpoints.
Zwraca
CertificatesEndpoints— Raw certificate lifecycle endpoints.
RawAuthenticatedClient.encryption (właściwość)
encryption: EncryptionEndpointsReturn raw public encryption-certificate endpoints.
Zwraca
EncryptionEndpoints— Raw public encryption-certificate endpoints.
RawAuthenticatedClient.invoices (właściwość)
invoices: InvoicesEndpointsReturn raw invoice and invoice-session endpoints.
Zwraca
InvoicesEndpoints— Raw invoice and invoice-session endpoints.
RawAuthenticatedClient.limits (właściwość)
limits: LimitEndpointsReturn raw limit endpoints.
Zwraca
LimitEndpoints— Raw limit endpoints.
RawAuthenticatedClient.collective_identifiers (właściwość)
collective_identifiers: CollectiveIdentifiersEndpointsReturn raw collective invoice identifier endpoints.
Zwraca
CollectiveIdentifiersEndpoints— Raw collective invoice identifier endpoints.
RawAuthenticatedClient.peppol (właściwość)
peppol: PeppolEndpointsReturn raw Peppol provider endpoints.
Zwraca
PeppolEndpoints— Raw Peppol provider endpoints.
RawAuthenticatedClient.permissions (właściwość)
permissions: RawPermissionsEndpointsReturn raw permission endpoint groups.
Zwraca
RawPermissionsEndpoints— Raw permission endpoint groups.
RawAuthenticatedClient.session (właściwość)
session: SessionEndpointsReturn raw online and batch session endpoints.
Zwraca
SessionEndpoints— Raw online and batch session endpoints.
RawAuthenticatedClient.testdata (właściwość)
testdata: TestDataEndpointsReturn raw TEST-only data seeding endpoints.
Zwraca
TestDataEndpoints— Raw TEST-only data seeding endpoints.
RawAuthenticatedClient.tokens (właściwość)
tokens: TokenEndpointsReturn raw token lifecycle endpoints.
Zwraca
TokenEndpoints— Raw token lifecycle endpoints.
RawClient
Import: from ksef2.raw import RawClient
class RawClientRawClient(transport: Middleware, environment: Environment)Raw unauthenticated endpoint facade for advanced integrations.
Metody
RawClient.auth (właściwość)
auth: AuthEndpointsReturn raw authentication endpoints.
Zwraca
AuthEndpoints— Raw authentication endpoints.
RawClient.encryption (właściwość)
encryption: EncryptionEndpointsReturn raw public encryption-certificate endpoints.
Zwraca
EncryptionEndpoints— Raw public encryption-certificate endpoints.
RawClient.peppol (właściwość)
peppol: PeppolEndpointsReturn raw Peppol provider endpoints.
Zwraca
PeppolEndpoints— Raw Peppol provider endpoints.
RawClient.testdata (właściwość)
testdata: TestDataEndpointsReturn raw TEST-only data seeding endpoints.
Zwraca
TestDataEndpoints— Raw TEST-only data seeding endpoints.
RawPermissionsEndpoints
Import: from ksef2.raw import RawPermissionsEndpoints
class RawPermissionsEndpointsRawPermissionsEndpoints(transport: Middleware)Raw permission endpoint groups bound to one transport.
Metody
RawPermissionsEndpoints.grant (właściwość)
grant: PermissionsGrantEndpointsReturn permission grant endpoints.
Zwraca
PermissionsGrantEndpoints— Permission grant endpoints.
RawPermissionsEndpoints.revoke (właściwość)
revoke: RevokePermissionsEndpointsReturn permission revocation endpoints.
Zwraca
RevokePermissionsEndpoints— Permission revocation endpoints.
RawPermissionsEndpoints.query (właściwość)
query: QueryPermissionsEndpointsReturn permission query endpoints.
Zwraca
QueryPermissionsEndpoints— Permission query endpoints.
RawPermissionsEndpoints.status (właściwość)
status: GetPermissionsEndpointsReturn permission operation status and role endpoints.
Zwraca
GetPermissionsEndpoints— Permission operation status and role endpoints.
Funkcje
encrypt_invoice
Import: from ksef2.raw import encrypt_invoice
def encrypt_invoice(xml_bytes: bytes, key: bytes, iv: bytes) -> bytesAES-256-CBC encrypt xml_bytes with PKCS#7 padding.
Parametry
xml_bytes(bytes) — Plain invoice XML bytes.key(bytes) — 32-byte AES-256 key.iv(bytes) — 16-byte initialization vector.
Zwraca
bytes— The raw ciphertext bytes. The caller is responsible for Base64 encoding.
Zgłasza
KSeFEncryptionError— If encryption fails, for example because of an invalid key length.
encrypt_symmetric_key
Import: from ksef2.raw import encrypt_symmetric_key
def encrypt_symmetric_key(key: bytes, cert_b64: str) -> bytesRSA-OAEP encrypt an AES key with a KSeF public-key certificate.
Parametry
key(bytes) — AES key to encrypt.cert_b64(str) — Base64-encoded DER certificate containing the RSA public key.
Zwraca
bytes— The raw ciphertext bytes. The caller is responsible for Base64 encoding.
Zgłasza
KSeFEncryptionError— If the certificate cannot be loaded or encryption fails.
encrypt_token
Import: from ksef2.raw import encrypt_token
def encrypt_token(token: str, timestamp: str, cert_b64: str) -> strRSA-OAEP encrypt token|timestamp and return Base64.
Parametry
token(str) — KSeF token.timestamp(str) — Challenge timestamp in Unix milliseconds, as a string.cert_b64(str) — Base64-encoded DER certificate containing the RSA public key.
Zwraca
str— The Base64-encoded ciphertext.
Zgłasza
KSeFEncryptionError— If the certificate cannot be loaded or encryption fails.
generate_session_key
Import: from ksef2.raw import generate_session_key
def generate_session_key() -> tuple[bytes, bytes]Generate a random AES-256 key (32 bytes) and IV (16 bytes).
Zwraca
tuple[bytes, bytes]— A tuple of the AES key and the initialization vector.
prepare_batch_package
Import: from ksef2.raw import prepare_batch_package
def prepare_batch_package(
*,
invoices: Iterable[BatchInvoice],
aes_key: bytes,
iv: bytes,
encrypted_key: bytes,
public_key_id: str | None = None,
form_code: FormSchema = FormSchema.FA3,
offline_mode: bool = False,
max_part_size: int = MAX_BATCH_PART_SIZE,
) -> PreparedBatchBuild, split, and encrypt a batch package from invoice payloads.
Parametry
invoices(Iterable[BatchInvoice]) — Invoices to include; each becomes one ZIP entry.aes_key(bytes) — AES-256 key used to encrypt the parts.iv(bytes) — AES initialization vector.encrypted_key(bytes) —aes_keyencrypted with the KSeF public key.public_key_id(str | None) — Identifier of the KSeF public key used forencrypted_key;Nonefor the default.form_code(FormSchema) — Invoice schema of the batch.offline_mode(bool) — Whether the invoices were issued in offline mode.max_part_size(int) — Maximum size in bytes of one encrypted part.
Zwraca
PreparedBatch— The prepared batch: package metadata, encrypted parts and encryption material.
Zgłasza
KSeFEncryptionError— If part encryption fails.KSeFValidationError— If the invoice list or part size is invalid.
sha256_b64
Import: from ksef2.raw import sha256_b64
def sha256_b64(data: bytes) -> strReturn the SHA-256 digest of data as a Base64-encoded string.
Parametry
data(bytes) — Bytes to hash.
Zwraca
str— The Base64-encoded digest.
Podmoduły
auth
Import: import ksef2.raw.auth
batch
Import: import ksef2.raw.batch
Supplementary models for batch session operations.
These models shadow the spec models with str instead of Base64Str fields to allow easier construction in mappers.
certificates
Import: import ksef2.raw.certificates
Supplementary models for certificate operations.
These models shadow generated schema models that use Base64Str fields so the SDK can pass already-base64-encoded request data without double decoding.
encryption
Import: import ksef2.raw.encryption
invoices
Import: import ksef2.raw.invoices
peppol
Import: import ksef2.raw.peppol
permissions
Import: import ksef2.raw.permissions
session
Import: import ksef2.raw.session
spec
Import: import ksef2.raw.spec
supp
Import: import ksef2.raw.supp
testdata
Import: import ksef2.raw.testdata
