3.0.0 • Published 5 years ago

@frontender-magazine/mercury-sdk v3.0.0

Weekly downloads
1
License
CC-BY-4.0
Repository
github
Last release
5 years ago

Mercury API SDK

JavaScript SDK for Mercury Web Parser API.

Bages

Travis Codecov branch

Documentation

Classes

Functions

ErrorServerResponse

Kind: global class

new ErrorServerResponse(statusCode, statusText, message)

Custom error message for abstract server response

ParamTypeDefaultDescription
statusCodenumberhttp status code
statusTextstringhttp status code text
messagestring | nullnullerror details

ErrorServerResponse.module.exports

Kind: static class of ErrorServerResponse

new module.exports(statusCode, statusText, message)

Constructor generates error instance

Returns: ErrorServerResponse - - current instance

ParamTypeDefaultDescription
statusCodenumberhttp status code
statusTextstringhttp status code text
messagestring | nullnullerror details

MercuryWebParser

Kind: global class
See: https://mercury.postlight.com/web-parser/

new MercuryWebParser()

SDK for mercury api

get(url) ⇒ Promise.<Page>

Get content of page

Kind: global function
Returns: Promise.<Page> - - single page

ParamTypeDescription
urlstringpage url

Example (Get single page)

import MercuryWebParser from '@frontender-magazine/mercury-sdk';
(async () => {
  const parser = new MercuryWebParser();
  const page = await parser.get('http://alistapart.com/article/design-like-a-teacher');
})();

getAll(url) ⇒ Promise.<PagesList>

Get content of all pages

Kind: global function
Returns: Promise.<PagesList> - - array of pages

ParamTypeDescription
urlstringpage url

Example (Get all pages as array)

import MercuryWebParser from '@frontender-magazine/mercury-sdk';
(async () => {
  const parser = new MercuryWebParser();
  const pages = await parser.getAll('http://alistapart.com/article/design-like-a-teacher');
})();