Welcome to the Panopto Community

Please note: All new registrants to the Panopto Community Forum must be approved by a forum moderator or admin. As such, if you navigate to a feature that is members-only, you may receive an error page if your registration has not yet been approved. We apologize for any inconvenience and are approving new members as quickly as possible.
Options

Using GetSessionDetailedUsage and GetSessionExtendedDetailedUsage with python 3

Hi. First, I'm not a very experienced python developer.

I would like to discover the data that can be retrieved using GetSessionDetailedUsage and GetSessionExtendedDetailedUsage with python 3. It seems that it won't be possible using a REST client, only with a SOAP client.

I have to admit that I have been drowning in all the documentation, having difficulty finding out what is relevant and what not. But these resources seem relevant:

  • support.panopto.com/resource/APIDocumentation/Help/html/c9f69782-6fe0-863d-9f8c-177c172375e3.htm
  • github.com/Panopto/python-soap/tree/python3

I used the supplied requirements.txt to install the relevant packages, pip list shows me this:

  • appdirs 1.4.4
  • attrs 23.1.0
  • cached-property 1.5.2
  • certifi 2023.5.7
  • charset-normalizer 3.1.0
  • defusedxml 0.7.1
  • idna 3.4
  • isodate 0.6.1
  • lxml 4.9.2
  • pip 23.1.2
  • pytz 2023.3
  • requests 2.30.0
  • requests-toolbelt 1.0.0
  • setuptools 64.0.3
  • six 1.16.0
  • urllib3 1.23
  • wheel 0.37.1
  • zeep 3.1.0

In the environment I'm an admin, under User Settings -> API Clients I added a client based in Desktop Application.

In the examples folder there are the files stats_report_example.py and usage_example.py, I edited both to add the host (https://xxxxxx.cloud.panopto.eu) and the oauth_token (added the client secret).

Unfortunately I get a list of errors, ending with "Failed to establish a new connection: [Errno 11001] getaddrinfo failed"

Any help is appreciated that helps me understand why I'm not getting it working or that there are better approaches / solutions than this.

Best,

Jaap Stelpstra

Tagged:

Best Answers

  • Options
    Nedim DeliahmetovicNedim Deliahmetovic Panopto Employee
    Answer ✓

    Hi Jaap,

    You are right, those endpoint are SOAP API endpoints and you will need to use SOAP format in order to get your needed responses.

    I will add here examples how you can try to get responses using Python requests and http.client libs:

    GetSessionDetailedUsage

    Python requests:

    import requests
    
    url = "https://***.panopto.com/Panopto/PublicAPI/4.0/UsageReporting.svc"
    payload = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">\r\n    <s:Body>\r\n        <GetSessionDetailedUsage xmlns=\"http://tempuri.org/\">\r\n            <auth xmlns:a=\"http://schemas.datacontract.org/2004/07/Panopto.Server.Services.PublicAPI.V40\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">                \r\n                <a:Password>{PANOPTO USER PASSWORD}</a:Password>\r\n                <a:UserKey>{PANOPTO USERNAME}</a:UserKey>\r\n            </auth>\r\n            <sessionId>{SESSION PUBLIC ID e.g 79172b62-3027-4c57-be26-ae9b00c665c8}</sessionId>          \r\n            <beginRange>2018-01-01</beginRange>\r\n            <endRange>2023-12-31</endRange>\r\n        </GetSessionDetailedUsage>\r\n    </s:Body>\r\n</s:Envelope>"
    headers = {
      'Content-Type': 'text/xml; charset=utf-8',
      'SoapAction': 'http://tempuri.org/IUsageReporting/GetSessionDetailedUsage'
    }
    response = requests.request("POST", url, headers=headers, data=payload)
    print(response.text)
    

    Python http.client

    import http.client
    
    conn = http.client.HTTPSConnection("***.panopto.com")
    payload = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">\r\n    <s:Body>\r\n        <GetSessionDetailedUsage xmlns=\"http://tempuri.org/\">\r\n            <auth xmlns:a=\"http://schemas.datacontract.org/2004/07/Panopto.Server.Services.PublicAPI.V40\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">                \r\n                <a:Password>{PANOPTO USER PASSWORD}</a:Password>\r\n                <a:UserKey>{PANOPTO USERNAME}</a:UserKey>\r\n            </auth>\r\n            <sessionId>{SESSION PUBLIC ID e.g 79172b62-3027-4c57-be26-ae9b00c665c8}</sessionId>          \r\n            <beginRange>2018-01-01</beginRange>\r\n            <endRange>2023-12-31</endRange>\r\n        </GetSessionDetailedUsage>\r\n    </s:Body>\r\n</s:Envelope>"
    headers = {
      'Content-Type': 'text/xml; charset=utf-8',
      'SoapAction': 'http://tempuri.org/IUsageReporting/GetSessionDetailedUsage'
    }
    conn.request("POST", "/Panopto/PublicAPI/4.0/UsageReporting.svc", payload, headers)
    res = conn.getresponse()
    data = res.read()
    print(data.decode("utf-8"))
    


    GetSessionExtendedDetailedUsage

    Python requests:

    import requests
    
    url = "https://***.panopto.com/Panopto/PublicAPI/4.0/UsageReporting.svc"
    payload = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">\r\n    <s:Body>\r\n        <GetSessionExtendedDetailedUsage xmlns=\"http://tempuri.org/\">\r\n            <auth xmlns:a=\"http://schemas.datacontract.org/2004/07/Panopto.Server.Services.PublicAPI.V40\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">                \r\n                <a:Password>{PANOPTO PASSWORD}</a:Password>\r\n                <a:UserKey>{PANOPTO USERNAME}</a:UserKey>\r\n            </auth>\r\n            <sessionId>{SESSION PUBLIC ID e.g 79172b62-3027-4c57-be26-ae9b00c665c8}</sessionId>         \r\n            <beginRange>2018-01-01</beginRange>\r\n            <endRange>2023-12-31</endRange>\r\n        </GetSessionExtendedDetailedUsage>\r\n    </s:Body>\r\n</s:Envelope>"
    headers = {
      'Content-Type': 'text/xml; charset=utf-8',
      'SoapAction': 'http://tempuri.org/IUsageReporting/GetSessionExtendedDetailedUsage'
    }
    response = requests.request("POST", url, headers=headers, data=payload)
    print(response.text)
    

    Python http.client

    import http.client
    
    conn = http.client.HTTPSConnection("***.panopto.com")
    payload = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">\r\n    <s:Body>\r\n        <GetSessionExtendedDetailedUsage xmlns=\"http://tempuri.org/\">\r\n            <auth xmlns:a=\"http://schemas.datacontract.org/2004/07/Panopto.Server.Services.PublicAPI.V40\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">                \r\n                <a:Password>{PANOPTO USER PASSWORD}</a:Password>\r\n                <a:UserKey>{PANOPTO USERNAME}</a:UserKey>\r\n            </auth>\r\n            <sessionId>{SESSION PUBLIC ID e.g 79172b62-3027-4c57-be26-ae9b00c665c8}</sessionId>         \r\n            <beginRange>2018-01-01</beginRange>\r\n            <endRange>2023-12-31</endRange>\r\n        </GetSessionExtendedDetailedUsage>\r\n    </s:Body>\r\n</s:Envelope>"
    headers = {
      'Content-Type': 'text/xml; charset=utf-8',
      'SoapAction': 'http://tempuri.org/IUsageReporting/GetSessionExtendedDetailedUsage'
    }
    conn.request("POST", "/Panopto/PublicAPI/4.0/UsageReporting.svc", payload, headers)
    res = conn.getresponse()
    data = res.read()
    print(data.decode("utf-8"))
    


    I hope examples will help you! Please let us know if you have additional questions.

    Kind regards,

    Panopto team.

  • Options
    Nedim DeliahmetovicNedim Deliahmetovic Panopto Employee
    Answer ✓

    Hi Jaap,

    Thanks for contacting us again.

    I am glad that you was able to retrieve needed data and I understand your additional need for REST instead of SOAP API for easier development.

    Unfortunately, I do not have information about roadmap for REST API and enhancements but I would kindly ask you if you could please submit support ticket for this request and our team will triage it and give more information about next steps?

    Kind regards,

    Nedim

Answers

  • Options

    Hi @Nedim Deliahmetovic, thanks for your help, I've been able to retrieve the data I needed using this, but it remains a struggle due to how SOAP works with XML and attributes that start with "a:", "b", "s", etc. and getting them into dictionaries and work with the data, while REST is so much more straightforward in its use.

    As the REST API is the long term commitment according to your colleagues, could you put it on the roadmap to also GetSessionDetailedUsage and GetSessionExtendedDetailedUsage to the REST API? That would make life so much easier, so I (and many others) won't need to use both REST API and SOAP API to get data out.

    If this fits your goals regarding the roadmap, could you give any indications of a timeline?

    Kind regards,

    Jaap Stelpstra

Sign In or Register to comment.