1.14.1 • Published 2 months ago

afpnews-api v1.14.1

Weekly downloads
3
License
MIT
Repository
github
Last release
2 months ago

AfpNews API

Build Status Greenkeeper badge

This project is aimed to help javascript developers use the AFP News API.

It provides authentication and search functions.

Getting Started

This package is available both for NodeJS and browsers. That's why two versions are available on the ./dist directory.

Prerequisites

Read the API documentation, and ask for an API Key and credentials.

Installing

Node

npm install --save afpnews-api

const AfpNews = require('afpnews-api')

Browser

<script src="./dist/afpnews-api.js"></script>

Let's start using it

const afpNews = new AfpNews({ clientId: 'YOUR_CLIENT_ID', clientSecret: 'YOUR_CLIENT_SECRET' })

const credentials = {
  username: 'YOUR_USERNAME',
  password: 'YOUR_PASSWORD'
}

afpNews.authenticate(credentials)
  .then(token => {
    // You can eventually save the token to be used later

    return afpNews.search()
  })
  .then(news => {
    console.log(news)
  })
  .catch(err => {
    console.error(err)
  })

Query parser

The above request use default parameters stored in ./src/defaultParams.js

You can pass your own parameters to the search function, that will overide the defaults :

const params = {
  products: ['news'],
  langs: ['fr'],
  urgencies: [1, 2, 3, 4],
  query: 'french politics',
  size: 10,
  dateFrom: '2012-01-01',
  dateTo: 'now',
  sortField: 'published',
  sortOrder: 'desc'
}

afpNews.search(params)
  .then(news => {
    console.log(news)
  })

The query parameter can be used to look precisely for a field (title:Macron) and may include logical parameters (Macron OR Merkel).

Development

Clone the repository, then npm install

Source files are automatically compiled using Webpack with npm run dev

Build and minify your work for browsers and node with npm run build

Running the tests

Just npm test to execute all tests in ./tests

Built With

Authors

License

This project is licensed under the MIT License - see the LICENSE.md file for details

2.0.26

2 months ago

2.0.24

3 months ago

2.0.25

3 months ago

2.0.22

3 months ago

2.0.23

3 months ago

2.0.21

3 months ago

2.0.19

3 months ago

2.0.20

3 months ago

2.0.18

3 months ago

2.0.15

3 months ago

2.0.16

3 months ago

2.0.14

3 months ago

2.0.17

3 months ago

2.0.13

3 months ago

2.0.11

4 months ago

2.0.12

4 months ago

2.0.10

4 months ago

2.0.9

4 months ago

2.0.8

4 months ago

2.0.3

4 months ago

2.0.5

4 months ago

2.0.4

4 months ago

2.0.7

4 months ago

2.0.6

4 months ago

2.0.2

5 months ago

2.0.1

5 months ago

2.0.0

5 months ago

1.14.1

2 years ago

1.14.0

2 years ago

1.15.0

2 years ago

1.15.4

2 years ago

1.15.3

2 years ago

1.15.2

2 years ago

1.15.1

2 years ago

1.15.8

2 years ago

1.15.7

2 years ago

1.15.6

2 years ago

1.15.5

2 years ago

1.13.2

3 years ago

1.13.1

3 years ago

1.12.5

3 years ago

1.12.3

3 years ago

1.12.1

3 years ago

1.12.0

3 years ago

1.11.1-rc2

4 years ago

1.11.1-rc1

4 years ago

1.11.0

4 years ago

1.9.0-rc5

4 years ago

1.10.0

4 years ago

1.9.0-rc3

4 years ago

1.9.0-rc2

4 years ago

1.9.0-rc1

4 years ago

1.8.0

4 years ago

1.7.7

5 years ago

1.7.6

5 years ago

1.7.5

5 years ago

1.7.4-rc2

5 years ago

1.7.4-rc1

5 years ago

1.7.4

5 years ago

1.7.3

5 years ago

1.7.2

5 years ago

1.7.1

5 years ago

1.7.0

5 years ago

1.7.0-rc2

5 years ago

1.7.0-rc1

5 years ago

1.6.1

5 years ago

1.6.0

5 years ago

1.6.0-rc1

5 years ago

1.5.3

5 years ago

1.5.2

5 years ago

1.5.1

5 years ago

1.5.0

6 years ago

1.4.0

6 years ago

1.3.1

6 years ago

1.3.0

6 years ago

1.2.2

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.1

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago