0.0.1 • Published 7 years ago

zimnews-api v0.0.1

Weekly downloads
3
License
ISC
Repository
github
Last release
7 years ago

ZimNews API Javascript SDK

Official documentation available at https://zimnews-api.firebaseapp.com

Installation

Node.js

npm i --save zimnews-api

Browser

<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/zimnews-api/index.js">

Usage

var ZimNews = require('zimnews-api'),
    zn = new ZimNews("api_key");

ES6 Import

import ZimNews from 'zimnews-api'
let zm = new ZimNews("api_key");

You can get your API Key from the documentation site.

Methods

.getNews(options)

Promise which returns an array of Stories.

.getSources(options)

Promise which returns an array of Sources.

.getCategories(options)

Promise which returns an array of Categories.

Options

OptionRequiredDefault
limit - number of items returnedNo25
category - of stories to return.NoAll
source - name of source to return. See docs for list of sources.NoAll

Examples

With async/await

(async ()=>{
    let stories = await zm.getNews({limit:10,category:'Business'})
    console.log(stories);
})()

With Promises

zm.getNews({limit:10,category:'Entertainment'}).then(stories=>{
    console.log(stories);
}).catch(e=>{
    console.log(e);
})