Skip to main content

An unofficial integration of the Ed API with Python

Project description

edapi

This package is a fork of an (unofficial) integration of the Ed API with Python https://github.com/smartspot2/edapi. 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:

This list may expand as the package is developed further.

Installation

This package is uploaded to PyPI: 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

Your API key can be created through https://edstem.org/us/settings/api-tokens or https://edstem.org/au/settings/api-tokens. The API key should be kept secret, and not committed through any version control system.

Insert ed api key in the constrctor. The Ed api endpoint can also be updated by inserting it within the contructor argument. By default its https://edstem.org/api

The following snippet is an example of using the API:

import os
from edapi import EdAPI
from edapi.models.user import User
# load from environment variables
from dotenv import load_dotenv
load_dotenv()

ed = EdAPI(os.getenv("ED_API_TOKEN"))

user_info = ed.get_user_info()
user: User = user_info.get_user_info_summary()

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.

install dependencies to run examples scripts

uv pip install -e ".[dev]" uv run .\examples\getuserinfo.py

Build package using uv

uv pip install -e ".[build]" uv build uv publish

publish through github action with tag

git tag -a v0.1.0 -m "Release v0.1.0" git push origin v0.1.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

edapi_fork-0.1.4.tar.gz (27.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

edapi_fork-0.1.4-py3-none-any.whl (31.9 kB view details)

Uploaded Python 3

File details

Details for the file edapi_fork-0.1.4.tar.gz.

File metadata

  • Download URL: edapi_fork-0.1.4.tar.gz
  • Upload date:
  • Size: 27.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for edapi_fork-0.1.4.tar.gz
Algorithm Hash digest
SHA256 3cfd5942be58cd27fbd21ca23f33322cef3a397ef5dc66413ffebd7a45926525
MD5 8fd7f85a3c71fff1bd23a44f19838898
BLAKE2b-256 7c8f5aa8524a253094a1f6c417e5008ac8c728d5b16d55c507dc557c796adf8b

See more details on using hashes here.

Provenance

The following attestation bundles were made for edapi_fork-0.1.4.tar.gz:

Publisher: release.yml on cooi123/edapi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file edapi_fork-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: edapi_fork-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 31.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for edapi_fork-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 5331f68c1f1c48d03a930e614ffba500b47e18d231f9f1ca6705a71d35f08bf1
MD5 df32a6a9e575bc4e2781dc4d7cfca654
BLAKE2b-256 3a681e0ef03b0f447a076a5738a52476a877032b7fbb95b575a3d13c00a74c2a

See more details on using hashes here.

Provenance

The following attestation bundles were made for edapi_fork-0.1.4-py3-none-any.whl:

Publisher: release.yml on cooi123/edapi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page