A simple script to download source code from Lovable.dev projects to your local machine. It handles the API requests, decodes binary files, and reconstructs the directory structure automatically.
Using uv:
uv syncUsing pip:
pip install aiohttp pydantic-settings python-dotenvThe script requires a BEARER_TOKEN. You can provide this in two ways:
- Terminal:
export BEARER_TOKEN="Bearer your_token_here" - .env file: Create a
.envfile in the root directory and addBEARER_TOKEN="Bearer your_token_here"
How to find your token:
- Open any project on Lovable.
- Open Browser DevTools (F12) -> Network tab.
- Refresh the page and click on a request to
api.lovable.dev. - Copy the value of the
authorizationrequest header.
# Using uv
uv run main.py <lovable-project-url>
# Using python directly
python main.py <lovable-project-url>Options:
--force: Overwrite the project folder if it already exists locally.- Projects are saved in the
./projects/directory, named by their unique ID.
If you are using uv and want to enable local caching of API responses, the dev dependency group includes aiohttp-client-cache. To use it, set AIOHTTP_CACHE_DIR in your environment or .env file.