pyoverleaf


Namepyoverleaf JSON
Version 0.1.4 PyPI version JSON
download
home_page
SummaryOverleaf API and simple CLI
upload_time2023-09-11 15:42:32
maintainer
docs_urlNone
author
requires_python>=3.8
licenseMIT
keywords overleaf api
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # PyOverleaf
Unofficial Python API to access Overleaf.

## Tasks
- [x] List projects
- [x] Download project as zip
- [x] List and download individual files/docs
- [x] Upload new files/docs
- [x] Delete files, create folders
- [x] Python CLI interface to access project files
- [ ] Move, rename files
- [ ] Create, delete, archive, and rename projects
- [ ] Access/update comments, perform live changes
- [ ] Access/update profile details
- [ ] Robust login

## Getting started
Install the project by running the following:
```bash
pip install 'pyoverleaf[cli]'
```

Before using the API, make sure you are logged into Overleaf in your default web browser.
Currently, only Google Chrome and Mozilla Firefox are supported: https://github.com/richardpenman/browsercookie
Test if everything is working by listing the projects:
```bash
pyoverleaf ls
```


## Python API
The low-level Python API provides a way to access Overleaf projects from Python.
The main entrypoint is the class `pyoverleaf.Api`

### Accessing projects
```python
import pyoverleaf

api = pyoverleaf.Api()
api.login_from_browser()

# Lists the projects
projects = api.get_projects()

# Download the project as a zip
project_id = projects[0].id
api.download_project(project_id, "project.zip")
```

### Managing project files
```python
import pyoverleaf

api = pyoverleaf.Api()
api.login_from_browser()
# Choose a project
project_id = projects[0].id

# Get project files
root_folder = api.project_get_files(project_id)

# Create new folder
new_folder = api.project_create_folder(project_id, root_folder.id, "new-folder")

# Upload new file to the newly created folder
file_bytes = open("test-image.jpg", "rb").read()
new_file = api.project_upload_file(project_id, new_folder.id, "file-name.jpg", file_bytes)

# Delete newly added folder containing the file
api.project_delete_entity(project_id, new_folder)
```

## Higher-level Python IO API
The higher-level Python IO API allows users to access the project files in a Pythonic way.
The main entrypoint is the class `pyoverleaf.ProjectIO`

Here are some examples on how to use the API:
```python
import pyoverleaf

api = pyoverleaf.Api()
api.login_from_browser()
# Choose a project
project_id = projects[0].id

# Get project IO API
io = pyoverleaf.ProjectIO(api, project_id)

# Check if a path exists
exists = io.exists("path/to/a/file/or/folder")

# Create a directory
io.mkdir("path/to/new/directory", parents=True, exist_ok=True)

# Listing a directory
for entity in io.listdir("path/to/a/directory"):
    print(entity.name)

# Reading a file
with io.open("path/to/a/file", "r") as f:
    print(f.read())

# Creating a new file
with io.open("path/to/a/new/file", "w+") as f:
    f.write("new content")
```


## Using the CLI
The CLI provides a way to access Overleaf from the shell.
To get started, run `pyoverleaf --help` to list available commands and their arguments.

### Listing projects and files
```bash
# Listing projects
pyoverleaf ls

# Listing project files
pyoverleaf ls project-name

# Listing project files in a folder
pyoverleaf ls project-name/path/to/files
```

### Downloading existing projects
```bash
pyoverleaf download-project project-name output.zip
```

### Creating and deleting directories
```bash
# Creating a new directory (including parents)
pyoverleaf mkdir -p project-name/path/to/new/directory

# Deleting
pyoverleaf rm project-name/path/to/new/directory
```

### Reading and writing files
```bash
# Writing to a file
echo "new content" | pyoverleaf write project-name/path/to/file.txt

# Uploading an image
cat image.jpg | pyoverleaf write project-name/path/to/image.jpg

# Reading a file
pyoverleaf read project-name/path/to/file.txt
```

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "pyoverleaf",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "overleaf,api",
    "author": "",
    "author_email": "Jonas Kulhanek <jonas.kulhanek@live.com>",
    "download_url": "https://files.pythonhosted.org/packages/6c/64/7cbf66eaddd654cb6f76a8b3a44a9e151986cf262a657bb4c9cdc9071393/pyoverleaf-0.1.4.tar.gz",
    "platform": null,
    "description": "# PyOverleaf\nUnofficial Python API to access Overleaf.\n\n## Tasks\n- [x] List projects\n- [x] Download project as zip\n- [x] List and download individual files/docs\n- [x] Upload new files/docs\n- [x] Delete files, create folders\n- [x] Python CLI interface to access project files\n- [ ] Move, rename files\n- [ ] Create, delete, archive, and rename projects\n- [ ] Access/update comments, perform live changes\n- [ ] Access/update profile details\n- [ ] Robust login\n\n## Getting started\nInstall the project by running the following:\n```bash\npip install 'pyoverleaf[cli]'\n```\n\nBefore using the API, make sure you are logged into Overleaf in your default web browser.\nCurrently, only Google Chrome and Mozilla Firefox are supported: https://github.com/richardpenman/browsercookie\nTest if everything is working by listing the projects:\n```bash\npyoverleaf ls\n```\n\n\n## Python API\nThe low-level Python API provides a way to access Overleaf projects from Python.\nThe main entrypoint is the class `pyoverleaf.Api`\n\n### Accessing projects\n```python\nimport pyoverleaf\n\napi = pyoverleaf.Api()\napi.login_from_browser()\n\n# Lists the projects\nprojects = api.get_projects()\n\n# Download the project as a zip\nproject_id = projects[0].id\napi.download_project(project_id, \"project.zip\")\n```\n\n### Managing project files\n```python\nimport pyoverleaf\n\napi = pyoverleaf.Api()\napi.login_from_browser()\n# Choose a project\nproject_id = projects[0].id\n\n# Get project files\nroot_folder = api.project_get_files(project_id)\n\n# Create new folder\nnew_folder = api.project_create_folder(project_id, root_folder.id, \"new-folder\")\n\n# Upload new file to the newly created folder\nfile_bytes = open(\"test-image.jpg\", \"rb\").read()\nnew_file = api.project_upload_file(project_id, new_folder.id, \"file-name.jpg\", file_bytes)\n\n# Delete newly added folder containing the file\napi.project_delete_entity(project_id, new_folder)\n```\n\n## Higher-level Python IO API\nThe higher-level Python IO API allows users to access the project files in a Pythonic way.\nThe main entrypoint is the class `pyoverleaf.ProjectIO`\n\nHere are some examples on how to use the API:\n```python\nimport pyoverleaf\n\napi = pyoverleaf.Api()\napi.login_from_browser()\n# Choose a project\nproject_id = projects[0].id\n\n# Get project IO API\nio = pyoverleaf.ProjectIO(api, project_id)\n\n# Check if a path exists\nexists = io.exists(\"path/to/a/file/or/folder\")\n\n# Create a directory\nio.mkdir(\"path/to/new/directory\", parents=True, exist_ok=True)\n\n# Listing a directory\nfor entity in io.listdir(\"path/to/a/directory\"):\n    print(entity.name)\n\n# Reading a file\nwith io.open(\"path/to/a/file\", \"r\") as f:\n    print(f.read())\n\n# Creating a new file\nwith io.open(\"path/to/a/new/file\", \"w+\") as f:\n    f.write(\"new content\")\n```\n\n\n## Using the CLI\nThe CLI provides a way to access Overleaf from the shell.\nTo get started, run `pyoverleaf --help` to list available commands and their arguments.\n\n### Listing projects and files\n```bash\n# Listing projects\npyoverleaf ls\n\n# Listing project files\npyoverleaf ls project-name\n\n# Listing project files in a folder\npyoverleaf ls project-name/path/to/files\n```\n\n### Downloading existing projects\n```bash\npyoverleaf download-project project-name output.zip\n```\n\n### Creating and deleting directories\n```bash\n# Creating a new directory (including parents)\npyoverleaf mkdir -p project-name/path/to/new/directory\n\n# Deleting\npyoverleaf rm project-name/path/to/new/directory\n```\n\n### Reading and writing files\n```bash\n# Writing to a file\necho \"new content\" | pyoverleaf write project-name/path/to/file.txt\n\n# Uploading an image\ncat image.jpg | pyoverleaf write project-name/path/to/image.jpg\n\n# Reading a file\npyoverleaf read project-name/path/to/file.txt\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Overleaf API and simple CLI",
    "version": "0.1.4",
    "project_urls": null,
    "split_keywords": [
        "overleaf",
        "api"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3352bbaa38b91399c6c6cb38523b93fa9be78ef6506c304740539f36b72163c9",
                "md5": "98bc537a0b9e7a4bf7bf55271748eccd",
                "sha256": "c4ea8c560aceb5c02aa8d97f5512f5a199ceebd3c68da9f90a86d21d21d6d85d"
            },
            "downloads": -1,
            "filename": "pyoverleaf-0.1.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "98bc537a0b9e7a4bf7bf55271748eccd",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 11319,
            "upload_time": "2023-09-11T15:42:30",
            "upload_time_iso_8601": "2023-09-11T15:42:30.977584Z",
            "url": "https://files.pythonhosted.org/packages/33/52/bbaa38b91399c6c6cb38523b93fa9be78ef6506c304740539f36b72163c9/pyoverleaf-0.1.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6c647cbf66eaddd654cb6f76a8b3a44a9e151986cf262a657bb4c9cdc9071393",
                "md5": "2e64441311064e41a5aa1fb51c1946a5",
                "sha256": "ee6de4f0635e26894d497de77be8f842f8411c9dab20e4e058d751a3459521ce"
            },
            "downloads": -1,
            "filename": "pyoverleaf-0.1.4.tar.gz",
            "has_sig": false,
            "md5_digest": "2e64441311064e41a5aa1fb51c1946a5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 12531,
            "upload_time": "2023-09-11T15:42:32",
            "upload_time_iso_8601": "2023-09-11T15:42:32.550661Z",
            "url": "https://files.pythonhosted.org/packages/6c/64/7cbf66eaddd654cb6f76a8b3a44a9e151986cf262a657bb4c9cdc9071393/pyoverleaf-0.1.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-11 15:42:32",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "pyoverleaf"
}
        
Elapsed time: 0.18641s