Generative Design Variations M.6.2.1 The Wikipedia API

This is the first theoretical exercise of two which I need to complete to finish the last exercises of the Generative Design book. Here is a brief description of the Generative Design book: ‘In principle, all data that can be seen in a browser can also be loaded with another program and used for other purposes. If an HTML text from a web page is not required, but the data is needed in a more structured way, it is more convenient to have this information available in XML format. Luckily, this is now often the case. RSS feeds, for example, are a special XML format, and many Internet pages provide programming interfaces (so-called APIs) with which information in XML format can be specifically queried. The Wikipedia API offers a comprehensive programming interface that allows the user to both query the Wikipedia database and edit articles.’ Until here the summary of the Generative Design book. Here is the original program.
M_6_2_01

Getting data from the Internet is not new to me. I first came into contact with the Internet in 1992. I was working at Océ Research & Development. But I will not go into that any further because it is not relevant for this exercise. I usually download a text.csv or text.tsv file to use the data in data visualizations. But downloading data through an API I’ve never done before. So that is new to me.

The first thing I tried is to type in a URL from the Generative Design book https://en.wikipedia.org/w/api.php?action=query&prop=links&titles=Superegg Then I get a page-which is the HTML representation of the JSON format. Then I have the question: What is JSON format? JSON (JavaScript Object Notation) is a format for data exchange. JSON is based on a subset of the JavaScript programming language. JavaScript? Oh no … not again. I need XML. Anyway … JSON apparently has a lot of advantages. It is compact. People and computers can understand it easily. It maps easily to the data structures used by most programming languages (numbers, strings, booleans, nulls and arrays). Until so far, all known things. Another advantage is that almost all programming languages have features or libraries that can read or write JSON structures. That all sounds very promising. But I need XML to complete this exercise and JSON is apparently an alternative to XML. But JSON seems to be more compact and it is easier to read and write than XML. The point is now that if you’re not careful you’re ending up doing other things than completing this exercise. Then you’ll get on the path that leads to figuring out how JSON, PHP (Hypertext Pre-processor) and AJAX (Asynchronous JavaScript And XML) works. Or try Perl perhaps? So for the time being it seems not a good idea. So I stopped following that path and continued to study the https://www.mediawiki.org/wiki/API:Main_page. This is the introduction page for the Wikipedia API.

Back to the Generative Design program M_6_2_01.pde. This program is not working. If I run it I get a [Fatal Error]: 1: 1: Premature end of file in my console. But because I have studied the Wikipedia API I suspect that this error is caused because the start of the URL in the program begins with http://. And I think the right URL should be: https://. It needs the ‘s’. https is ‘Hyper Text Transfer Protocol’ with Secure Sockets Layer (SSL). This is another protocol primarily developed with secure, safe Internet transactions in mind. So when I correct that and let the program run then I get a neat list of 27 numbered links from Wikipedia Superegg page in my Processing console. So I think this problem is now solved. I also tried other pages by requesting Superegg replacing Superegg with Generative%20Design (The% 20 comes from percent-encoding a space). I have done the same with New%20York, Steve%20Jobs, Dada and Kurt%20Schwitters. And these URL’s all work fine. All links on those pages are neatly sorted in alphabetical order and displayed in my Processing console. I think that this exercise is over. Furthermore, there are no graphics or variations of the program involved.

Advertisements

Comments? Leave a reply.

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s