newsdataapi library

Official Dart/Flutter client for the Newsdata.io News API.

See https://github.com/newsdataapi/newsdata-flutter-client for usage docs.

Classes

Article
One news article. Field names use camelCase; JSON tags use the API's snake_case.
Endpoint
Endpoint identifiers — pass these as the endpoint: argument to scrollAll and paginate.
NewsDataApiClient
HTTP client for the Newsdata.io API. Construct with NewsDataApiClient.new and call the per-endpoint methods (latest, archive, …). All methods return Future<NewsdataResponse> and throw NewsdataException subclasses on failure.
NewsdataResponse
Top-level envelope returned by every endpoint.

Functions

redactApiKey(String url) String
Replace the apikey query parameter's value with REDACTED so the URL is safe to log.
validateAndEncode(String endpoint, Map<String, Object?> params, {String? rawQuery}) Map<String, String>
Validate and normalize endpoint parameters. Returns a map from API parameter name to its string representation, ready to be URL-encoded.

Typedefs

NewsdataLogger = void Function(String level, String message)
Function signature for the optional logger. The client calls this once per request attempt and on retries; the URL is already API-key-redacted.

Exceptions / Errors

NewsdataApiException
The API returned a structured error response.
NewsdataAuthException
Raised on 401 / 403 responses (missing, invalid, or unauthorized API key).
NewsdataException
Base class for every exception raised by the Newsdata.io SDK.
NewsdataNetworkException
A network-level failure (DNS, TLS, timeout, socket error) prevented the request from completing.
NewsdataRateLimitException
Raised on 429 responses once retries are exhausted. retryAfter is the number of seconds the Retry-After header asked for, or null when the header was missing or unparseable.
NewsdataServerException
Raised on 5xx responses once retries are exhausted.
NewsdataValidationException
A user-provided parameter failed client-side validation. No request was sent.