Help get this topic noticed by sharing it on Twitter, Facebook, or email.

How can I filter the results from the Daylife API to a particular set of sources?

In other words, how can I use source filtering?
1 person has
this question
+1
Reply
  • The DayPI supports a mechanism we call source filtering as a means to limit API results to a specific set of sources, or to eliminate a specified set of sources from returned results.

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

    In general, source filters can contain either a white list, which ensures that returned results are limited to a specified set of results, or as a black list, which suppresses results from a particular set of sources from return data.

    In addition, 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 whether you're looking for a whitelist or a blacklist
    3. 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 blacklists sources that are direct competitors or whose viewpoints from which you wish to spare your readers. You could then build a page that shows news first from your publication, then from a sanitized set of 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/p...
    /4.4/search_getRelatedArticles?query=&start_time=2008-04-28&
    end_time=2008-05-05&sort=date&offset=&limit=10&source_filter_id=
    &accesskey=8befa1cf0a7c0291613242235638a662&
    signature=8a97d5179d6e7f0dbf263e64ddaec321



    Runtime Defined Source Filters

    Without waiting on us, you can specify a whitelist or blacklist 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, or exclude a particular set of sources from your results.

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


    source_whitelist=


    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/pu...

    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/pu...

    (0blKbZP140g1Z is the source_id for CNN)

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

    http://freeapi.daylife.com/xmlrest/pu...

    You can download the list of sources here - http://developer.daylife.com/node/178
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited sad, anxious, confused, frustrated indifferent, undecided, unconcerned kidding, amused, unsure, silly

  • what if I'm trying to call one of the source filters i established from the admin, how do i figure out what it's source_filter_id is??
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited sad, anxious, confused, frustrated indifferent, undecided, unconcerned kidding, amused, unsure, silly