Skip to main content

Python library for newsdata client-API Call

Project description

Alt text

Newsdataapi 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.


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 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 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_data : 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 Request Parameters. ex(country = "us")
response = api.sources_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.


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.0.tar.gz (8.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.0-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: newsdataapi-0.1.0.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.2.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.8.10

File hashes

Hashes for newsdataapi-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2078f8d06a344c91c3378027e979905bacf82d4c0441708f219be8d52858c820
MD5 867e9be0316f639eafaa44209f0b55e0
BLAKE2b-256 753d2212fdac14fd2a821249cda737173b3c48c1936e39a2722ed486ff15839d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: newsdataapi-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.2.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.8.10

File hashes

Hashes for newsdataapi-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 06fe599d9e03b294b4c9ccd765ee70158e129819b7dac02fbfa0693a004586b1
MD5 9d584a13f68b1c62490b8dd4144f991c
BLAKE2b-256 15be6298302f85a681241f96776715da9dd2aea963ad8bef86254196a0923305

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