Skip to main content

A Python wrapper for Schoology's API.

Project description

Python wrapper for Schoology’s API.

https://badge.fury.io/py/schoolopy.svg

Installation

You may easily install schoolopy from PyPI with pip3 install schoolopy.

Setup & Authorization

Before any use of schoolopy, you’ll need to import it.

import schoolopy

You’ll then need to instantiate the Auth class and, using that object, instantiate the API wrapper. There are two ways of authenticating with Schoology: two-legged and three-legged. The former is far simpler and useful for apps used by only one user who is capable of managing their own API keys, but if you’re building a web app to interact with Schoology you’ll need to use three-legged.

Obtain your consumer API key and secret from [Schoology URL]/api.

# Two-legged
sc = schoolopy.Schoology(schoolopy.Auth(key, secret))
sc.get_feed()  # etc.
# Three-legged
auth = schoolopy.Auth(key, secret, three_legged=True, domain='https://schoology.com')  # Replace URL with that of your school's Schoology
url = auth.request_authorization()
# Redirect user to that URL as appropriate for your application. Once user has performed action, continue.
if not auth.authorize():
    raise SystemExit('User not authorized!')
sc = schoolopy.Schoology(auth)

Example

More in-depth examples of both two- and three-legged authentication in action can be found in example-twolegged.py and example-threelegged.py. You will need to write your key and secret into example_config.yml.example and rename that file to example_config.yml.

Methods

This library contains a large number of functions for interaction with the API, and listing them all would be impractical.

For a comprehensive list of what endpoints are available, consult the REST API v1 documentation.

Most objects’ functions follow a similar pattern to the following example.

[realm] represents the name of any realm type; in this case you can use district, school, user, section, or group. Valid realms may vary for different objects.

event represents an Event object.

  • sc.get_events([realm]_id=)

  • sc.get_[realm]_events([realm]_id)

  • sc.create_event(event, [realm]_id=)

  • sc.create_[realm]_event(event, [realm]_id)

  • sc.get_event(event_id, [realm]_id=)

  • sc.get_[realm]_events([realm]_id)

  • sc.update_event(event, event_id, [realm]_id=)

  • sc.update_[realm]_event(event, event_id, [realm]_id)

  • sc.delete_event(event_id, [realm]_id=)

  • sc.delete_[realm]_event(event_id, [realm]_id)

Note: Some methods, such as `get_courses`, are currently broken because Schoology’s API has stopped providing data on the relevant endpoints.

Author

This library was created by Erik Boesen.

Licensing

This software is available under the MIT License.

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

schoolopy-0.3.1.tar.gz (17.0 kB view details)

Uploaded Source

File details

Details for the file schoolopy-0.3.1.tar.gz.

File metadata

  • Download URL: schoolopy-0.3.1.tar.gz
  • Upload date:
  • Size: 17.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.16

File hashes

Hashes for schoolopy-0.3.1.tar.gz
Algorithm Hash digest
SHA256 3eb753588ce65e637a64956f398a329ad9e3d54822ab29845100aed63e6472d1
MD5 003e471175327f1071f456c279427a01
BLAKE2b-256 914153a9385b0bd439ac41dcad6d8811b327ace195ce263dc8e2d564732e816f

See more details on using hashes here.

Supported by

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