Article Retrieval Service#
When enabled along with all other Factiva Analytics APIs, this service allows to retrieve content for display purposes when end users need to read the underlying content from a calculated score or derived datapoint after processing Snapshots or Streams news articles.
ArticleRetrieval#
- class factiva.analytics.article_retrieval.article_retrieval.ArticleRetrieval(oauth_user: OAuthUser | None = None)#
Allows to fetch articles against the Article Retrieval Service using the provided OAuthUser credentials.
- Parameters:
oauth_user (OAuthUser) – An instance of an OAuthUser with working credentials. If not provided the user instance is created automatically from ENV variables.
Examples
Create an ArticleRetrieval instance.
from factiva.analytics import ArticleRetrieval ar = ArticleRetrieval() ar
<class 'factiva.analytics.article_retrieval.article_retrieval.ArticleRetrieval'> |-oauth_user: <class 'factiva.analytics.auth.oauthuser.OAuthUser'> | |-client_id = fbwqyORz0te484RQTt0E7qj6Tooj4Cs6 | |-token_status = OK | |-...
- oauth_user = None#
User instance wich provides the credentials to connect to the Article Retrieval API endpoints.
- retrieve_single_article(an: str) dict #
Method that retrieves a single article to be displayed in a user interface. The requested item is initially retrieved from the . Additionally, the retrieved data is stored in the class atttribute
last_retrieval_response
.- Parameters:
an (str) – String containing the 32-character long article ID (AN). e.g. WSJO000020221229eict000jh
- Returns:
Python dict containing full articles’ data. This will be replaced when the
UIArticle
class is implemented.- Return type:
dict
Examples
Creating a new
ArticleRetrieval
instance which reads credentials values from environment variables and retrieves a single article:from factiva.analytics import ArticleRetrieval ar = ArticleRetrieval() article = ar.retrieve_single_article(an='WSJO000020221229eict000jh') article
output
<class 'factiva.analytics.article_retrieval.article_retrieval.UIArticle'> |-an: WSJO000020221229eict000jh |-headline: Europe Taps Tech's Power-Hungry Data Centers to Heat Homes. |-source_code: WSJO |-source_name: The Wall Street Journal Online |-publication_date: 2022-12-29 |-metadata: <dict> - [4] keys |-content: <dict> - [19] keys |-included: <list> - [0] items |-relationships: <dict> - [0] keys
- Raises:
PermissionError – If the user doesn’t have access to the requested content
UIArticle#
- class factiva.analytics.article_retrieval.article_retrieval.UIArticle(article_dict: dict)#
Class that represents a single article for visualization purposes. Methods and attributes are tailored for front-end environments.
- Parameters:
article_dict (dict) – A python dict with the structure returned by the Dow Jones Article Retrieval service.
Examples
See ArticleRetrieval class examples.
- an = None#
Article unique identifier, also known as Accession Number
- content = {}#
Article’s content dict. Full text with annotations and other UI elements.
- headline = None#
Article’s headline, also known as title
- included = []#
References to objects linked to a specific article
- metadata = {}#
Article’s metadata dict. Contains Dow Jones Intelligent Identifiers among other codes.
- publication_date = None#
Article’s publication date in ISO format as provided by the source. e.g. ‘2022-12-03’
- relationships = {}#
References to related objects
- source_code = None#
Article content creator’s code. e.g. WSJO
- source_name = None#
Article content creator’s name. e.g. The Wall Street Journal Online