newsapi_client 0.2.5+2

Dart native js
Flutter Android iOS web

A client for the newsapi.org API (v2) written in dart. You can get access to the API by signing up at https://newsapi.org.

Newsapi client for dart #

A client for the newsapi.org API written in dart.

Endpoints #

Top headlines #

import 'package:newsapi_client/newsapi_client.dart';

class News {

  final client = NewsapiClient('YOUR API KEY');

  // Get the latest business headlines.
  Future<Map<String, dynamic>> topBusiness() async {
    final response = await client.request(TopHeadlines(
      category: Categories.business,
    ));
    return response;
  }

  [...]

Everything #

  [...]

  // Get all articles with keyword: Microsoft from 2019-02-01 to now.
  Future<Map<String, dynamic>> everythingMicrosoft() async {
    final response = await client.request(Everything(
      query: 'Microsoft',
      from: DateTime.parse('2019-02-01'),
      to: DateTime.now(),
    ));
    return response;
  }

  [...]

Sources #

  [...]

  // Get all norwegian sources.
  Future<Map<String, dynamic>> norwegianSources() async {
    final response = await client.request(Sources(
      country: Countries.norway,
    ));
    return response;
  }

}
2
likes
100
pub points
58%
popularity

A client for the newsapi.org API (v2) written in dart. You can get access to the API by signing up at https://newsapi.org.

Repository (GitHub)
View/report issues

Documentation

API reference

Uploader

srdlarsen@gmail.com

License

MIT (LICENSE)

Dependencies

http

More

Packages that depend on newsapi_client