{"id":28141,"library":"replit","title":"Replit Python Library","description":"A library for interacting with Replit features such as the Replit Database (key-value store), Identity (auth tokens), Audio (deprecated), and other platform utilities. Current version 4.1.2 requires Python >=3.10, <4.0. Release cadence is irregular.","status":"active","version":"4.1.2","language":"python","source_language":"en","source_url":"https://github.com/replit/replit-py","tags":["replit","database","identity","auth","flask","starlette"],"install":[{"cmd":"pip install replit","lang":"bash","label":"Install from PyPI"},{"cmd":"pip install replit==4.1.2","lang":"bash","label":"Pin to latest version"}],"dependencies":[{"reason":"Required for the `replit.web` module (Flask integration). Optional if not using web features.","package":"flask","optional":true},{"reason":"Used for WebSocket support in the `replit.web` module.","package":"flask-socketio","optional":true},{"reason":"Used internally for HTTP calls (Replit DB, Identity, etc.).","package":"requests","optional":false},{"reason":"Used for ASGI support in `replit.web` and the Audio module (deprecated).","package":"starlette","optional":true}],"imports":[{"note":"Database was moved to `replit` directly; submodule import may sometimes work but is not guaranteed.","wrong":"from replit.database import Database","symbol":"Database","correct":"from replit import Database"},{"note":"Audio v3 API removed in v4.0.0. Use the new pattern or avoid entirely. Submodule import will fail.","wrong":"from replit.audio import Audio","symbol":"Audio","correct":"from replit import Audio"},{"note":"Identity is available at `replit.Identity` since v3.4.0.","wrong":"","symbol":"Identity","correct":"from replit import Identity"}],"quickstart":{"code":"import os\nfrom replit import Database\n\n# Get database URL from environment variable (set automatically in Replit)\ndb_url = os.environ.get('REPLIT_DB_URL', '')\nif not db_url:\n    print('REPLIT_DB_URL not set. Running outside Replit?')\nelse:\n    db = Database(db_url)\n    db['key'] = 'Hello from replit-py'\n    print(db['key'])","lang":"python","description":"Basic usage of Replit Database (key-value store). Requires the REPLIT_DB_URL environment variable, which is automatically set in Replit environments."},"warnings":[{"fix":"Remove any Audio usage. If you need audio playback, use a third-party library like `playsound`.","message":"In v4.0.0, the Audio module was removed entirely. Code using `from replit import Audio` or `from replit.audio import Audio` will break. There is no replacement provided.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"If you used those versions and stored keys with leading slashes, you may need to re-add the slashes manually using a newer version.","message":"In v3.6.1, Database keys with leading slashes were forbidden. The v3.6.3 release reverted this change, but if you upgraded to 3.6.1 or 3.6.2 and saved keys with slashes, they may have been stripped. Check your keys.","severity":"breaking","affected_versions":"3.6.1, 3.6.2"},{"fix":"Avoid using `replit.web`. Use Flask or Starlette directly.","message":"The `web` module (Flask/SocketIO integration) is considered deprecated in favor of standalone Flask or Starlette apps. It may be removed in a future major version.","severity":"deprecated","affected_versions":">=4.0.0"},{"fix":"Set the environment variable `REPLIT_DB_URL` to a database endpoint URL (e.g., a local test server or the real Replit DB URL).","message":"When using `Database` outside of Replit environment, you must manually set `REPLIT_DB_URL`. The library does not provide a fallback.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Replace `from replit.audio import Audio` with something else or update your code to not use Audio.","cause":"Audio module was removed in v4.0.0.","error":"ModuleNotFoundError: No module named 'replit.audio'"},{"fix":"Upgrade to latest version: `pip install --upgrade replit` and use `from replit import Database`.","cause":"You might be using an older version (<3.0) where Database was in a submodule.","error":"AttributeError: module 'replit' has no attribute 'Database'"},{"fix":"Install Flask: `pip install flask`, or avoid using `replit.web`.","cause":"The `replit.web` module depends on Flask, which is an optional dependency.","error":"replit_python_flask_import_error: Flask not installed"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}