Skip to main content

Libraries & SDKs

Speed up your integration with our official libraries. These SDKs provide convenient wrappers around the GNews API, handling authentication, error management, and response parsing for you.

Official Libraries​

Python​

gnews-io-python - Official Python SDK

Features:

  • No dependencies, Python 3.10+
  • Typed responses (Article, Source) with editor autocompletion
  • One exception per API error (invalid key, quota reached, rate limit...)
  • Automatic retries on rate limit (429), server (5xx) and network errors
  • Lazy pagination helpers (iter_search, iter_top_headlines)

Installation:

pip install gnews-io-python

The package is imported as gnews_io:

from gnews_io import GNews

client = GNews("YOUR_API_KEY")
result = client.search("bitcoin", lang="en", max=10)

The gnews package on PyPI is an unrelated Google News scraper, not the GNews API client.

Documentation: pypi.org/project/gnews-io-python

GitHub repository: github.com/gnews-io/gnews-io-python

JavaScript, TypeScript, and Node.js​

@gnews-io/gnews-io-js - Official JavaScript SDK

Features:

  • Promise-based API, TypeScript types included
  • Errors carry the API message and HTTP status (GNews.GNewsError)
  • Automatic retries on rate limit (429), server (5xx) and network errors
  • Configurable request timeout and retries
  • Accepts Date objects for from and to
  • Works in Node.js 24+ and in the browser

Installation:

npm install @gnews-io/gnews-io-js

Documentation: www.npmjs.com/package/@gnews-io/gnews-io-js

GitHub repository: github.com/gnews-io/gnews-io-js

PHP​

gnews-io/gnews-io-php - Official PHP SDK

Features:

  • PSR-4 autoloading, built on Guzzle (a custom client can be injected)
  • Exceptions carry the API message, with the HTTP status as code
  • Automatic retries on rate limit (429), server (5xx) and network errors
  • API key sent in a header, so it never appears in URLs or error messages
  • Accepts DateTimeInterface objects for from and to
  • PHP 8.4+ support

Installation:

composer require gnews-io/gnews-io-php

Documentation: packagist.org/packages/gnews-io/gnews-io-php

GitHub repository: github.com/gnews-io/gnews-io-php

LangChain​

langchain-gnews - Official LangChain tools

Two tools for LangChain and LangGraph agents: GNewsTopHeadlines (top headlines by category, country and language) and GNewsSearch (news search with date filters over an archive since 2020). Built on the Python SDK.

Installation:

pip install langchain-gnews

Documentation: LangChain page

GitHub repository: github.com/gnews-io/langchain-gnews

MCP Server for AI Assistants​

To use the GNews API from Claude Code, Cursor, VS Code or Gemini CLI, connect the hosted MCP server: nothing to install.

Community Libraries​

We welcome community contributions! If you've created a library for GNews API, let us know and we'll feature it here.

Want to Create a Library?​

Here's what makes a great GNews API library:

Essential Features:

  • API key authentication
  • Support for both endpoints (/search and /top-headlines)
  • Error handling with meaningful messages
  • Response parsing and validation

Nice to Have:

  • Caching mechanisms
  • Pagination helpers
  • Comprehensive documentation
  • Unit tests

Need a Different Language?​

Don't see a library for your preferred programming language? You can:

  • Use the REST API directly - it works with any HTTP client
  • Contribute a community library and get it featured here

Support​

Each library has its own GitHub repository with:

  • Installation instructions
  • Usage examples
  • API documentation
  • Issue tracking
  • Community discussions