A Fun Little Exercise to Familiarize People with RESTful APIs: <–(I’m American, so we spell it familiariZe)
RESTful APis are basically just HTTP GETs, POSTs, and PUTs to urls where the response it read by a computer program rather than a web browser (which is also a computer program but that’s not important to this discussion).
However, because the interface to a RESTful API is simply HTTP protocol, you can use your web browser (Firefox, IE, Chrome, etc) to explore how specific API’s work, as we will do here with the LingQ API, simply by surfing to the LingQ API’s urls.
The first thing the LingQ API documentation specifies you do is retrieve your APIKey, this can simply be done by going here: Login - LingQ
Copy your APIKey to Notepad or somewhere you can retrieve it easily. For the sake of example say your APIKey is ABC123 (in reality your specific APIKey will be a very large hexadecimal number comprised of a bunch of digits and any number of letters between a and f).
This APIKey will be used as a parameter in subsequent LingQ API calls. First you will want to see the codes for the languages you currently study.
In the address bar to your web browser put in this url: http://www.lingq.com/api_v2/languages/?format=xml&apikey=ABC123
Remember to put in your actual APIKey, not ABC123
You will see something that looks like this:
it
en
es
These are LingQs language codes for languages you are studying. In my example, we see the codes for Italian, English, and Spanish respectively.
Pick a language code that you have a good amount of LingQs for for use with this next example.
We are going to show you all of your LingQs for a specific language. For this example I will use “it” for Italian
In your web browser, put this url in the address bar: http://www.lingq.com/api_v2/it/lingqs/?format=xml&apikey=ABC123
Notice the segment /api_v2/it/lingqs of the url, here you must replace “it” with the language code of your choice, and remember to put in your proper APIKey.
You will see something that looks like this:
0
primario, accusato anche di truffa e falso, anche se
truffa
4073703
fraud, swindle, cheat, fiddle, do, racket, hoax
0
rimborsi e lui ne traesse «un vantaggio economico in
traesse
4073700
v. derive, draw, pull, get; take; bring
These are your LingQs listed in xml format, with various information about them, such as the LingQ’s id, so it can be referenced in other LingQ API messages.
Now that you have got your feet wet in the workings of RESTful APIs, you can go to the LingQ documentation page and play around with other things like getting lists of your lessons and lists of your LingQs per lesson. Neat eh?