Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

angular-news-api

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-news-api

This Library provides everything you need to use the NewsAPI from you Angular app the way it should be: using Observables, Types and Dependency Injection.

  • 0.0.7
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8
increased by14.29%
Maintainers
1
Weekly downloads
 
Created
Source

NewsAPI - An Angular Interface for NewsAPI

This Library provides everything you need to use the NewsAPI from you Angular app the way it should be: using Observables, Types and Dependency Injection.

Installing in your project

npm install --save angular-news-api

Using in your Angular application

Import the AppRoutingModule into your app module and configure your API Key:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { NgnewsModule } from 'angular-news-api';
import { NewsApiKeyConfig } from 'angular-news-api';

const newsApiConfig: NewsApiKeyConfig = {
  key: 'API_KEY_FROM_NEWS_API'
};

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    NgnewsModule.forRoot(newsApiConfig)
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Now you can use all the endpoints of the API:

constructor(private newsApiService: NewsApiService) {}

topHeadlines() {
 this.newsApiService.topHeadlines({
       sources: 'bbc-news,the-verge'
     }).subscribe(data => console.log(data));
}

everything() {
 this.newsApiService.everything({
       q: 'trump'
     }).subscribe(data => console.log(data));
}

sources() {
 this.newsApiService.sources({
       country: 'us'
     }).subscribe(data => console.log(data));
}

Check the official documentation for more info about the options in each endpoint.

Keywords

FAQs

Package last updated on 28 Dec 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc