Getting the Content API in RSS/ATOM format using Yahoo Pipes

351 views
Skip to first unread message

Michael Brunton-Spall

unread,
Dec 1, 2010, 1:10:53 PM12/1/10
to Guardian API Talk
Hey all,

We've had a couple of queries about whether it's possible to access the content API in ATOM or RSS format, and I thought I'd share with you all the ways that we are using to do so.

We currently use the Content API and Yahoo Pipes to drive some of our twitter feeds.  The reason for this is that twitter accounts such as @guardiannews tweet everything that is included in the news tag.  But followers have pointed out that there is a lot of duplication between the news tweets and sections like football, technology and media, all of which have their own specific twitter accounts.
We couldn't use the standard RSS feeds from the guardian to exclude content from certain sections, so instead we use the content api to build up a much more complex query, for example for the guardian media we use a query like this: http://explorer.content.guardianapis.com/#/search?tag=-tone%2Fletters%2C+-tone%2Fobituaries%2C+-media%2Fgreenslade&section=media&order-by=newest&format=json&show-fields=shortUrl
which selects all articles in date order that are in the media section, but with any content that has the tone/letters, tone/obituaries and media/greenslade tags applied to it removed from the results.

This gives us back a JSON object that we could then parse nicely.

However, our twitter feed bots don't accept our API as an input, like many online systems they accept RSS feeds, and the Content API doesn't have an RSS or ATOM format available.  So at this point we turn to Yahoo Pipes as a simple Json to RSS converter.


As you can see, I've started with a Url Builder and Text Input, so that you can specify your API key.  I've hard coded the query parameters for now, but I'm sure you can imagine it's very easy to hook in a number of Text Input boxes for each query parameter.  We've also used before a single Text Input that contains the content api url to hit.

If you click on the title box of the Url Builder, at the bottom of the page, after a short delay should appear the build url, in this case http://content.guardianapis.com/search?format=json&order-by=newest&tag=tone/reviews&show-fields=shortUrl&api-key=

If you want the debugging to work, you will ahve to enter your api key into the debug field of the API key text field, since the URL above is invalid and returns an error.  Once you've done that, you can click on the Fetch Data box, which is the next step.  This should show you the results json broken down into a nice tree for you.
We pipe the results data into the Create RSS box, and we have to tell the RSS generator where to get the required RSS fields from.  The drop downs should make this fairly easy, you can select item.webTitle for title, or you could select item.fields.headline to select the headline for example.  In this case we want a very simple RSS feed, so we only fill in the Title, Link and PubDate fields.


Hopefully this has helped you if you wanted an RSS feed from the content api, which should help you integrate the API into other tools and applications.
Don't forget that using the API in this manner still requires that you follow the terms and conditions in the same way as if you had built a custom integration.

Michael Brunton-Spall
Developer Advocate
guardian.co.uk
Please consider the environment before printing this email.
------------------------------------------------------------------
Visit guardian.co.uk - newspaper website of the year
www.guardian.co.uk  www.observer.co.uk

To save up to 33% when you subscribe to the Guardian and the Observer
visit http://www.guardian.co.uk/subscriber

---------------------------------------------------------------------

This e-mail and all attachments are confidential and may also
be privileged. If you are not the named recipient, please notify
the sender and delete the e-mail and all attachments immediately.
Do not disclose the contents to another person. You may not use
the information for any purpose, or store, or copy, it in any way.

Guardian News & Media Limited is not liable for any computer
viruses or other material transmitted with or as part of this
e-mail. You should employ virus checking software.

Guardian News & Media Limited

A member of Guardian Media Group plc
Registered Office
PO Box 68164
Kings Place
90 York Way
London
N1P 2AP

Registered in England Number 908396

Reply all
Reply to author
Forward
0 new messages