SEARCH

// developer.daylife.com


Using Source Filtering

The DayPI supports a mechanism we call source filtering as a means to limit API results to a specific set of sources

This recipe describes the two existing methods for invoking source filters in DayPI calls.

Source filters can be defined in two ways: as a predefined set or as a runtime defined set , which you provide in the context of your DayPI call.

 

Predefined Source Filters

In the currently available production version of the DayPI, Daylife must set up a predefined source filter for you.

Predefined source filters are defined per access key; only you will be able to access a source filter defined for you.

The mechanism is straightforward, and is initiated with an email to us that includes the following information:

  1. Include your API key
  2. Specify a set of sources you'd like included in your filter, as a list of Daylife sourceID's and source names.

We'll set up the source filter on our end, and return to you a source filter ID that you can add to your DayPI calls to achieve the filtering you've defines.

You can have several source filters going at once, each of which you can choose to invoke at appropriate points in your code. For instance, if you're building an application for a newspaper, you might build a source filter that whitelists only your publication, then another that whitelists sources that are your sister publications. You could then build a page that shows news first from your publication, your partner sources and sources from around the web.

You invoke a predefined sourcefilter by including it as a parameter in your DayPI call.

http://freeapi.daylife.com/jsonrest/publicapi/4.4/search_getRelatedArticles?query=&start_time=2008-04-28&end_time=2008-05-05&sort=date&offset=&limit=10&source_filter_id=<sourcefilterid>=&accesskey=8befa1cf0a7c0291613242235638a662&signature=8a97d5179d6e7f0dbf263e64ddaec321

 

Runtime Defined Source Filters

Without waiting on us, you can specify a whitelist for sources at runtime by using on-the-fly source filters.

Using an on-the-fly source filter, you can limit the returned results to a set of sources in your results.

You can put an on-the-fly source filter in place by adding a parameter to your call:

source_whitelist=<sourcename | sourceID>

For instance, the following call gets the past week’s worth of CNN articles that match the search term “Iraq”:

http://freeapi.daylife.com/xmlrest/publicapi/4.4/search_getRelatedArticles?source_whitelist=cnn&query=iraq&start_time=2008-04-25&end_time=2008-05-02&sort=date&offset=&limit=10&source_filter_id=&include_image=&include_scores=&accesskey=8befa1cf0a7c0291613242235638a662&signature=6ed7dcd9cd026fd34e477b03f5c66b47

Note that if you use a source name for the source_whitelist value, you need to match the name we use directly. A completely reliable way to get results from a particular publication is to use that source’s source_id:

http://freeapi.daylife.com/xmlrest/publicapi/4.4/search_getRelatedArticles?source_whitelist=0blKbZP140g1Z&query=iraq&start_time=2008-04-25&end_time=2008-05-02&sort=date&offset=&limit=10&source_filter_id=&include_image=&include_scores=&accesskey=8befa1cf0a7c0291613242235638a662&signature=6ed7dcd9cd026fd34e477b03f5c66b47

(0blKbZP140g1Z is the source_id for CNN)

If you wish to have several sources in your filter, specify the source_whitelist multiple times. For instance:

http://freeapi.daylife.com/xmlrest/publicapi/4.4/search_getRelatedArticles?source_whitelist=cnn&source_whitelist=gawker&query=iraq&start_time=2008-04-25&end_time=2008-05-02&sort=date&limit=10&accesskey=8befa1cf0a7c0291613242235638a662&signature=6ed7dcd9cd026fd34e477b03f5c66b47

You can download the list of sources here.