SDKs · 21 languages
News API SDKs for Python, JavaScript, Java and 18 more languages
World News API SDKs come in 21 languages, generated from the OpenAPI spec and open source on GitHub: a Python news API client (pip install worldnewsapi), a JavaScript news API client on npm, TypeScript, Java and 17 more. Every news API SDK wraps the full news data API, from search and the news by country API to the news headline API and RSS feeds, so it doubles as a news feed SDK.
import worldnewsapi configuration = worldnewsapi.Configuration( api_key={"headerApiKey": "YOUR_API_KEY"} ) with worldnewsapi.ApiClient(configuration) as api_client: news_api = worldnewsapi.NewsApi(api_client) response = news_api.search_news( text="electric vehicles", language="en", source_country="us", ) for article in response.news: print(article.publish_date, article.title)
import Worldnewsapi from 'worldnewsapi'; let defaultClient = Worldnewsapi.ApiClient.instance; let headerApiKey = defaultClient.authentications['headerApiKey']; headerApiKey.apiKey = 'YOUR API KEY'; let apiInstance = new Worldnewsapi.NewsApi(); let opts = { 'text': "tesla", 'language': "en" }; apiInstance.searchNews(opts, (error, data, response) => { if (error) { console.error(error); } else { console.log('API called successfully. Returned data: ' + data); } });
<!-- pom.xml --> <dependency> <groupId>com.worldnewsapi</groupId> <artifactId>java-client</artifactId> <version>2.2.0</version> </dependency> ApiClient defaultClient = Configuration.getDefaultApiClient(); ApiKeyAuth headerApiKey = (ApiKeyAuth) defaultClient.getAuthentication("headerApiKey"); headerApiKey.setApiKey("YOUR API KEY"); NewsApi apiInstance = new NewsApi(defaultClient); SearchNews200Response result = apiInstance.searchNews( "tesla", null, "us", "en", null, null, null, null, null, null, null, null, null, null, null, 0, 10);
<?php require_once(__DIR__ . '/vendor/autoload.php'); $config = OpenAPI\Client\Configuration::getDefaultConfiguration() ->setApiKey('x-api-key', 'YOUR_API_KEY'); $apiInstance = new OpenAPI\Client\Api\NewsApi( new GuzzleHttp\Client(), $config ); try { $result = $apiInstance->searchNews('tesla'); print_r($result); } catch (Exception $e) { echo 'Exception when calling NewsApi->searchNews: ', $e->getMessage(), PHP_EOL; }
require 'openapi_client' OpenapiClient.configure do |config| config.api_key['headerApiKey'] = 'YOUR API KEY' end api_instance = OpenapiClient::NewsApi.new opts = { text: 'tesla', language: 'en', number: 10 } result = api_instance.search_news(opts) p result
Download
All 21 official SDKs.
Each language links to its folder on GitHub, with a README and docs for every method, and to a zip you can drop into your project.
- AndroidDocs on GitHub Zip
- Angular JSDocs on GitHub Zip
- C#Docs on GitHub Zip
- C++Docs on GitHub Zip
- ClojureDocs on GitHub Zip
- DartDocs on GitHub Zip
- ElixirDocs on GitHub Zip
- ElmDocs on GitHub Zip
- ErlangDocs on GitHub Zip
- GoDocs on GitHub Zip
- HaskellDocs on GitHub Zip
- JavaDocs on GitHub Zip
- JavaScriptDocs on GitHub Zip
- KotlinDocs on GitHub Zip
- LuaDocs on GitHub Zip
- PerlDocs on GitHub Zip
- PHPDocs on GitHub Zip
- PythonDocs on GitHub Zip
- RubyDocs on GitHub Zip
- RustDocs on GitHub Zip
- TypeScriptDocs on GitHub Zip
Inside each SDK
The whole international news API in 9 methods.
Your key goes in once, as the apiKey query setting or the headerApiKey header setting. Method names follow each language's style, for example search_news() in Python and Ruby.
- searchNewsGET /search-newsSearch and filter news articles by text, entities, location, country, language, sentiment, category, source, author and publish date.
- topNewsGET /top-newsGet the top headlines of a country and language for a given day, clustered by story.
- retrieveNewspaperFrontPageGET /retrieve-front-pageGet the front page image of a newspaper by country, publication and date (6,000+ publications).
- retrieveNewsArticlesByIdsGET /retrieve-newsRetrieve full news articles by their ids.
- extractNewsGET /extract-newsExtract the title, text, images, authors and publish date of the article at any URL.
- extractNewsLinksGET /extract-news-linksExtract the links to news articles from a news website, e.g. a homepage or section page.
- searchNewsSourcesGET /search-news-sourcesCheck whether a news source is indexed, by name.
- newsWebsiteToRSSFeedGET /feed.rssTurn any news website into an RSS feed.
- getGeoCoordinatesGET /geo-coordinatesGet latitude and longitude of a location name, e.g. for the location-filter of Search News.
- Suggest News Source (
POST /suggest-news-source) is not in the SDKs yet; call it over plain REST.
Specs and tools
Language not listed? Generate it, or skip the SDK.
The same OpenAPI 3 file the SDKs are built from is yours to download, along with a Postman collection for trying every endpoint first, and an MCP server for AI clients.
OpenAPI 3 specification
Generate a client for any language, for example with OpenAPI Generator:
openapi-generator-cli generate -i world-news-api-openapi-3.json -g swift5 -o swift-client Postman collection
Want to get started without downloading an SDK? Fork the collection into your Postman workspace, add your key and send any request.
Plain REST
Every endpoint is one HTTPS request, so any HTTP client works. The docs show each call in cURL, Python, JavaScript, Java, Go and C#.
curl 'https://api.worldnewsapi.com/top-news?source-country=us&language=en' -H 'x-api-key: YOUR_API_KEY' MCP server
No code at all: plug real-time news into your AI assistant. The World News API MCP server runs locally (stdio) with your API key, so Claude Desktop, Cursor and other MCP clients can search news, read articles and cite sources.
- Claude Desktop
- Cursor
- any local MCP client
SDK questions
Is there a Python library for the news API?
Yes: pip install worldnewsapi. The official Python news API client is on PyPI; create a worldnewsapi.NewsApi object and call search_news(). It is generated from the OpenAPI file. Plain requests calls work just as well; the Python guide shows both.
Does World News API have an npm package?
Yes: npm install worldnewsapi. The worldnewsapi package (version 2.2.0) is the JavaScript news API client; a TypeScript client is listed here too. Plain fetch works the same in any Node.js 18+ project, as the JavaScript guide shows.
Do the SDKs work with RapidAPI?
No. They only work with direct World News API access. RapidAPI has its own libraries for the World News API if you access it there.
Are the SDKs open source?
Yes. All clients are on GitHub in world-news-api-clients; look at the source or fork it. If your language is missing, generate a client from the OpenAPI 3 specification.