A React hook-based wrapper for the NewsData.io API
newsdataapi
is a lightweight, dependency-free React Hook client for accessing the NewsData.io API. It supports all available endpoints and handles validation, pagination, and parameter safety out of the box.
npm install newsdataapi
import useNewsDataApiClient from "newsdataapi";
const { latest, archive, crypto, sources } = useNewsDataApiClient("YOUR_API_KEY");
Each function accepts parameters as an object. All parameters are validated against NewsData.io Documentation
- latest(params)
latest({ q: "ai", country: "us", language: "en" });
- archive(params)
archive({ q: "elections", from_date: "2023-01-01", to_date: "2023-03-01" });
- crypto(params)
crypto({ q: "bitcoin", coin: "btc"});
- sources(params)
sources({ country: "us", language: "en" });