Skip to content

Latest commit

 

History

History
158 lines (109 loc) · 5.14 KB

README.md

File metadata and controls

158 lines (109 loc) · 5.14 KB

worldnewsapi

The World News API gives you access to thousands of news sources in over 50 languages from over 150 countries. News are semantically tagged allowing for semantic news search like never before.

This is the python-package for easy acccess to the api.

  • API version: 1.2.0
  • Package version: 1.2.0

Resources

Requirements

Python 3.7+

Installation & Usage

pip install

This package is hosted on PyPi, you can install directly using:

pip install worldnewsapi

(you may need to run pip with root permission: sudo pip install worldnewsapi)

Then import the package:

import worldnewsapi

Setuptools

Install via Setuptools.

python setup.py install --user

(or sudo python setup.py install to install the package for all users)

Then import the package:

import worldnewsapi

Tests

Execute pytest to run the tests.

Getting Started

Please follow the installation procedure and then run the following:

import worldnewsapi
from worldnewsapi.rest import ApiException
from pprint import pprint

# Defining the host is optional and defaults to https://api.worldnewsapi.com
# See configuration.py for a list of all supported configuration parameters.
configuration = worldnewsapi.Configuration(
    host = "https://api.worldnewsapi.com"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure API key authorization: apiKey
configuration.api_key['apiKey'] = os.environ["API_KEY"]

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['apiKey'] = 'Bearer'

# Configure API key authorization: headerApiKey
configuration.api_key['headerApiKey'] = os.environ["API_KEY"]

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['headerApiKey'] = 'Bearer'


# Enter a context with an instance of the API client
with worldnewsapi.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = worldnewsapi.NewsApi(api_client)
    url = 'https://www.bbc.com/news/world-us-canada-59340789' # str | The url of the news.
    analyze = true # bool | Whether to analyze the news (extract entities etc.)

    try:
        # Extract News
        api_response = api_instance.extract_news(url, analyze)
        print("The response of NewsApi->extract_news:\n")
        pprint(api_response)
    except ApiException as e:
        print("Exception when calling NewsApi->extract_news: %s\n" % e)

Documentation for API Endpoints

All URIs are relative to https://api.worldnewsapi.com

Class Method HTTP request Description
NewsApi extract_news GET /extract-news Extract News
NewsApi extract_news_links GET /extract-news-links Extract News Links
NewsApi get_geo_coordinates GET /geo-coordinates Get Geo Coordinates
NewsApi news_website_to_rss_feed GET /feed.rss News Website to RSS Feed
NewsApi retrieve_news_articles_by_ids GET /retrieve-news Retrieve News Articles by Ids
NewsApi search_news GET /search-news Search News
NewsApi top_news GET /top-news Top News

Documentation For Models

Documentation For Authorization

Authentication schemes defined for the API:

apiKey

  • Type: API key
  • API key parameter name: api-key
  • Location: URL query string

headerApiKey

  • Type: API key
  • API key parameter name: x-api-key
  • Location: HTTP header

Author

mail@worldnewsapi.com