{"id":27300763,"url":"https://github.com/nevermendel/leetcode-export","last_synced_at":"2025-04-12T01:25:53.828Z","repository":{"id":62575501,"uuid":"443135473","full_name":"NeverMendel/leetcode-export","owner":"NeverMendel","description":"Python script and Docker image to export your LeetCode submissions","archived":false,"fork":false,"pushed_at":"2024-04-14T10:19:06.000Z","size":74,"stargazers_count":15,"open_issues_count":3,"forks_count":7,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-04-14T11:14:31.306Z","etag":null,"topics":["collaborate","docker","github","github-codespaces","leetcode","leetcode-solutions","python","python3"],"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/NeverMendel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-12-30T17:00:45.000Z","updated_at":"2024-06-01T13:54:10.096Z","dependencies_parsed_at":"2022-11-03T17:32:39.538Z","dependency_job_id":"db608f0a-fba5-495a-9f75-561e88593825","html_url":"https://github.com/NeverMendel/leetcode-export","commit_stats":{"total_commits":37,"total_committers":2,"mean_commits":18.5,"dds":"0.027027027027026973","last_synced_commit":"e1841cdd20e1fda3bfd043f8867b4911ca61e704"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NeverMendel%2Fleetcode-export","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NeverMendel%2Fleetcode-export/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NeverMendel%2Fleetcode-export/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NeverMendel%2Fleetcode-export/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NeverMendel","download_url":"https://codeload.github.com/NeverMendel/leetcode-export/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248502882,"owners_count":21114898,"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":["collaborate","docker","github","github-codespaces","leetcode","leetcode-solutions","python","python3"],"created_at":"2025-04-12T01:25:53.139Z","updated_at":"2025-04-12T01:25:53.810Z","avatar_url":"https://github.com/NeverMendel.png","language":"Python","readme":"# LeetCode Export\n\nPython script and Docker image to export your LeetCode submissions.\n\nIf you find LeetCode Export helpful, please consider giving it a star ⭐️. Your support helps me gauge its usage and motivates further development.\n\n## 📝 Table of Contents\n\n- [DISCLAIMER](#DISCLAIMER)\n- [About](#about)\n- [Getting started](#getting-started)\n- [Script arguments](#script-arguments)\n- [Special mentions](#special-mentions)\n- [License](#license)\n\n## ⚠️ DISCLAIMER \u003ca name=\"disclaimer\"\u003e\u003c/a\u003e\n\nThe problems hosted on leetcode.com are intellectual propriety of LeetCode LLC unless specified otherwise. **DO NOT\nUPLOAD THE DESCRIPTION OF LEETCODE PROBLEMS ON GITHUB OR ON ANY OTHER WEBSITE** or you might receive ad DMCA Takedown\nnotice.\n\nBefore using this script read the [LeetCode Terms of Service](https://leetcode.com/terms/).\n\n## ⚙️ About \u003ca name=\"about\"\u003e\u003c/a\u003e\n\nThis script uses LeetCode REST and GraphQL APIs to download all your LeetCode submitted solutions.\n\nBefore running the script, make sure that python3 is installed in your system.\n\nIf you prefer, you can use the Docker image to download LeetCode submissions. For more information read the\nsection [Docker Image](#docker-image).\n\n## 🏁 Getting started \u003ca name=\"getting-started\"\u003e\u003c/a\u003e\n\n### Download `leetcode-export`\n\nTo use `leetcode-export` download it from pypi.org, pull the docker image, or clone this repository.\n\n#### Download from pypi.org\n\nRun `pip install leetcode-export` to install leetcode-export, you might have to use `pip3` of your system. Then execute\nrun the script `leetcode-export`, optionally supply the script arguments. For more information read the\nsection [script arguments](#script-arguments).\n\n#### Docker Image\n\nDownload the docker image from DockerHub:\n\n```bash\ndocker pull nevermendel/leetcode-export\n```\n\nDownload all your LeetCode submission in the current folder:\n\n```bash\ndocker run -it -v $(pwd):/usr/app/out --rm nevermendel/leetcode-export\n```\n\n#### Clone the repository\n\nClone this repository:\n\n```bash\ngit clone https://github.com/NeverMendel/leetcode-export\n```\n\nInstall all the needed dependencies:\n\n```bash\npip install -r requirements.txt\n```\n\nInstall leetcode-export in your system or just execute it:\n\n- To install the script:\n    ```bash\n    pip install .\n    ```\n\n- To execute the script without installing it:\n    ```bash\n    python -m leetcode_export --folder submissions\n    ```\n\n### Login\n\n`leetcode-export` requires a valid LeetCode account to download its submissions. Login to your LeetCode account by\nproviding the cookies. To log in using cookies, get them from an existing session.\n\n**Steps required**:\n\n- Login in to LeetCode in the web browser\n- Open the browser's Dev Tool\n- Click on the Network tab\n- Copy the cookie header that can be found under Request Headers in any leetcode.com request.\n\nYou can insert the cookie string that you have just copied in the interactive menu (recommended) or you can pass it as a\nprogram argument when lunching the script, like in the following example:\n\n```bash\npython leetcode-export --cookies {COOKIES}\n```\n\nUsing the interactive menu is preferred because it will avoid storing cookies in the command history.\n\n## Script arguments\n\nThe script accepts the following arguments:\n\n```\nusage: leetcode-export [-h] [--cookies COOKIES] [--folder FOLDER]\n                       [--problem-folder-name PROBLEM_FOLDER_NAME]\n                       [--no-problem-statement]\n                       [--problem-statement-filename PROBLEM_STATEMENT_FILENAME]\n                       [--problem-statement-content PROBLEM_STATEMENT_CONTENT]\n                       [--submission-filename SUBMISSION_FILENAME]\n                       [--only-accepted] [--only-last-submission]\n                       [--language LANGUAGE_UNPROCESSED] [-v] [-vv] [-V]\n\nExport LeetCode submissions\n\noptions:\n  -h, --help            show this help message and exit\n  --cookies COOKIES     set LeetCode cookies\n  --folder FOLDER       set output folder\n  --problem-folder-name PROBLEM_FOLDER_NAME\n                        problem folder name format\n  --no-problem-statement\n                        do not save problem statement\n  --problem-statement-filename PROBLEM_STATEMENT_FILENAME\n                        problem statement filename format\n  --problem-statement-content PROBLEM_STATEMENT_CONTENT\n                        problem statement content format\n  --submission-filename SUBMISSION_FILENAME\n                        submission filename format\n  --only-accepted       save accepted submissions only\n  --only-last-submission\n                        only save the last submission for each programming language\n  --language LANGUAGE_UNPROCESSED\n                        save submissions for specified programming languages.\n                        syntax: --language=\u003clang1\u003e,\u003clang2\u003e,...\n                        languages: python, python3, c, cpp, csharp, java,\n                                   kotlin, mysql, mssql, oraclesql, javascript,\n                                   html, php, golang, scala, pythonml,\n                                   rust, ruby, bash, swift\n                        example: --language=python,cpp,java\n  -v, --verbose         enable verbose logging details\n  -vv, --extra-verbose  enable more verbose logging details\n  -V, --version         show program's version number and exit\n```\n\n### Problem template arguments\n\n#### Problem statement filename template\n\nTo change the format of the problem statement filename provide a template as a string when executing the\nscript.\n\n```bash\npython leetcode-export --problem-statement-filename PROBLEM_STATEMENT_FILENAME\n```\n\nThe template can contain parameters that will later be replaced based on the LeetCode problem information. The available\nparameters are the following:\n\n```python\nquestion_id: int\ndifficulty: str\nstats: str\ntitle: str\ntitle_slug: str\n```\n\nDefault problem statement filename template: `${question_id} - ${title_slug}.html`\n\n#### Problem statement content template\n\nTo change the format of the problem statement content provide a template as a string when executing the\nscript.\n\n```bash\npython leetcode-export --problem-statement-content PROBLEM_STATEMENT_CONTENT\n```\n\nThe template can contain parameters that will later be replaced based on the LeetCode problem information. The available\nparameters are the ones contained in [problem statement filename template](#problem-statement-filename-template) plus:\n\n```python\ncontent: str\n```\n\nDefault problem statement content template:\n`\u003ch1\u003e${question_id} - ${title}\u003c/h1\u003e\u003ch2\u003eDifficulty: ${difficulty} - \u003ca href=\"https://leetcode.com/problems/${title_slug}/\"\u003e${title_slug}\u003c/a\u003e\u003c/h2\u003e${content}`\n\n#### Submission filename template\n\nTo change the format of the submission filename, you can provide a template as a string when lunching the script.\n\n```bash\npython leetcode-export --submission-filename SUBMISSION_FILENAME\n```\n\nThe template can contain parameters that will later be replaced based on the submission information. The available\nparameters are the following:\n\n```python\nid: int\nlang: str\ntime: str\ntimestamp: int\nstatus_display: str\nruntime: str\nurl: str\nis_pending: str\ntitle: str\nmemory: str\ncode: str\ncompare_result: str\ntitle_slug: str\ndate_formatted: str\nextension: str\n```\n\nDefault submission filename\ntemplate: `${date_formatted} - ${status_display} - runtime ${runtime} - memory ${memory}.${extension}`\n\n## Special mentions\n\nThanks to [skygragon](https://github.com/skygragon) for\ndeveloping [leetcode-cli](https://github.com/skygragon/leetcode-cli), which I used as documentation for LeetCode APIs.\nThe license of leetcode-cli is available [here](https://github.com/skygragon/leetcode-cli/blob/master/LICENSE).\n\n## License\n\n[MIT License](LICENSE)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnevermendel%2Fleetcode-export","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnevermendel%2Fleetcode-export","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnevermendel%2Fleetcode-export/lists"}