Python example for creating a lesson for a course?

I would like to upload some texts to my courses(collection) using the lingq API via python. I found some examples like updating lingq’s using python (

from httplib2 import Http
from urllib import urlencode

API_KEY = “xxxxxx”
h = Http()
data = dict(id=2782310, status=0, fragment=“cinco horas”)
url = ‘’ % API_KEY
resp, content = h.request(url, “PUT”, urlencode(data))
print resp

Is there a similar simple way for creating lessons for a course?

data=dict(collectionId=xxxxxxx, title:“Title1”, text=“text…”)
url = ‘’ % API_KEY
resp, content = h.request(url, “PUT/POST???”, urlencode(data))



What happened to the API?
None of the calls works for me.
Is there a Postman collection around?

That API looks obsolete. The proper one is here REST API Documentation — LingQ 1.0 documentation

Thanks for the link - i actually meant this version of the API. For some reason i don’t get any calls to work.
For instance this give me an error:

OK. Thanks.
This works to some extend. It is strait forward to create a new lesson in a course using python.

import requests
API_KEY = the access code from Login - LingQ
data = {“title”: “Lorem Ipsum”,
“text”: “Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut
labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi
ut aliquip ex ea commodo consequat.”,
“tags”: [“Test”], “collection”: “Course PK”}
resp =‘’, data=data, headers={‘Authorization’: 'Token ’ + API_KEY})

I just did not figure out how to send the audio-file using the “audio” property. I tried as value: open(“file.mp3”,“rb”) and base64.encodestring(audio). But it didn’t work. The error message was as follows: u’audio’: [u’The submitted data was not a file. Check the encoding type on the form.']. How do I have to encode the file? Could someone give me an example?

The other limitation is, that when the text is larger than 2k words the document is split automatically. I would like to avoid this. Since it is possible to create lessons containing more than 2k but less than 10k words manually, I was wondering whether or not it is possible to avoid the automatic splitting using python?

Thanks a lot and all the best.