{"id":21959722,"url":"https://github.com/rusticisoftware/scormcloud-api-v2-client-python","last_synced_at":"2025-06-17T14:36:42.441Z","repository":{"id":46244831,"uuid":"177437211","full_name":"RusticiSoftware/scormcloud-api-v2-client-python","owner":"RusticiSoftware","description":"Swagger Generated Python Client for SCORM Cloud API v2","archived":false,"fork":false,"pushed_at":"2024-02-09T22:23:16.000Z","size":579,"stargazers_count":7,"open_issues_count":0,"forks_count":5,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-06-01T18:39:33.328Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RusticiSoftware.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-03-24T16:03:17.000Z","updated_at":"2025-01-19T22:37:37.000Z","dependencies_parsed_at":"2024-11-29T09:42:17.038Z","dependency_job_id":null,"html_url":"https://github.com/RusticiSoftware/scormcloud-api-v2-client-python","commit_stats":{"total_commits":14,"total_committers":5,"mean_commits":2.8,"dds":0.6428571428571428,"last_synced_commit":"ec38b14057b283e76309101a24c6493527f93bfe"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/RusticiSoftware/scormcloud-api-v2-client-python","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RusticiSoftware%2Fscormcloud-api-v2-client-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RusticiSoftware%2Fscormcloud-api-v2-client-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RusticiSoftware%2Fscormcloud-api-v2-client-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RusticiSoftware%2Fscormcloud-api-v2-client-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RusticiSoftware","download_url":"https://codeload.github.com/RusticiSoftware/scormcloud-api-v2-client-python/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RusticiSoftware%2Fscormcloud-api-v2-client-python/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260380723,"owners_count":23000335,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-29T09:32:08.545Z","updated_at":"2025-06-17T14:36:37.427Z","avatar_url":"https://github.com/RusticiSoftware.png","language":"Python","readme":"# rustici_software_cloud_v2\nREST API used for SCORM Cloud integrations.\n\nThis Python package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:\n\n- API version: 2.0\n- Package version: 4.0.0\n- Build package: io.swagger.codegen.languages.PythonClientCodegen\n\n## Requirements.\nPython 3.4+\n\n## Installation\n### pip\n[rustici_software_cloud_v2](https://pypi.org/project/rustici_software_cloud_v2/)\n\n```sh\npip install rustici_software_cloud_v2\n```\n\n### GitHub\n[scormcloud-api-v2-client-python](https://github.com/RusticiSoftware/scormcloud-api-v2-client-python)\n\n```sh\npip install git+https://github.com/RusticiSoftware/scormcloud-api-v2-client-python.git\n```\n\n### Setuptools\n```sh\npython setup.py install --user\n```\n(or `sudo python setup.py install` to install the package for all users)\n\nThen import the package:\n```python\nimport rustici_software_cloud_v2\n```\n\n## Tips and Tricks\nWorking with headers will require calling the `WithHttpInfo` version of the function. This allows for grabbing the header directly from the response object:\n```python\n# Note: This code is specifically designed to not modify any existing data\ndispatch_api = scorm_cloud.DispatchApi()\nresponse = dispatch_api.update_dispatches_with_http_info(scorm_cloud.UpdateDispatchSchema(), since=datetime.utcnow().isoformat() + 'Z')\nprint(response[2]['X-Total-Count'])\n```\n\n## Changelog:\nCheck the [changelog](https://cloud.scorm.com/docs/v2/reference/changelog/) for details of what has changed.\n\n## Sample Code\n```python\nimport rustici_software_cloud_v2 as scorm_cloud\nfrom datetime import datetime, timedelta\nimport urllib.parse as ul\nimport time\n\n\n# ScormCloud API credentials\n# Note: These are not the same credentials used to log in to ScormCloud\nAPP_ID = \"APP_ID\"\nSECRET_KEY = \"SECRET_KEY\"\n\n# Sample values for data\nCOURSE_PATH = \"/PATH/TO/COURSE/RunTimeAdvancedCalls_SCORM20043rdEdition.zip\"\n\nCOURSE_ID = \"PY_SAMPLE_COURSE\"\nLEARNER_ID = \"PY_SAMPLE_COURSE_LEARNER\"\nREGISTRATION_ID = \"PY_SAMPLE_COURSE_REGISTRATION\"\n\n# String used for output formatting\nOUTPUT_BORDER = \"---------------------------------------------------------\\n\"\n\n\ndef main():\n    \"\"\"\n    This sample will consist of:\n    1. Creating a course.\n    2. Registering a learner for the course.\n    3. Building a link for the learner to take the course.\n    4. Getting the learner's progress after having taken the course.\n    5. Viewing all courses and registrations.\n    6. Deleting all of the data created via this sample.\n\n    All input variables used in this sample are defined up above.\n    \"\"\"\n\n    # Configure HTTP basic authorization: APP_NORMAL\n    config = scorm_cloud.Configuration()\n    config.username = APP_ID\n    config.password = SECRET_KEY\n\n    # Set the default configuration values for new configuration objects\n    scorm_cloud.Configuration().set_default(config)\n\n    sc = ScormCloud_Python_Sample()\n\n    try:\n        # Create a course and a registration\n        course_details = sc.create_course(COURSE_ID, COURSE_PATH)\n        sc.create_registration(COURSE_ID, LEARNER_ID, REGISTRATION_ID)\n\n        # Show details of the newly imported course\n        print(\"Newly Imported Course Details: \")\n        print(course_details)\n\n\n\n        # Create the registration launch link\n        launch_link = sc.build_launch_link(REGISTRATION_ID)\n\n        # Show the launch link\n        print(OUTPUT_BORDER)\n        print(f\"Launck Link: {launch_link}\")\n        print(\"Navigate to the url above to take the course. Hit enter once complete.\")\n        input()\n\n\n\n        # Get the results for the registration\n        registration_progress = sc.get_result_for_registration(REGISTRATION_ID)\n\n        # Show details of the registration progress\n        print(OUTPUT_BORDER)\n        print(\"Registration Progress: \")\n        print(registration_progress)\n\n\n\n        # Get information about all the courses in ScormCloud\n        course_list = sc.get_all_courses()\n\n        # Show details of the courses\n        print(OUTPUT_BORDER)\n        print(\"Course List: \")\n        for course in course_list:\n            print(course)\n\n\n\n        # Get information about all the registrations in ScormCloud\n        registration_list = sc.get_all_registrations()\n\n        # Show details of the registrations\n        print(OUTPUT_BORDER)\n        print(\"Registration List: \")\n        for registration in registration_list:\n            print(registration)\n\n    except (scorm_cloud.rest.ApiException, ValueError) as err:\n        print(err)\n\n    finally:\n        # Delete all the data created by this sample\n        sc.clean_up(COURSE_ID, REGISTRATION_ID)\n\n\nclass ScormCloud_Python_Sample:\n\n    def __configure_oauth(self, scopes):\n        \"\"\"\n        Sets the default OAuth token passed with all calls to the API.\n\n        If a token is created with limited scope (i.e. read:registration),\n        calls that require a different permission set will error. Either a\n        new token needs to be generated with the correct scope, or the\n        default access token can be reset to None. This would cause the\n        request to be made with basic auth credentials (appId/ secret key)\n        instead.\n\n        Additionally, you could create a new configuration object and set\n        the token on that object instead of the default access token. This\n        configuration would then be passed into the Api object:\n\n        config = scorm_cloud.Configuration()\n        token_request = {\n            'permissions': scorm_cloud.PermissionsSchema([ \"write:course\", \"read:course\" ]),\n            'expiry': (datetime.utcnow() + timedelta(minutes=2)).isoformat() + 'Z'\n        }\n        config.access_token = app_management_api.create_token(token_request).result\n        course_api = scorm_cloud.CourseApi(scorm_cloud.ApiClient(config))\n\n        Any calls that would use this CourseApi instance would then have the\n        write:course and read:course permissions passed automatically, but\n        other instances would be unaffected and continue to use other means\n        of authorization.\n\n        :param scopes: List of permissions for calls made with the token.\n        :type scopes: list[str]\n        \"\"\"\n\n        app_management_api = scorm_cloud.ApplicationManagementApi()\n\n        # Set permissions and expiry time of the token\n        # The expiry expected for token request must be in ISO-8601 format\n        expiry = (datetime.utcnow() + timedelta(minutes=2)).isoformat() + 'Z'\n        permissions = scorm_cloud.PermissionsSchema(scopes)\n\n        # Make the request to get the OAuth token\n        token_request = scorm_cloud.TokenRequestSchema(permissions, expiry)\n        token_result = app_management_api.create_token(token_request)\n\n        # Set the default access token used with further API requests.\n        # To remove the token, reset config.access_token back to None\n        # and set the default before the next call.\n        config = scorm_cloud.Configuration()\n        config.access_token = token_result.result\n        scorm_cloud.Configuration().set_default(config)\n\n    def create_course(self, course_id, course_path):\n        \"\"\"\n        Creates a course by uploading the course from your local machine.\n        Courses are a package of content for a learner to consume.\n\n        Other methods for importing a course exist. Check the documentation\n        for additional ways of importing a course.\n\n        :param course_id: Id that will be used to identify the course.\n        :type course_id: str\n        :param course_path: Path to the course being uploaded.\n        :type course_path: str\n        :returns: Detailed information about the newly uploaded course.\n        :rtype: CourseSchema\n        \"\"\"\n\n        # (Optional) Further authenticate via OAuth token access\n        # self.__configure_oauth([ \"write:course\", \"read:course\" ])\n\n        # This call will use OAuth with the \"write:course\" scope\n        # if configured.  Otherwise the basic auth credentials will be used\n        course_api = scorm_cloud.CourseApi()\n        job_id = course_api.create_upload_and_import_course_job(course_id, file=course_path)\n\n        # This call will use OAuth with the \"read:course\" scope\n        # if configured.  Otherwise the basic auth credentials will be used\n        job_result = course_api.get_import_job_status(job_id.result)\n        while job_result.status == \"RUNNING\":\n            time.sleep(1)\n            job_result = course_api.get_import_job_status(job_id.result)\n\n        if job_result.status == \"ERROR\":\n            raise ValueError(\"Course is not properly formatted: \" + job_result.message)\n\n        return job_result.import_result.course\n\n    def create_registration(self, course_id, learner_id, registration_id):\n        \"\"\"\n        Creates a registration allowing the learner to consume the course\n        content. A registration is the link between a learner and a single\n        course.\n\n        :param course_id: Id of the course to register the learner for.\n        :type course_id: str\n        :param learner_id: Id that will be used to identify the learner.\n        :type learner_id: str\n        :param registration_id: Id that will be used to identify the registration.\n        :type registration_id: str\n        \"\"\"\n\n        # (Optional) Further authenticate via OAuth token access\n        # self.__configure_oauth([ \"write:registration\" ])\n\n        registration_api = scorm_cloud.RegistrationApi()\n        learner = scorm_cloud.LearnerSchema(learner_id)\n        registration = scorm_cloud.CreateRegistrationSchema(course_id, learner, registration_id)\n        registration_api.create_registration(registration)\n\n    def build_launch_link(self, registration_id):\n        \"\"\"\n        Builds a url allowing the learner to access the course.\n\n        This sample will build the launch link and print it out. It will then\n        pause and wait for user input, allowing you to navigate to the course\n        to generate sample learner progress. Once this step has been reached,\n        hitting the enter key will continue program execution.\n\n        :param registration_id: Id of the registration the link is being built for.\n        :type registration_id: str\n        :returns: Link for the learner to launch the course.\n        :rtype: str\n        \"\"\"\n\n        # (Optional) Further authenticate via OAuth token access\n        # self.__configure_oauth([ \"read:registration\" ])\n\n        registration_api = scorm_cloud.RegistrationApi()\n        settings = scorm_cloud.LaunchLinkRequestSchema(redirect_on_exit_url=\"Message\")\n        launch_link = registration_api.build_registration_launch_link(registration_id, settings)\n\n        return launch_link.launch_link\n\n    def get_result_for_registration(self, registration_id):\n        \"\"\"\n        Gets information about the progress of the registration.\n\n        For the most up-to-date results, you should implement our postback\n        mechanism. The basic premise is that any update to the registration\n        would cause us to send the updated results to your system.\n\n        More details can be found in the documentation:\n        https://cloud.scorm.com/docs/v2/guides/postback/\n\n        :param registration_id: Id of the registration to get results for.\n        :type registration_id: str\n        :returns: Detailed information about the registration's progress.\n        :rtype: RegistrationSchema\n        \"\"\"\n\n        # (Optional) Further authenticate via OAuth token access\n        # self.__configure_oauth([ \"read:registration\" ])\n\n        registration_api = scorm_cloud.RegistrationApi()\n        progress = registration_api.get_registration_progress(registration_id)\n\n        return progress\n\n    def get_all_courses(self):\n        \"\"\"\n        Gets information about all courses. The result received from the API\n        call is a paginated list, meaning that additional calls are required\n        to retrieve all the information from the API. This has already been\n        accounted for in the sample.\n\n        :returns: List of detailed information about all of the courses.\n        :rtype: list[CourseSchema]\n        \"\"\"\n\n        # (Optional) Further authenticate via OAuth token access\n        # self.__configure_oauth([ \"read:course\" ])\n\n        # Additional filters can be provided to this call to get a subset\n        # of all courses.\n        course_api = scorm_cloud.CourseApi()\n        response = course_api.get_courses()\n\n        # This call is paginated, with a token provided if more results exist\n        course_list = response.courses\n        while response.more is not None:\n            response = course_api.get_courses(more=response.more)\n            course_list += response.courses\n\n        return course_list\n\n    def get_all_registrations(self):\n        \"\"\"\n        Gets information about the registration progress for all\n        registrations. The result received from the API call is a paginated\n        list, meaning that additional calls are required to retrieve all the\n        information from the API. This has already been accounted for in the\n        sample.\n\n        This call can be quite time-consuming and tedious with lots of\n        registrations. If you find yourself making lots of calls to this\n        endpoint, it might be worthwhile to look into registration postbacks.\n\n        More details can be found in the documentation:\n        https://cloud.scorm.com/docs/v2/guides/postback/\n\n        :returns: List of detailed information about all of the registrations.\n        :rtype: list[RegistrationSchema]\n        \"\"\"\n\n        # (Optional) Further authenticate via OAuth token access\n        # self.__configure_oauth([ \"read:registration\" ])\n\n        # Additional filters can be provided to this call to get a subset\n        # of all registrations.\n        registration_api = scorm_cloud.RegistrationApi()\n        response = registration_api.get_registrations()\n\n        # This call is paginated, with a token provided if more results exist\n        registration_list = response.registrations\n        while response.more is not None:\n            response = registration_api.get_registrations(more=response.more)\n            registration_list += response.registrations\n\n        return registration_list\n\n    def clean_up(self, course_id, registration_id):\n        \"\"\"\n        Deletes all of the data generated by this sample.\n        This code is run even if the program has errored out, providing a\n        \"clean slate\" for every run of this sample.\n\n        It is not necessary to delete registrations if the course\n        they belong to has been deleted. Deleting the course will\n        automatically queue deletion of all registrations associated with\n        the course. There will be a delay between when the course is deleted\n        and when the registrations for the course have been removed. The\n        registration deletion has been handled here to prevent scenarios\n        where the registration hasn't been deleted yet by the time the\n        sample has been rerun.\n\n        :param course_id: Id of the course to delete.\n        :type course_id: str\n        :param registration_id: Id of the registration to delete.\n        :type registration_id: str\n        \"\"\"\n\n        # (Optional) Further authenticate via OAuth token access\n        # self.__configure_oauth([ \"delete:course\", \"delete:registration\" ])\n\n        # This call will use OAuth with the \"delete:course\" scope\n        # if configured.  Otherwise the basic auth credentials will be used\n        course_api = scorm_cloud.CourseApi()\n        course_api.delete_course(course_id)\n\n        # The code below is to prevent race conditions if the\n        # sample is run in quick successions.\n\n        # This call will use OAuth with the \"delete:registration\" scope\n        # if configured.  Otherwise the basic auth credentials will be used\n        registration_api = scorm_cloud.RegistrationApi()\n        registration_api.delete_registration(registration_id)\n\n\nif __name__ == \"__main__\":\n    main()\n\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frusticisoftware%2Fscormcloud-api-v2-client-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frusticisoftware%2Fscormcloud-api-v2-client-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frusticisoftware%2Fscormcloud-api-v2-client-python/lists"}