All Projects → jcobhams → newsapi-php

jcobhams / newsapi-php

Licence: MIT license
A PHP client for the News API (https://newsapi.org/docs/get-started)

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to newsapi-php

Php Ovh
Lightweight PHP wrapper for OVH APIs. That's the easiest way to use OVH.com APIs in your PHP applications.
Stars: ✭ 230 (+995.24%)
Mutual labels:  api-wrapper
java-binance-api
Java Binance API Client
Stars: ✭ 72 (+242.86%)
Mutual labels:  api-wrapper
ruby-ambassador
Ambassador API v2 wrapper for Ruby
Stars: ✭ 20 (-4.76%)
Mutual labels:  api-wrapper
Betfair
betfairlightweight - python wrapper for Betfair API-NG (with streaming)
Stars: ✭ 246 (+1071.43%)
Mutual labels:  api-wrapper
cvpysdk
Developer SDK - Python
Stars: ✭ 50 (+138.1%)
Mutual labels:  api-wrapper
knowledgeworks api
The API utils for querying CN-DBpedia & CN-Probase, the biggest Chinese knowledge bases
Stars: ✭ 24 (+14.29%)
Mutual labels:  api-wrapper
Taxize
A taxonomic toolbelt for R
Stars: ✭ 209 (+895.24%)
Mutual labels:  api-wrapper
epicstore api
Epic Games Store Web API Wrapper written in Python
Stars: ✭ 48 (+128.57%)
Mutual labels:  api-wrapper
ProgressiveNewsApp
A simple Progressive Web App that brought news from a variety of sources using News API.
Stars: ✭ 41 (+95.24%)
Mutual labels:  newsapi
wikipedia-reference-scraper
Wikipedia API wrapper for references
Stars: ✭ 34 (+61.9%)
Mutual labels:  api-wrapper
Play Store Api
Google Play Store protobuf API wrapper in java
Stars: ✭ 249 (+1085.71%)
Mutual labels:  api-wrapper
conekta-elixir
Elixir library for Conekta api calls
Stars: ✭ 15 (-28.57%)
Mutual labels:  api-wrapper
cpAPI
A Flask API that gives updates about the upcoming contests on various Coding Platforms.
Stars: ✭ 13 (-38.1%)
Mutual labels:  api-wrapper
Python Scrapyd Api
A Python wrapper for working with Scrapyd's API.
Stars: ✭ 235 (+1019.05%)
Mutual labels:  api-wrapper
powershellwrapper
This PowerShell module acts as a wrapper for the IT Glue API.
Stars: ✭ 96 (+357.14%)
Mutual labels:  api-wrapper
Python Ovh
Thin wrapper around OVH's APIs. Handles all the hard work including credential creation and requests signing.
Stars: ✭ 213 (+914.29%)
Mutual labels:  api-wrapper
hata
Async Discord API wrapper.
Stars: ✭ 156 (+642.86%)
Mutual labels:  api-wrapper
Pyrez
(ON REWRITE) An easy to use (a)sync wrapper for Hi-Rez Studios API (Paladins, Realm Royale, and Smite), written in Python. 🐍
Stars: ✭ 23 (+9.52%)
Mutual labels:  api-wrapper
chess-web-api
Chess.com public data API wrapper with "isChanged" and priority queue functionality.
Stars: ✭ 83 (+295.24%)
Mutual labels:  api-wrapper
messages
A python package designed to make sending messages easy and efficient!
Stars: ✭ 38 (+80.95%)
Mutual labels:  api-wrapper

NewsAPI-PHP

A PHP client for the News API.

Installation

Available for installation on packagist using composer.

composer require jcobhams/newsapi

Usage

After installation and and requireing vendor/autoload.php file in your project,

Get Your API key from here

use jcobhams\NewsApi\NewsApi;
.
.
.
$newsapi = new NewsApi($your_api_key);

Get TopHeadLines

$newsapi->getTopHeadlines($q, $sources, $country, $category, $page_size, $page);

* $q : Keywords or a phrase to search for.

* $sources: A comma-seperated string of identifiers for the news sources or blogs you want headlines from. 
            Use the getSources() method to locate these programmatically or look at the sources index. 
            Note: you can't mix this param with the country or category params.
            
* $country: The 2-letter ISO 3166-1 code of the country you want to get headlines for. 
            Use the getCountries() method to locate these programmatically. 
            Note: you can't mix this param with the sources param.
            
* $category: The category you want to get headlines for. Use the getCategories() method to locate these programmatically. 
             Note: you can't mix this param with the sources param.

* $page_size: The number of results to return per page (request). 20 is the default, 100 is the maximum.

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

Returns JSON object is successful or throws excpetions if invalid data or unsuccessful request.

Get Everything

$newsapi->getEverything($q, $sources, $domains, $exclude_domains, $from, $to, $language, $sort_by,  $page_size, $page);

* $domains: A comma-seperated string of domains (eg bbc.co.uk, techcrunch.com, engadget.com) to restrict the search to.

* $exclude_domains: A comma-seperated string of domains (eg bbc.co.uk, techcrunch.com, engadget.com) to remove from the results.

* $from: A date and optional time for the oldest article allowed. 
         This should be in ISO 8601 format (e.g. 2018-11-16 or 2018-11-16T16:19:03) 
         Default: the oldest according to your plan.

* $to: A date and optional time for the newest article allowed. 
       This should be in ISO 8601 format (e.g. 2018-11-16 or 2018-11-16T16:19:03) 
       Default: the newest according to your plan.

* $language: The 2-letter ISO-639-1 code of the language you want to get headlines for. 
             Possible options: ar de en es fr he it nl no pt ru se ud zh . 
             Default: all languages returned. Use the getLanguages() method to locate these programmatically.

* $sort_by: The order to sort the articles in. Use the getSortBy() method to locate these programmatically.

Returns JSON object is successful or throws excpetions if invalid data or unsuccessful request.

Get New Sources

$newsapi->getSources($category, $language, $country)


Returns JSON object is successful or throws excpetions if invalid data or unsuccessful request.

Get Countries

$newsapi->getCountries()

Returns an array of allowed countries

Get Languages

$newsapi->getLanguages()

Returns an array of allowed languages

Get Categories

$newsapi->getCategories()

Returns an array of allowed categories

Get SortBy

$newsapi->getSortBy()

Returns an array of allowed sort_by

CONTRIBUTORS

This package is authored by Joseph Cobhams.

TODO

Write more unit tests, mocks and stubs.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].