“Everything should be made as simple as possible, but not simpler.” A. Einstein
It is not that much I started tinkering about WordPress, and they publish a very interesting API for the site.
Following a well-established path, the site is a REST one. I would like to develop some code around it.
For now I show a very little snippet, in Python:
f = urllib2.urlopen('http://public-api.wordpress.com/rest/v1/sites/33534099/posts/43/?pretty=true/')
If you own a nice copy of Python on your PC (that I warmly suggest), you can just call it with the simple
command. In the python environment you can then copy and paste the previous snippet, a row at a time, or you can create a file and make python execute it.
The result is a JSON description of data. What is Jason? We’ll see sooner or later: for now, let’s define it as a means to describe an object in a very direct manner.
For today please just observe the REST-ivity 🙂 of the call. If you look at the URL, you can clearly understand the structure of the request: it is a hierarchical description of something you want to GET.
It’s not by chance I am using the word “GET”: with REST you return to the very beginning of HTTP, (W3C specs) using just GET, POST, DEL and (guess!) PUT as basic verbs. Talking deeply about that would take us very far, for the moment let’s admire the clarity of the call.