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

afpnews-api

Package Overview
Dependencies
Maintainers
1
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

afpnews-api

Node helper functions to authenticate and fetch AFP Core API

  • 2.0.22
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

AfpNews API

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

It provides authentication, searching for documents function, and online news product.

Getting Started

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

Prerequisites

You'll need an API key and credentials to retrieve all content from the API.

Installing

Node

npm install --save afpnews-api

const { ApiCore } = require('afpnews-api')
// OR using import
import { ApiCore } from 'afpnews-api'
Browser
<script src="./dist/bundles/apicore.min.js"></script>

Let's start using it

// Initialize the API
const apicore = new ApiCore({ clientId, clientSecret })

// Authenticate
await apicore.authenticate({ username, password })

// Get token changed
apicore.on('tokenChanged', token => console.log(token))

// Search for latest documents
const { documents } = await apicore.search()

// Or using a generator to crawl multiple pages
for await (const doc of apicore.searchAll()) {
  console.log(doc)
}

// Get a specific document
const document = await apicore.get(uno)

// Look for similar documents
const { documents } = await apicore.mlt(uno)

// Display the most used slugs
const { keywords } = await apicore.list('slug')

Query parser

The above request use default parameters stored in ./src/default-search-params.js

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

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

Development

Clone the repository, then npm install

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

You will need some environment variables in a .env file :

AFPNEWS_BASE_URL=
AFPNEWS_API_KEY=
AFPNEWS_CLIENT_ID=
AFPNEWS_CLIENT_SECRET=
AFPNEWS_USERNAME=
AFPNEWS_PASSWORD=

Built With

  • TypeScript - Typescript

Authors

License

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

Keywords

FAQs

Package last updated on 07 Feb 2024

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