Skip to main content

LearnDash Python Library

Warning, early alpha. Most functionality is missing. The LearnDash Python Library provides a simple wrapper for a LearnDash API.

Documentation

See the LearnDash API V2 Docs.

Installation

pip install learndash

Usage

import learndash
learndash.api_host = https://my-learndash-website.com

# Auth is provided via wordpress user credentials when needed
import os
learndash.wordpress_un = os.environ.get('WORDPRESS_UN')
learndash.wordpress_pw = os.environ.get('WORDPRESS_PW')

# list Courses
courses = learndash.Course().list()
print(courses)

# retrieve specific Course
course = learndash.Course(12).retrieve()
print(course)

# add user to a course
course_id = 1
learndash.Course(1).users().update({'user_ids': [course_id]})

Supported Resources

The Learndash V2 API is still in beta, and this library is still in development. Supported resources and examples are listed below.

  • Course
    • Retrieve
      learndash.Course(1).retrieve()
    • List
      learndash.Course().list()
  • Course Step
    • List
      learndash.Course(1).steps().list()
    • Update
      learndash.Course(1).steps().update({})
  • Course Prerequisite
    • List
      learndash.Course(1).prerequisites().list()
  • Course User
    • List
      learndash.Course(1).users().list()
    • Update
      learndash.Course(1).users().update({'user_ids': []})
  • Course Group
    • List
      learndash.Course(1).groups().list()
    • Update
      learndash.Course(1).groups().update()
  • User
    • Retrieve
      learndash.User(1).retrieve()
    • List
      learndash.User().list()
  • User Course Progress
    • List
      learndash.User(1).course_progress().list()
  • User Course
    • List
      learndash.User(1).courses().list()
    • Update
      learndash.User(1).courses().update({'user_ids': []})
  • User Group
    • List
      learndash.User(1).groups().list()
    • Update
      learndash.User(1).groups().update({})
  • User Quiz Progress
    • List
      learndash.User(1).quiz_progress().list()

Configuring API Paths

The LearnDash Wordpress plugin allows admins to configure the paths for each API resource. By default, this library will use the LearnDash plugin's default paths, but you can reconfigure those paths.

How To Configure

Simply import the learndash module and overwrite the default path for an endpoint.

import learndash
learndash.path_courses = 'courses'  # Leave out slashes

Configurable Paths

All configurable paths and their default values are below. From learndash/__init__.py.

path_assignments = 'sfwd-assignment'
path_courses = 'sfwd-courses'
path_course_steps = 'steps'
path_course_prerequisites = 'prerequisites'
path_course_users = 'users'
path_course_groups = 'groups'
path_essays = 'sfwd-essays'
path_groups = 'groups'
path_group_courses = 'courses'
path_group_leaders = 'leaders'
path_group_users = 'users'
path_lessons = 'sfwd-lessons'
path_price_types = 'price-types'
path_questions = 'sfwd-question'
path_question_types = 'question-types'
path_quizzes = 'sfwd-quiz'
path_quiz_statistics = 'statistics'
path_quiz_statistics_questions = 'questions'
path_topics = 'sfwd-topic'
path_users = 'users'
path_user_course_progress = 'course-progress'
path_user_courses = 'courses'
path_user_groups = 'groups'
path_user_quiz_progress = 'course-progress'

Dependencies

Requires the requests library.

Metadata

Release files for learndash 0.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for learndash 0.0.7
File Size Uploaded
learndash-0.0.7.tar.gz 8.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for learndash 0.0.7
File Interpreter ABI Platform
learndash-0.0.7-py3-none-any.whl Python 3 none any Details

Total release size: 21.1 kB

Release files / learndash-0.0.7.tar.gz

Download URL learndash-0.0.7.tar.gz
Size 8.7 kB
Tags Source
SHA-256 checksum
How to use checksums
d23a77ae0a1566840b9ae805bfee51446bc1dfe16bfd5b27b16086d16382a20e
BLAKE2b-256 checksum
How to use checksums
0d2594fcd4181f20abb7fc11a1296310ce337acedd7c18e0b5fc2619d45265a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.2

Release files / learndash-0.0.7-py3-none-any.whl

Download URL learndash-0.0.7-py3-none-any.whl
Size 12.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
be1a5d467f0a328ee1b4462063182aa306304e967d9de48f236a53a66f18e93a
BLAKE2b-256 checksum
How to use checksums
10322338c8102ebf0e0b88c9962b9175b7c394c2d5cf3e9a651d975303aa8e2c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.2

Release history Release notifications | RSS feed

This release

0.0.7 This release

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page