{"id":17901804,"url":"https://github.com/jcobhams/newsapi-php","last_synced_at":"2025-03-23T13:31:50.700Z","repository":{"id":33372487,"uuid":"157895013","full_name":"jcobhams/newsapi-php","owner":"jcobhams","description":"A PHP client for the News API (https://newsapi.org/docs/get-started)","archived":false,"fork":false,"pushed_at":"2024-04-05T14:21:06.000Z","size":9,"stargazers_count":40,"open_issues_count":8,"forks_count":23,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-16T22:18:42.117Z","etag":null,"topics":["api-client","api-wrapper","newsapi","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jcobhams.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-11-16T16:41:07.000Z","updated_at":"2024-09-06T06:33:49.000Z","dependencies_parsed_at":"2024-06-21T04:10:53.493Z","dependency_job_id":null,"html_url":"https://github.com/jcobhams/newsapi-php","commit_stats":{"total_commits":7,"total_committers":3,"mean_commits":"2.3333333333333335","dds":0.2857142857142857,"last_synced_commit":"5961d7e1b1493fe7493d278bada2dba1f5481471"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcobhams%2Fnewsapi-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcobhams%2Fnewsapi-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcobhams%2Fnewsapi-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcobhams%2Fnewsapi-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jcobhams","download_url":"https://codeload.github.com/jcobhams/newsapi-php/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245108227,"owners_count":20562007,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-client","api-wrapper","newsapi","php"],"created_at":"2024-10-28T16:03:35.971Z","updated_at":"2025-03-23T13:31:50.650Z","avatar_url":"https://github.com/jcobhams.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"## NewsAPI-PHP\nA PHP client for the [News API](https://newsapi.org/docs/get-started).\n\n### Installation\nAvailable for installation on packagist using composer.\n```\ncomposer require jcobhams/newsapi\n```\n\n### Usage\nAfter installation and and `require`ing `vendor/autoload.php` file in your project,\n\nGet Your API key from [here](https://newsapi.org/register)\n```php\nuse jcobhams\\NewsApi\\NewsApi;\n.\n.\n.\n$newsapi = new NewsApi($your_api_key);\n```\n\n### Get TopHeadLines\n```\n$newsapi-\u003egetTopHeadlines($q, $sources, $country, $category, $page_size, $page);\n\n* $q : Keywords or a phrase to search for.\n\n* $sources: A comma-seperated string of identifiers for the news sources or blogs you want headlines from. \n            Use the getSources() method to locate these programmatically or look at the sources index. \n            Note: you can't mix this param with the country or category params.\n            \n* $country: The 2-letter ISO 3166-1 code of the country you want to get headlines for. \n            Use the getCountries() method to locate these programmatically. \n            Note: you can't mix this param with the sources param.\n            \n* $category: The category you want to get headlines for. Use the getCategories() method to locate these programmatically. \n             Note: you can't mix this param with the sources param.\n\n* $page_size: The number of results to return per page (request). 20 is the default, 100 is the maximum.\n\n* $page: Use this to page through the results if the total results found is greater than the page size.\n\nReturns JSON object is successful or throws excpetions if invalid data or unsuccessful request.\n```\n\n### Get Everything\n```\n$newsapi-\u003egetEverything($q, $sources, $domains, $exclude_domains, $from, $to, $language, $sort_by,  $page_size, $page);\n\n* $domains: A comma-seperated string of domains (eg bbc.co.uk, techcrunch.com, engadget.com) to restrict the search to.\n\n* $exclude_domains: A comma-seperated string of domains (eg bbc.co.uk, techcrunch.com, engadget.com) to remove from the results.\n\n* $from: A date and optional time for the oldest article allowed. \n         This should be in ISO 8601 format (e.g. 2018-11-16 or 2018-11-16T16:19:03) \n         Default: the oldest according to your plan.\n\n* $to: A date and optional time for the newest article allowed. \n       This should be in ISO 8601 format (e.g. 2018-11-16 or 2018-11-16T16:19:03) \n       Default: the newest according to your plan.\n\n* $language: The 2-letter ISO-639-1 code of the language you want to get headlines for. \n             Possible options: ar de en es fr he it nl no pt ru se ud zh . \n             Default: all languages returned. Use the getLanguages() method to locate these programmatically.\n\n* $sort_by: The order to sort the articles in. Use the getSortBy() method to locate these programmatically.\n\nReturns JSON object is successful or throws excpetions if invalid data or unsuccessful request.\n```\n\n### Get New Sources\n```\n$newsapi-\u003egetSources($category, $language, $country)\n\n\nReturns JSON object is successful or throws excpetions if invalid data or unsuccessful request.\n```\n\n### Get Countries\n```\n$newsapi-\u003egetCountries()\n\nReturns an array of allowed countries\n```\n\n### Get Languages\n```\n$newsapi-\u003egetLanguages()\n\nReturns an array of allowed languages\n```\n\n### Get Categories\n```\n$newsapi-\u003egetCategories()\n\nReturns an array of allowed categories\n```\n\n### Get SortBy\n```\n$newsapi-\u003egetSortBy()\n\nReturns an array of allowed sort_by\n```\n\n### CONTRIBUTORS\n\nThis package is authored by Joseph Cobhams.\n\n### TODO\nWrite more unit tests, mocks and stubs.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcobhams%2Fnewsapi-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjcobhams%2Fnewsapi-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcobhams%2Fnewsapi-php/lists"}