supertokens / supertokens-python

Python SDK for SuperTokens
https://supertokens.com
Other
121 stars 34 forks source link

Simpler API access #518

Open ocervell opened 1 month ago

ocervell commented 1 month ago

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 ?

rishabhpoddar commented 1 month ago

Hi @ocervell , these are all fair and excellent suggestions. I do agree that doing the several imports is a pain (it's annoying for us to type it in the docs even - haha). However, fixing this would take quite some time, and we are already very occupied with our current roadmap.

So we shall wait until this has more thumbs up, or if someone else does an OS contribution.

Thanks.