I tried but it requires Django to work. Looks like it is intended to be used internally by openedx. I was looking for a package that can be used externally to make integrations. Additionally, it only provides a get method, not specific functions to access the API endpoints directly.
But I liked the way it handles oauth authentication. I think I will reuse this part and build from it.
If someone finds anything similar please let us know.
It has three different classes, depending on how you want to authenticate: using OAuth2 with a service user, using OAuth2 as the user who is logged in to your application (via OAuth2 SSO), or as an anonymous (not logged in) user who nevertheless has a unique session ID.
It uses Django a bit, for caching results and getting user auth data, but you can strip that out if you don’t need it. In particular the “base” client (for OAuth2 using a service user account) doesn’t depend on Django, if you remove the cache-related code. It does also use django-rest-framework’s serializers to deserialize some results, but you can also strip that out if you want.
We’re not able to support or maintain this code as a separate project right now, but feel free to use it if it’s helpful.
Example:
client = EdxAppClient(
lms_url=settings.LMS_ROOT,
studio_url=settings.CMS_ROOT,
oauth_key=settings.LMS_API_AUTH_KEY,
oauth_secret=settings.LMS_API_AUTH_SECRET,
)
print(f"This application can make API requests as the user '{client.get_username()}'")
Thanks @braden and @BbrSofiane! I think I will make a mix of both repos and create a new one. I wanted a very thin client, without Django or other libraries. Once I have some progress I will share the repo so anyone can contribute.
Hi all!
Well, I have finally started this project.
It consists of a package as small as possible (over all not dependent on Django) that can be imported in any python project to make calls to any LMS REST API endpoints.
Up to now, it’s intended to make anonymous calls using bearer tokens. However the code to request jwt tokens is there (just that I couldn’t find out how to authenticate a user out of a django app… your help here will be appreciated).
The code is in this repo. Only two functions are available so far: list_all_courses and change_enrollment. Anybody can contribute creating more and more functions! The final idea would be to have one function for each api entry point.
It can be installed with pip install openedx-rest-api-client.
Basic usage:
from openedx_rest_api_client import client as openedx_client
lms_url = 'https://lms.example.com'
lms_client_id = '' # get from django admin /admin/oauth2/client/'
lms_client_secret = '' # get from django admin /admin/oauth2/client/'
lms_client = openedx_client.OpenedxRESTAPIClient(
base_url=lms_url, client_id=lms_client_id, client_secret=lms_client_secret)
courses = lms_client.list_all_courses()
print(courses)
Contributions are welcome!!
What can be done next:
Implement more client functions for the api endpoints
Hi Andres,
Good work !
I would like to know if you were able to access the Polls and Survey answers and metadata.
Please, let me know, i was not able to find it in your last updates of repo
Thanks,
Amaury
I don’t think the polls and surveys data is available in any REST API of the LMS. If you want to insert a survey into a course and then see statistic information, you would need an analytics tool like Panorama. Indeed, the standard survey tool provided by Open edX out of the box is quite limited. I suggest integrating a powerful survey tool like Limesurvey into Open edX which is open source, offers more flexibility and can be connected to Panorama. Feel free to contact me at andres@aulasneo.com if you need more information.
Exactly! That video shows how to connect Panorama to an external tool like LimeSurvey and link both sources in a consolidated view.
The LimeSurvey XBlock will help you embed the survey experience into Open edX, but will not get the response data into any analytics system.
The free mode of Panorama is a limited version of the our basic SaaS offering, neither of which include connection to third party sources.
You can use the Panorama agent to connect to LimeSurvey directly by yourself.
If you need support just send me an email to andres@aulasneo.com and we’ll be happy to explain you in details all the options.
Hi @Andres.Aulasneo
thank you,
not sure to fully understand, but even with the ELT on GitHub, i will have to susbribe to panorama and create Azure resources right ?
I would prefer not to duplicate data already stored in the OpenEdX data base, i’m lookig to expose and consume them.
Regards
Amaury
Panorama currently works only on AWS datalake, not Azure. You do not have to subscribe to Panorama if you don’t want, but you will have to build your own datalake to make it work.
Always remember that the internal databases are designed for OLTP (transactional process), while OLAP (analytics) have other requirements and can eventually interfere with the application performance. More on that in this article.
Additionally, interconnecting external services like LimeSurvey can be challenging. I mean, student data will be on Open edX db, survey responses will be in the LimeSurvey db. You will have to figure out how to join data from different dbs.
Hi @Andres.Aulasneo
thanks for clarifying,
that’s why i’m looking for the right endpoints and map the student id and profile with respondant id.
i still don’t know how to setup a datalake for an opensource version of panorama-elt, is there any documentation about this ?
I’ve understood there are csv, xls and mysql support, with some SQL DML