newsapi_client 0.2.5+2 copy "newsapi_client: ^0.2.5+2" to clipboard
newsapi_client: ^0.2.5+2 copied to clipboard

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.

example/example.dart

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;
  }

  // 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;
  }

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

Publisher

unverified uploader

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
Contributing

License

MIT (LICENSE)

Dependencies

http

More

Packages that depend on newsapi_client