Skip to main content

Python package to interact with Factiva Analytics APIs. Services are described in the Dow Jones Developer Platform.

Project description

https://github.com/dowjones/factiva-analytics-python/actions/workflows/master_test_publish.yml/badge.svg

This library simplifies the integration to Factiva Analytics API services that delivers premium news content.

The following services are currently implemented.

  • auth: Contains tools to handle UserKey authentication and account statistics.

  • Snapshots: Allows to run each snapshot creation, monitoring, download and local exploration, in an individual manner. Also allows to run the whole process within a single method.

  • Streams: In addition to creating and getting stream details, contains the methods to easily implement a stream listener and push the content to other locations appropriate for high-available setups.

  • Taxonomy: Operations that return taxonomies applied to classify news content.

Installation

To install this library, run the following commands.

$ pip install --upgrade factiva-analytics

Using Library services

Most Factiva Analytics services are implemented in this library. There may be a delay (commonly weeks) when new features are released and their operations are implemented in this package.

Creating a User Instance and Getting its statistics

Create UserKey instance and retrieve a summary of the account statistics.

from factiva.analytics import UserKey
u = UserKey(
    key='abcd1234abcd1234abcd1234abcd1234',  # Not needed if the ENV variable FACTIVA_USERKEY is set
    stats=True)  # Connects to the API and pulls the latest account status
print(u)
<class 'factiva.core.userkey.UserKey'>
|-key = ****************************1234
|-cloud_token = **Not Fetched**
|-account_name = AccName1234
|-account_type = account_with_contract_limits
|-active_products = DNA
|-max_allowed_concurrent_extractions = 5
|-max_allowed_extracted_documents = 200,000
|-max_allowed_extractions = 3
|-currently_running_extractions = 0
|-total_downloaded_bytes = 7,253,890
|-total_extracted_documents = 2,515
|-total_extractions = 1
|-total_stream_instances = 4
|-total_stream_subscriptions = 1
|-enabled_company_identifiers = [{'id': 4, 'name': 'isin'}, {'id': 3, 'name': 'cusip'}, {'id': 1, 'name': 'sedol'}, {'id': 5, 'name': 'ticker_exchange'}]
|-remaining_documents = 197,485
|-remaining_extractions = 2

Snapshots

Create a new snapshot and download to a local repository just require a few lines of code.

from factiva.analytics import Snapshot
my_query = "publication_datetime >= '2020-01-01 00:00:00' AND LOWER(language_code) = 'en'"
my_snapshot = Snapshot(
    user_key='abcd1234abcd1234abcd1234abcd1234',  # Can be ommited if exist as env variable
    query=my_query)
my_snapshot.process_extract()  # This operation can take several minutes to complete

After the process completes, the output files are stored in a subfolder named as the Extraction Job ID.

In the previous code a new snapshot is created using my_query as selection criteria and user_key for user authentication. After the job is being validated internally, a Snapshot Id is obtained along with the list of files to download. Files are automatically downloaded to a folder named equal to the snapshot ID, and contents are loaded as a Pandas DataFrame to the variable news_articles. This process may take several minutes, but automates the extraction process significantly.

Streams

Create a stream instance and get the details to configure the stream client and listen the content as it is delivered.

from factiva.analytics import Stream

stream_query = Stream(
    user_key='abcd1234abcd1234abcd1234abcd1234',   # Can be ommited if exist as env variable
    user_key_stats=True,
    query="publication_datetime >= '2021-04-01 00:00:00' AND LOWER(language_code)='en' AND UPPER(source_code) = 'DJDN'",
    )

print(stream_query.create())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

factiva-analytics-0.3.0.tar.gz (41.0 kB view details)

Uploaded Source

Built Distribution

factiva_analytics-0.3.0-py3-none-any.whl (50.2 kB view details)

Uploaded Python 3

File details

Details for the file factiva-analytics-0.3.0.tar.gz.

File metadata

  • Download URL: factiva-analytics-0.3.0.tar.gz
  • Upload date:
  • Size: 41.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for factiva-analytics-0.3.0.tar.gz
Algorithm Hash digest
SHA256 e988be2e862d8476dd29124cc29426371a2116e4430fe75d4314d1c9ecfd4d2d
MD5 aba6daf2d1d840b67edaa8017d9d1d72
BLAKE2b-256 2892b27e103d21f6c6f447740c1ffa56a0107508134085a92284683501fdbfba

See more details on using hashes here.

File details

Details for the file factiva_analytics-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for factiva_analytics-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 015d7fdfc609a1a3c390f77905be3d8178eb31af64fcb358fbc91757943e73bf
MD5 9cea7737b399ed900fe0f69c6862a31e
BLAKE2b-256 218cd0bf24fa46a15df941502efe4b806fd4a0856dc6757f39b1b4f2650a97aa

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page