edapi


Nameedapi JSON
Version 0.1.0 PyPI version JSON
download
home_pageNone
SummaryAn unofficial integration of the Ed API with Python
upload_time2024-08-16 01:34:10
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # edapi

This package is an (unofficial) integration of the Ed API with Python. Since as of now there is no detailed documentation on the HTTP endpoints for the Ed API, I've reverse-engineered the endpoints by snooping through Chrome devtools.

Further, since the Ed API is in beta, the API endpoints can change at any time, and this package may break.

This package is still a work in progress, and currently contains the following features:
* Authenticating through an Ed API token (accessible through [https://edstem.org/us/settings/api-tokens](https://edstem.org/us/settings/api-tokens))
* Creating threads
* Editing existing threads (both through global ids and through course-specific ids)
* Uploading files to Ed (through direct file upload)
* Get user information
* List existing threads
* Lock and unlock threads

This list may expand as the package is developed further.

## Installation

This package is uploaded to PyPI: [https://pypi.org/project/edapi/](https://pypi.org/project/edapi/); the easiest way to install is with `pip3 install edapi`.

### Building the package

You can also build the package manually; to do so, just run `python3 -m build` in the root directory. This will create a `dist/` folder containing the package wheel, which can be installed via `pip3 install dist/edapi-x.x.x-py3-none.whl`.

## Documentation

Most documentation can be found in `edapi/docs/api_docs.md`; it contains documentation for the API, and also several notes on the HTTP endpoints as I've worked through this package.

## Usage

The bare minimum to utilize the API integration is to create a `.env` file in your project storing your API key, or store the API key in an environment variable in an equivalent manner:
```
ED_API_TOKEN=your-token-here
```
Your API key can be created through [https://edstem.org/us/settings/api-tokens](https://edstem.org/us/settings/api-tokens). The API key should be kept secret, and not committed through any version control system.

The following snippet is an example of using the API:
```python
from edapi import EdAPI

# initialize Ed API
ed = EdAPI()
# authenticate user through the ED_API_TOKEN environment variable
ed.login()

# retrieve user information; authentication is persisted to next API calls
user_info = ed.get_user_info()
user = user_info['user']
print(f"Hello {user['name']}!")
```

Types for all methods are also documented and type hints are used for every method. You can peruse the types in `edapi/edapi/types/`.

### Working with thread content

Ed uses a special XML format to format thread bodies. The various tags are also documented in `edapi/docs/api_docs.md` for your reference.

There are utility methods included to help with the process of creating thread documents through `BeautifulSoup`:
- `new_document()`: creates a new blank document containing the bare XML tags necessary to create a new thread.
    - Returns a new `BeautifulSoup` instance for the new document, along with the root document tag (use the document tag to serialize for the API).
- `parse_document(content: str)`: parses the content string, which holds the XML content of a thread.
    - Similar to `new_document`, returns a new `BeautifulSoup` instance for the parsed document, along with the root document tag.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "edapi",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": null,
    "author": null,
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/af/34/f19a93887c2bb056e037fb20a91b90aca024b162dbf66680532d45e83652/edapi-0.1.0.tar.gz",
    "platform": null,
    "description": "# edapi\n\nThis package is an (unofficial) integration of the Ed API with Python. Since as of now there is no detailed documentation on the HTTP endpoints for the Ed API, I've reverse-engineered the endpoints by snooping through Chrome devtools.\n\nFurther, since the Ed API is in beta, the API endpoints can change at any time, and this package may break.\n\nThis package is still a work in progress, and currently contains the following features:\n* Authenticating through an Ed API token (accessible through [https://edstem.org/us/settings/api-tokens](https://edstem.org/us/settings/api-tokens))\n* Creating threads\n* Editing existing threads (both through global ids and through course-specific ids)\n* Uploading files to Ed (through direct file upload)\n* Get user information\n* List existing threads\n* Lock and unlock threads\n\nThis list may expand as the package is developed further.\n\n## Installation\n\nThis package is uploaded to PyPI: [https://pypi.org/project/edapi/](https://pypi.org/project/edapi/); the easiest way to install is with `pip3 install edapi`.\n\n### Building the package\n\nYou can also build the package manually; to do so, just run `python3 -m build` in the root directory. This will create a `dist/` folder containing the package wheel, which can be installed via `pip3 install dist/edapi-x.x.x-py3-none.whl`.\n\n## Documentation\n\nMost documentation can be found in `edapi/docs/api_docs.md`; it contains documentation for the API, and also several notes on the HTTP endpoints as I've worked through this package.\n\n## Usage\n\nThe bare minimum to utilize the API integration is to create a `.env` file in your project storing your API key, or store the API key in an environment variable in an equivalent manner:\n```\nED_API_TOKEN=your-token-here\n```\nYour API key can be created through [https://edstem.org/us/settings/api-tokens](https://edstem.org/us/settings/api-tokens). The API key should be kept secret, and not committed through any version control system.\n\nThe following snippet is an example of using the API:\n```python\nfrom edapi import EdAPI\n\n# initialize Ed API\ned = EdAPI()\n# authenticate user through the ED_API_TOKEN environment variable\ned.login()\n\n# retrieve user information; authentication is persisted to next API calls\nuser_info = ed.get_user_info()\nuser = user_info['user']\nprint(f\"Hello {user['name']}!\")\n```\n\nTypes for all methods are also documented and type hints are used for every method. You can peruse the types in `edapi/edapi/types/`.\n\n### Working with thread content\n\nEd uses a special XML format to format thread bodies. The various tags are also documented in `edapi/docs/api_docs.md` for your reference.\n\nThere are utility methods included to help with the process of creating thread documents through `BeautifulSoup`:\n- `new_document()`: creates a new blank document containing the bare XML tags necessary to create a new thread.\n    - Returns a new `BeautifulSoup` instance for the new document, along with the root document tag (use the document tag to serialize for the API).\n- `parse_document(content: str)`: parses the content string, which holds the XML content of a thread.\n    - Similar to `new_document`, returns a new `BeautifulSoup` instance for the parsed document, along with the root document tag.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "An unofficial integration of the Ed API with Python",
    "version": "0.1.0",
    "project_urls": {
        "Homepage": "https://github.com/smartspot2/edapi"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f4a1d80286243cbbc888beef4c786ded4eec02f70e63a2cb0992d4f42fe54394",
                "md5": "f423604a06c09b7a632f184a9eb3d9a4",
                "sha256": "ac23ebb8d3f882bcda3a367f73fa19f69b00fbc07c5e9bd5a0c4108a79a7dd90"
            },
            "downloads": -1,
            "filename": "edapi-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f423604a06c09b7a632f184a9eb3d9a4",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 28584,
            "upload_time": "2024-08-16T01:34:09",
            "upload_time_iso_8601": "2024-08-16T01:34:09.127761Z",
            "url": "https://files.pythonhosted.org/packages/f4/a1/d80286243cbbc888beef4c786ded4eec02f70e63a2cb0992d4f42fe54394/edapi-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "af34f19a93887c2bb056e037fb20a91b90aca024b162dbf66680532d45e83652",
                "md5": "ba9042b88cb0392705914ba3da98d500",
                "sha256": "bd4929260647cfb50d2f736819c31365d56a7b4c0e302613f27af24ef4dfed7b"
            },
            "downloads": -1,
            "filename": "edapi-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "ba9042b88cb0392705914ba3da98d500",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 25368,
            "upload_time": "2024-08-16T01:34:10",
            "upload_time_iso_8601": "2024-08-16T01:34:10.407222Z",
            "url": "https://files.pythonhosted.org/packages/af/34/f19a93887c2bb056e037fb20a91b90aca024b162dbf66680532d45e83652/edapi-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-16 01:34:10",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "smartspot2",
    "github_project": "edapi",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "edapi"
}
        
Elapsed time: 1.75973s