Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simpler API access #518

Open
ocervell opened this issue Jul 26, 2024 · 1 comment
Open

Simpler API access #518

ocervell opened this issue Jul 26, 2024 · 1 comment

Comments

@ocervell
Copy link

ocervell commented Jul 26, 2024

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
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants