Skip to main content

Python library for newsdata client-API Call

Project description

Alt text

NewsData.io Python Client

newsdataapi allows you to create a library for accessing http services easily, in a centralized way. An API defined by newsdataapi will return a JSON object when called.

Build Status License PyPI Supported Python versions Python


Installation

Supported Python Versions

Python >= 3.5 fully supported and tested.

Install Package

pip install newsdataapi

Quick Start

Newsdataapi docs can be seen here.


Latest News API

GET /1/news

from newsdataapi import NewsDataApiClient

# API key authorization, Initialize the client with your API key
api = NewsDataApiClient(apikey="API key")

# You can pass empty or with request parameters {ex. (country = "us")}
response = api.news_api()

API key : Your private Newsdata API key.

country : You can pass a comma seperated string of 2-letter ISO 3166-1 countries (maximum 5) to restrict the search to. Possible Options: us gb in jp ae sa au ca sg

category : A comma seperated string of categories (maximum 5) to restrict the search to. Possible Options: top, business, science, technology, sports, health, entertainment

language : A comma seperated string of languages (maximum 5) to restrict the search to. Possible Options: en, ar, jp, in, es, fr

domain : A comma seperated string of domains (maximum 5) to restrict the search to. Use the /domains endpoint to find top sources id.

q : Keywords or phrases to search for in the news title and content. The value must be URL-encoded. Advance search options: Search Social q=social, Search "Social Pizza" q=social pizza, Search Social but not with pizza. social -pizza q=social -pizza, Search Social but not with pizza and wildfire. social -pizza -wildfire q=social -pizza -wildfire, Search multiple keyword with AND operator. social AND pizza q=social AND pizza

qInTitle : Keywords or phrases to search for in the news title only.

page : Use this to page through the results if the total results found is greater than the page size.


News Archive API

GET /1/archive

from newsdataapi import NewsDataApiClient

# API key authorization, Initialize the client with your API key
api = NewsDataApiClient(apikey="API key")

# You can pass empty or with request parameters {ex. (country = "us")}
response = api.archive_api()

API key : Your private Newsdata API key.

country : You can pass a comma seperated string of 2-letter ISO 3166-1 countries (maximum 5) to restrict the search to. Possible Options: us gb in jp ae sa au ca sg

category : A comma seperated string of categories (maximum 5) to restrict the search to. Possible Options: top, business, science, technology, sports, health, entertainment

language : A comma seperated string of languages (maximum 5) to restrict the search to. Possible Options: en, ar, jp, in, es, fr

domain : A comma seperated string of domains (maximum 5) to restrict the search to. Use the /domains endpoint to find top sources id.

from_date : A date and optional time for the oldest article allowed. This should be in ISO 8601 format (e.g. 2021-04-18 or 2021-04-18T04:04:34)

to_date : A date and optional time for the newest article allowed. This should be in ISO 8601 format (e.g. 2021-04-18 or 2021-04-18T04:04:34)

q : Keywords or phrases to search for in the news title and content. The value must be URL-encoded. Advance search options: Search Social q=social, Search "Social Pizza" q=social pizza, Search Social but not with pizza. social -pizza q=social -pizza, Search Social but not with pizza and wildfire. social -pizza -wildfire q=social -pizza -wildfire, Search multiple keyword with AND operator. social AND pizza q=social AND pizza

qInTitle : Keywords or phrases to search for in the news title only.

page : Use this to page through the results if the total results found is greater than the page size.


News Sources API

GET /1/sources

from newsdataapi import NewsDataApiClient

# API key authorization, Initialize the client with your API key
api = NewsDataApiClient(apikey="API key")

# You can pass empty or with request parameters {ex. (country = "us")}
response = api.sources_api()

API key : Your private Newsdata API key.

country : Find sources that display news in a specific country. Possible Options: us gb in jp ae sa au ca sg

category : Find sources that display news of this category. Possible Options: top, business, science, technology, sports, health, entertainment

language : Find sources that display news in a specific language. Possible Options: en, ar, jp, in, es, fr


Crypto News API

GET /1/crypto

from newsdataapi import NewsDataApiClient

# API key authorization, Initialize the client with your API key
api = NewsDataApiClient(apikey="API key")

# You can pass empty or with request parameters {ex. (country = "us")}
response = api.crypto_api()

API key : Your private Newsdata API key.

country : You can pass a comma seperated string of 2-letter ISO 3166-1 countries (maximum 5) to restrict the search to. Possible Options: us gb in jp ae sa au ca sg

language : A comma seperated string of languages (maximum 5) to restrict the search to. Possible Options: en, ar, jp, in, es, fr

domain : A comma seperated string of domains (maximum 5) to restrict the search to. Use the /domains endpoint to find top sources id.

q : Keywords or phrases to search for in the news title and content. The value must be URL-encoded. Advance search options: Search Bitcoin q=bitcoin Search "Bitcoin Ethereum" q=bitcoin ethereum Search Bitcoin but not with Ethereum q=bitcoin -ethereum Search Bitcoin but not with Ethereum and Dogecoin bitcoin -ethereum -dogecoin q=bitcoin -ethereum -dogecoin Search multiple keyword with AND operator bitcoin AND ethereum q=bitcoin AND ethereum .

qInTitle : Keywords or phrases to search for in the news title only.

page : Use this to page through the results if the total results found is greater than the page size.


News API with Pagination

GET /1/news

from newsdataapi import NewsDataApiClient

# API key authorization, Initialize the client with your API key
api = NewsDataApiClient(apikey="API key")

# You can pass empty or with request parameters {ex. (country = "us")}
response = api.news_api()

# You can go to next page by providing Page parameter
response = api.news_api(page = "nextPage value")

# You can paginate till last page by providing Page parameter in Loop
page=None
while True:
    response = api.news_api(page = page)
    page = response.get('nextPage',None)
    if not page:
        break


License

Provided under MIT License by Matt Lisivick.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

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

newsdataapi-0.1.6.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

newsdataapi-0.1.6-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file newsdataapi-0.1.6.tar.gz.

File metadata

  • Download URL: newsdataapi-0.1.6.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.16

File hashes

Hashes for newsdataapi-0.1.6.tar.gz
Algorithm Hash digest
SHA256 2e77a71a39686ae039caf97f396f3bee6dc33c51925942f6aefc697d23730ef0
MD5 c54f3b0282cd15f387d5b046184c45cc
BLAKE2b-256 74f9f78bea14aaa52340d259e41cc8bfe7fd977563959bbf65f19eb9289c4796

See more details on using hashes here.

File details

Details for the file newsdataapi-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: newsdataapi-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.16

File hashes

Hashes for newsdataapi-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 78376a23f81a75e9fcacbae5944f7a599ef17c20fab6db7c8722cd0c62e520fe
MD5 a8c1681d4118e0a7f6e62cc3803cd5c5
BLAKE2b-256 9e903258cc6fad9b699181b6f843cb49ade572cdd58c3a7811537c50c0ed6950

See more details on using hashes here.

Supported by

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