Skip to content

Consider adding snake_case to camelCase conversion for Literal parameter values #700

@vdusek

Description

@vdusek

Summary

Currently, Literal type parameters that map directly to API query parameters use camelCase values, matching the API convention. For example:

sort_by: Literal['createdAt', 'stats.lastRunStartedAt'] | None = 'createdAt'
ownership: Literal['ownedByMe', 'sharedWithMe'] | None = None

This works, but it's not idiomatic Python — users would expect snake_case values in the Python interface.

Proposal

Introduce a conversion mechanism that allows snake_case values in the Python-facing API and converts them to camelCase before sending to the Apify API. For example:

# Python interface
ownership: Literal['owned_by_me', 'shared_with_me'] | None = None

# Converted to `ownedByMe` / `sharedWithMe` in the HTTP request

Context

This was identified during the review of #696 — see this comment.

Should be considered before v3.

Metadata

Metadata

Assignees

No one assigned

    Labels

    t-toolingIssues with this label are in the ownership of the tooling team.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions