The BBC News Labs Juicer API let you run queries on content from an increasing list of over news sources which includes BBC News but also other publications like Sky News, The Guardian, The Mirror, The Independent, The Daily Record, The Huffington Post and other media. It also includes content from other sources, including the BBC News and BBC Parliament TV channels and MP's Twitter accounts.
The majority of content is in the form of articles from news organisations but there are also images, video and tweets from select sources.
Data about content from other sources - including the BBC News video and image archives - is also held in the Juicer but is not be avalible outside of the BBC network. This content will not normally be surfaced when using this library.
The APIs exposed by this library include an interface to an Elastic Search powered database and our Triplestore Semantic Data platform.
We get our Linked Data concepts (aka tags) from DBPedia.org, which in turn is derived from Wikipedia data. You can see an example of how this entity extraction works at:
The tagging is fully automated and consequently isn't 100% accurate.
The Juicer is not a production system or an offical BBC production service; it's an experimental platform for research and development - availability or suitability for any particular purpose is not guaranteed.
This API may be suspended, changed or disabled without prior notice at any time. The API evolves and changes over time and should not be considered stable!
The BBC News Labs Juicer API is are experimental and are chiefly intended for use by R&D teams in news organisations and universities. If you'd like to more more or have any feedback about them, please get in touch with @BBC_News_Labs via Twitter.
You can get a list of sources the Semantic API knows about with
var newsQuery = ;newsQuery;
The response is an array of objects with
name: 'Sky News'uri: ''name: 'The Guardian'uri: ''...
A simple query to get started is to search articles using a keyword search.
This doesn't actually invoke the BBC News Labs Linked Data platform directly (instead it triggers calls to an Elastic Search powered endpoint), but does return articles along with entities which you can use in Linked Data queries.
The response for a matching query will return articles, with titles, descriptions, the organisation that published it, the URL for the article and a list of concepts the article was tagged with (including the URI's for each concept, what type of object the concept is and the "confidence score" for each concept that the article has been tagged with).
You can optionally specify a date range if you are only interested in articles published on or around specific date:
You can use the ID for the article and one of the additional queries API calls documented to pull back full data (tags, summary, etc.) for the article.
Note that unlike the other API endpoints only text articles (not images or video) from the following sources are currently returned by this method:
If you have an article ID from any of the searches or calls below you can search for other, similar article using getSimilarArticles().
The article ID value usually the property labeled
cps_id and is a string (in some cases it might look like an integer but that's not true for all cases, so it should be treated like a string).
If you have an article from an external source you can search for articles from other publications that are similar to the article you already have):
You need to get a definitive URI for a concept before you can search the BBC News Labs Linked Data platform for articles that mention that concept.
A concept is typically a person, place, organisation or theme (e.g. "law", "economics", "gravity", "policy"). These correspond to entries in dbpedia, which uses an ontology derived from data in Wikipedia.
An example that returns the first 5 concepts matching the term "Rooney":
The response from getConcepts() is an array of concepts, each with a unique URI (and possibly an image).
Note in the example below 'Wayne Rooney' is a SoccerPlayer, and SoccerPlayers are Athletes, and Athletes are People.
Mickey Rooney is classed as a Person, although it has not specifically identified him as an Actor - the granularity of the specificity may vary from concept to concept.
NB: An 'Agent', which is as the last type for both, is simply a top level ontology class associated with all People and Organisations (and does not refer to an individial as being sports or acting agent). In this context an 'Agent' is a thing that acts in the world, for example, as distinct from something that is an Activity or a Place.
name: 'Wayne Rooney'uri: ''image: ''type:''''''''name: 'Mickey Rooney'uri: ''image: ''type:''''
If you have the definitive URI for a concept you can use it's URI to request detailed information about a concept, such as a description and it's type.
e.g. You can check the "type" field to see if it's categorized as a Person, Place, Organisation, etc (you can also check for more specific types, like SoccerPlayer or Company).
Note that calling getConcept() explicitly on a URI may return more specific type information than is returned along with a concept in other calls, such as getArticlesByConcept().
The response is a single object, with a description and additional metadata, typically an image, and at least one article about the subject (you can specify more via the second parameter to the function).
description: 'David William Donald Cameron is the Prime Minister of the United Kingdom, First Lord of the Treasury, Minister for the Civil Service and Leader of the Conservative Party. He represents Witney as its Member of Parliament (MP). Cameron studied Philosophy, Politics and Economics (PPE) at Oxford, gaining a first class honours degree. He then joined the Conservative Research Department and became Special Adviser to Norman Lamont, and then to Michael Howard.'articles:product: ''summary: 'The UK Independence Party has stormed to victory in the European elections and unleashing a political whirlwind in Britain.'title: 'Farage throws down gauntlet as Ukip unleashes whirlwind'article: ''cpsid: 'irish_independant_7ddba5bc3c79dca7f45714c782c73e61625d8b85'published: '2014-05-27T01:30:00Z'thumbnail: ''name: 'David Cameron'type:''''''uri: ''
You can fetch concepts that - by being linked through news articles - are linked to a given concept. For example, to get concepts related to "Ukraine":
The response from getCoOccuringConcepts() is an array of concepts, returned in order of how many co-occurrences there are between the concepts.
i.e. how much times both concepts have been mentioned in the same article, tagged in one image, mentioned in a video, etc.
name: 'Russia'uri: ''occurrences: 9530image: ''
You can also optionally specify:
types(as a string, or array of strings) of object to get (e.g. "http://www.bbc.co.uk/ontologies/bbc/Person", "http://www.bbc.co.uk/ontologies/bbc/Company" etc.)
For example the following query would return the top 10 people Sky News mentioned in stories that related to the Ukraine.
Once you have the URI for a concept, you can use it to find news articles mentioning it. You can specify a single concept URI or an array of URIs.
Example response from getArticlesByConcept() is shown below.
Note that the response includes quite high level type information for each concept, but it does return the latitude and longitude values for concepts that are identified as places.
This is an example of slightly inconsistent behaviour between function calls - as lat/lon values are not returned for Places by any other calls. This is something we are looking at to see if we can improve.
id: 'the_huffington_post_a819bb600f1a3c9d11a2a635e528f972ab241751'source: ''url: ''dateCreated: '2014-05-27T11:49:15Z'title: 'Tony Blair Defends Immigration And EU, Says Ukip \'Do Not Have All The Answers\''description: 'Tony Blair has moved to unite the left against Ukip in his strongest attack yet against Nigel Farage and the eurosceptic party. \n \nThe former prime minister, who is still reviled by many left-wingers over his decision to invade Iraq in 2003, said Ukip did "not have all the answers" and should be exposed for having "no actual solutions to the problems of the 21st century". \n \nBlair, 61, told BBC Radio 4\'s Today programme that blaming immigrants for problems is a "backwards and regressive ste...'image: ''concepts:name: 'Brussels'uri: ''image: ''type: ''lat: '50.85'lon: '4.35'name: 'David Cameron'uri: ''image: ''type:''''name: 'Great Britain'uri: ''image: ''type: ''lat: '53.826'lon: '-2.422'name: 'BBC Radio 4'uri: ''image: ''type:''''name: 'Ed Miliband'uri: ''image: ''type:''''name: 'Nick Clegg'uri: ''image: ''type:''''name: 'Alan Milburn'uri: ''image: ''type:''''name: 'Israeli Labor Party'uri: ''image: '(Israel)_logo.png/200px-Labor_(Israel)_logo.png'type:''''name: 'Iraq'uri: ''image: ''type: ''lat: '33.333333333333336'lon: '44.43333333333333'name: 'Tony Blair'uri: ''image: ''type:''''name: 'Nigel Farage'uri: ''image: ''type:''''name: 'Diane Abbott'uri: ''image: ''type:''''name: 'UK Independence Party'uri: ''image: ''type:''''name: 'The Huffington Post'uri: ''image: ''type:''''name: 'Europe'uri: ''image: ''type: ''name: 'Conservative Party (UK)'uri: '(UK)'image: ''type:''''name: 'Labour Party (UK)'uri: '(UK)'image: ''type:''''name: 'John Hutton, Baron Hutton of Furness'uri: ''image: ''type:''''name: 'Owen Jones (writer)'uri: '(writer)'image: ''type:''''
You can query how many occurrences there are for a given concept between a series of dates, the startDate and endDate can be up to a year apart.
If you don't specify a startDate or an endDate (both should be strings in the form 'YYYY-MM-DD') then the current date will be used for either value.
The response from getConceptOccurrencesOverTime() is an array of objects with 'date' and 'value' keys, in order of oldest to most recent.
date: '2014-05-24' value: 5date: '2014-05-25' value: 13date: '2014-05-26' value: 28date: '2014-05-27' value: 17date: '2014-05-28' value: 9
If you want to filter by a specific source, you can specify a source URI - from the list returned by
getSources() - as an optional 4th parameter.
The below example shows how to get the number of articles related to Russia that appeared in The Guardian in the last 7 days:
var moment = ;newsQuery;
Note: You can request dates up to a year apart. The bulk of the data goes back over 6 months, we are still in the progress of adding sources.
You can find full information about how the raw BBC News Labs Juicer APIs work on the #newsHACK site:
The Semantic News Labs API: http://newshack.co.uk/newshack-ii/newslabs-apis/
The News Juicer API: http://newshack.co.uk/newshack-ii/juicer-apis/
Note that the formats of the responses may differ if using the raw APIs, this module attempts to simplify them to make them easier to consume.
Pull requests, feature requests and bug reports are welcome!
To run tests just run
> npm test