Skip to content

Simpler API access #518

Open
Open
@ocervell

Description

@ocervell

Currently I have to import all the recipe APIs like:

from supertokens_python import asyncio as api
from supertokens_python.recipe.userroles import asyncio as roles_api
from supertokens_python.recipe.multitenancy import asyncio as multitenancy_api
from supertokens_python.recipe.usermetadata import asyncio as usermetadata_api
from supertokens_python.recipe.thirdparty import asyncio as thirdparty_api
from supertokens_python.recipe.emailpassword import asyncio as emailpassword_api

api.get_users_oldest_first(tenant_id)
apiuserroles_api.create_new_role_or_add_permissions(...)
usermetadata_api.get_user_metadata(...)
thirdparty_api.get_user_by_id(...)

This makes it a bit redundant to have all these imports everywhere, and I end up with files with +20 imports.
IMHO it would be nice to have some glue factory so we can do something like:

from supertokens_python import api

api.get_users_oldest_first(tenant_id)
api.userroles.create_new_role_or_add_permissions(...)
api.usermetadata.get_user_metadata(...)
api.thirdparty.get_user_by_id(...)

Even better (but probably harder to implement in the current state, it is nice to get a CRUD-like interface verbs like:

from supertokens_python import api

api.users.list(tenant_id, oldest_first=True)
api.users.roles.create(...)
api.users.metadata.get(...)
api.users.thirdparty.get(...)

I think any of those would improve the SDK quite a bit and make it way more usable, especially if some auto-complete is added to make it easy when typing api. what to write next ;)

Thoughts ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions