RkBlog

Hardware, programming and astronomy tutorials and reviews.

Using Guardian OpenPlatform API

Guardian Open Platform is a new API from The Guardian for accessing it's publications, news and articles

Guardian Open Platform is a new API from The Guardian for accessing it's publications, news and articles. API is just HTTP REST, so it's very easy to use. Currently in beta - so when you register your app you will have to wait few days to be activated. Using the API you can search and get articles publishen by Guardian and few other newspapers. There is interesting example of Google Wave robot that inserts search results (with Guardian publications) in a Wave.

OpenPlatform and Python

There is complete library openplatform-python, which covers all the API:
from guardianapi import Client

client = Client('Your API Key')
results = client.search(q = 'robert kubica')
print results.count()
for item in results:
	print item['headline']
	# content
	#print item['typeSpecific']['body']
	print
Which will return articles matching query term - "Roberta Kubicy":
Japanese grand prix - as it happened

Bahrain grand prix - as it happened

European grand prix - live

Chinese grand prix lap-by-lap - as it happened

Barcelona grand prix - as it happened

Malaysian grand prix - as it happened

Kubica off the pace but fast enough

Breakthrough for Kubica but the pits for Hamilton

Breakthrough for Kubica but the pits for Hamilton

Kubica announces his arrival as championship contender
More examples can be found on the library website.

OpenPlatform and PHP

There is similar library openplatform-php that allows PHP scripts to easily use the API. There is an example in the library package.
RkBlog

Python programming, 13 October 2009,

Comment article