{"id":21096841,"url":"https://github.com/stytchauth/stytch-python","last_synced_at":"2026-05-04T22:02:10.304Z","repository":{"id":39019894,"uuid":"300031625","full_name":"stytchauth/stytch-python","owner":"stytchauth","description":"Official Stytch Backend SDK for Python","archived":false,"fork":false,"pushed_at":"2025-04-02T19:08:10.000Z","size":1069,"stargazers_count":56,"open_issues_count":4,"forks_count":12,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-04-02T19:17:09.365Z","etag":null,"topics":["authentication","python","sdk","stytch"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stytchauth.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-09-30T19:11:13.000Z","updated_at":"2025-04-02T19:07:40.000Z","dependencies_parsed_at":"2023-02-18T15:15:57.655Z","dependency_job_id":"28d79996-8ef0-48fb-a44f-5a01a5cd08f7","html_url":"https://github.com/stytchauth/stytch-python","commit_stats":null,"previous_names":[],"tags_count":152,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stytchauth%2Fstytch-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stytchauth%2Fstytch-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stytchauth%2Fstytch-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stytchauth%2Fstytch-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stytchauth","download_url":"https://codeload.github.com/stytchauth/stytch-python/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248625497,"owners_count":21135513,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["authentication","python","sdk","stytch"],"created_at":"2024-11-19T22:44:24.238Z","updated_at":"2026-05-04T22:02:10.297Z","avatar_url":"https://github.com/stytchauth.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Stytch Python Library\n\nThe Stytch Python library makes it easy to use the Stytch user infrastructure API in Python applications.\n\nIt pairs well with the Stytch [Web SDK](https://www.npmjs.com/package/@stytch/vanilla-js) or your own custom authentication flow.\n\n## Requirements\n\nThe Stytch Python library supports Python 3.10+\n\n## Installation\n\n```\npip install stytch\n```\n\n## Usage\n\nYou can find your API credentials in the [Stytch Dashboard](https://stytch.com/dashboard/api-keys).\n\nThis client library supports all Stytch's live products:\n\n## B2C\n\n- [x] [Email Magic Links](https://stytch.com/docs/api/send-by-email)\n- [x] [Embeddable Magic Links](https://stytch.com/docs/guides/magic-links/embeddable-magic-links/api)\n- [x] [OAuth logins](https://stytch.com/docs/guides/oauth/idp-overview)\n- [x] [SMS passcodes](https://stytch.com/docs/api/send-otp-by-sms)\n- [x] [WhatsApp passcodes](https://stytch.com/docs/api/whatsapp-send)\n- [x] [Email passcodes](https://stytch.com/docs/api/send-otp-by-email)\n- [x] [Session Management](https://stytch.com/docs/guides/sessions/using-sessions)\n- [x] [WebAuthn](https://stytch.com/docs/guides/webauthn/api)\n- [x] [Time-based one-time passcodes (TOTPs)](https://stytch.com/docs/guides/totp/api)\n- [x] [Crypto wallets](https://stytch.com/docs/guides/web3/api)\n- [x] [Passwords](https://stytch.com/docs/guides/passwords/api)\n\n## B2B\n\n- [x] [Organizations](https://stytch.com/docs/b2b/api/organization-object)\n- [x] [Members](https://stytch.com/docs/b2b/api/member-object)\n- [x] [Email Magic Links](https://stytch.com/docs/b2b/api/send-login-signup-email)\n- [x] [OAuth logins](https://stytch.com/docs/b2b/api/oauth-google-start)\n- [x] [Session Management](https://stytch.com/docs/b2b/api/session-object)\n- [x] [Single-Sign On](https://stytch.com/docs/b2b/api/sso-authenticate-start)\n- [x] [Discovery](https://stytch.com/docs/b2b/api/discovered-organization-object)\n- [x] [Passwords](https://stytch.com/docs/b2b/api/passwords-authenticate)\n\n### Example B2C usage\n\nCreate an API client:\n\n```python\nimport stytch\n\nclient = stytch.Client(\n    project_id=\"project-live-c60c0abe-c25a-4472-a9ed-320c6667d317\",\n    secret=\"secret-live-80JASucyk7z_G8Z-7dVwZVGXL5NT_qGAQ2I=\",\n    # Optionally specify a custom base URL for all API calls\n    # custom_base_url=\"https://api.custom-domain.com/\",\n)\n```\n\nSend a magic link by email:\n\n```python\nlogin_or_create_resp = client.magic_links.email.login_or_create(\n    email=\"sandbox@stytch.com\",\n    login_magic_link_url=\"https://example.com/authenticate\",\n    signup_magic_link_url=\"https://example.com/authenticate\",\n)\n# Responses are fully-typed `pydantic` objects\nprint(login_or_create_resp)\n```\n\nAuthenticate the token from the magic link:\n\n```python\nauth_resp = client.magic_links.authenticate(\n    token=\"DOYoip3rvIMMW5lgItikFK-Ak1CfMsgjuiCyI7uuU94=\",\n)\nprint(auth_resp)\n```\n\n## Async support\n\nEvery endpoint supports an `async` version which you can use by appending `_async` to the method name. You can use the\nsame `Client` object for `sync` and `async` methods. The above example of sending and authenticating an magic link can\nbe rewritten as:\n\n```python\nlogin_or_create_resp = await client.magic_links.email.login_or_create_async(\n    email=\"sandbox@stytch.com\",\n    login_magic_link_url=\"https://example.com/authenticate\",\n    signup_magic_link_url=\"https://example.com/authenticate\",\n)\nprint(login_or_create_resp)\n\nauth_resp = await client.magic_links.authenticate(\n    token=\"DOYoip3rvIMMW5lgItikFK-Ak1CfMsgjuiCyI7uuU94=\",\n)\nprint(resp)\n```\n\n### Example B2B usage\n\nCreate an API client:\n\nPython:\n\n```python\nimport stytch\n\nclient = stytch.B2BClient(\n    project_id=\"project-live-c60c0abe-c25a-4472-a9ed-320c6667d317\",\n    secret=\"secret-live-80JASucyk7z_G8Z-7dVwZVGXL5NT_qGAQ2I=\",\n    # Optionally specify a custom base URL for all API calls\n    # custom_base_url=\"https://api.custom-domain.com/\",\n)\n```\n\nCreate an organization\n\n```python\nresponse = client.organizations.create(\n    organization_name=\"Acme Co\",\n    organization_slug=\"acme-co\",\n    email_allowed_domains=[\"acme.co\"]\n)\n```\n\nLog the first user into the organization\n\n```python\nresponse = client.magic_links.email.login_or_signup(\n    organization_id=\"ORGANIZATION_ID_FROM_RESPONSE\",\n    email_address=\"admin@acme.co\",\n    login_redirect_url=\"https://example.com/authenticate\",\n    signup_redirect_url=\"https://example.com/authenticate\"\n)\n```\n\n## Handling Errors\n\nStructured errors from the Stytch API will raise `StytchError` exceptions. You can view the details of the error through\nthe `.details` property of the `StytchError` exception.\n\n```python\nfrom stytch.core.response_base import StytchError\n\ntry:\n    auth_resp = await client.magic_links.authenticate_async(token=\"token\")\nexcept StytchError as error:\n    # Handle Stytch errors here\n    if error.details.error_type == \"invalid_token\":\n        print(\"Whoops! Try again?\")\nexcept Exception as error:\n    # Handle other errors here\n    pass\n```\n\nLearn more about errors in the [docs](https://stytch.com/docs/api/errors).\n\n## Documentation\n\nSee example requests and responses for all the endpoints in the [Stytch API Reference](https://stytch.com/docs/api).\n\nFollow one of the [integration guides](https://stytch.com/docs/home#guides) or start with one of our [example apps](https://stytch.com/docs/home#example-apps).\n\n## Support\n\nIf you've found a bug, [open an issue](https://github.com/stytchauth/stytch-python/issues/new)!\n\nIf you have questions or want help troubleshooting, join us in [Slack](https://stytch.com/docs/resources/support/overview) or email support@stytch.com.\n\nIf you've found a security vulnerability, please follow our [responsible disclosure instructions](https://stytch.com/docs/resources/security-and-trust/security#:~:text=Responsible%20disclosure%20program).\n\n## Development\n\nSee [DEVELOPMENT.md](DEVELOPMENT.md)\n\n## Code of Conduct\n\nEveryone interacting in the Stytch project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstytchauth%2Fstytch-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstytchauth%2Fstytch-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstytchauth%2Fstytch-python/lists"}