python sample code for rdp api fetching news analytics

Hi team, where can i find sample python code to fetch news analytics from RDP using rdp api? I'm also confused about the python library since we have refinitiv.dataplatform, refinitiv.data and refinitiv.data-platform, which is the correct one for rdp api? And do we have detailed tutorial regarding the fileds for all commands? Thank you.

Best Answer

Answers

  • Hello @Julian.Bai

    Thank you for reaching out to us. Firstly, please let me clarify the RDP APIs questions as follow:

    • The Refinitiv Data Platform APIs (RDP APIs) are the core web-based APIs that provide Refinitiv content via the Request-Response (RESTful web service), Alert, Bulk, and Streaming delivery methods
    • The Refinitiv Data Libraries (RD Library)are ease-of-use libraries that simplified RDP APIs via high-level API interfaces. It is the strategic library and is available for Python (Production ready), TypeScript (beta phase), and .Net (beta phase)languages
    • The refinitiv.data-platform library is the non-strategic RDP ease-of-use library. It has been replaced by RD Library above

    The recommended APIs are the core RDP APIs or RD Library based on your preference whether you need a manual HTTP operation/management or the ease-of-use API.

    About the MRN News Analytics, I cannot find the related News Analytics endpoints on the https://apidocs.refinitiv.com/Apps/ApiDocs (RDP APIs document) page.

    rdp-news.png

    There is the Exploring News Metadata - with Refinitiv Data Platform and Python article about getting RDP News's metadata, I am not sure it is the thing you want.

    The News Analytics is available on the Refinitiv Real-Time platform. There is the Refinitiv Real-Time WebSocket API Python example/article on How to get MRN News Analytics Data via WebSocket API page.

    I hope this information helps.

  • Hi Wasin, thanks for the info. My client is just single user so which one is more easier and requires less dev work? Thank you.

  • Hi Wasin, let me check and may reply you later. Thank you!
  • When seeking assignment writing assistance in the UK, it is crucial to select the best assignment writers who can deliver high-quality work and meet your academic requirements. With numerous services available, choosing the right one can be a daunting task. This article provides a guide to help you make an informed decision when selecting the write my assignment in the UK. We will explore key factors to consider, ensuring you receive exceptional service and top-notch assignments.


  • import requests

    # Set up API credentials and endpoint

    api_key = 'YOUR_API_KEY'

    api_secret = 'YOUR_API_SECRET'

    api_endpoint = '


    # Set up request headers with authentication

    headers = {

    'Content-Type': 'application/json',

    'X-api-key': api_key,

    'X-api-secret': api_secret

    }


    # Set up request parameters

    params = {

    'query': 'YOUR_SEARCH_QUERY',

    'count': 10 # Number of news analytics results to retrieve

    }


    # Send GET request to the API endpoint

    response = requests.get(api_endpoint, headers=headers, params=params)


    # Check if the request was successful (status code 200)

    if response.status_code == 200:

    # Parse the JSON response

    data = response.json()


    # Process the retrieved news analytics data

    for result in data['data']:

    # Access and print relevant information

    title = result['title']

    sentiment = result['sentiment']

    relevance = result['relevance']

    print(f"Title: {title}")

    print(f"Sentiment: {sentiment}")

    print(f"Relevance: {relevance}")

    print("----------------------")


    else:

    print(f"Error: {response.status_code} - {response.text}")

    Remember to replace 'YOUR_API_KEY', 'YOUR_API_SECRET', and 'YOUR_SEARCH_QUERY' with your actual RDP API credentials and the desired search query for news analytics. This code sends a GET request to the RDP API endpoint, retrieves the news analytics data, and prints the title, sentiment, and relevance of each news result to the website development solution.