Skip to content

anubhavsrivastava/favicongrab

Repository files navigation

favicongrab

A module for grabbing Favicon for any web site

Build Status PRs Welcome GitHub issues HitCount

NPM

Install

$ npm install favicongrab --save

or

yarn add favicongrab

Usage

const { grabFavicon } = require('favicongrab');

grabFavicon('https://about.theanubhav.com').then((response)=>{console.log(response)})

Above call returns following response

{ domain: 'about.theanubhav.com',
  icons: [ {
      src: 'https://about.theanubhav.com/favicon.ico',
    type: 'image/x-icon'
    } ]
}

API Specification

grabFavicon

  • returns - Promise

  • arguments - siteUrl // e.g theanubhav.com

  • Result Data

  1. Success :

    { domain: 'about.theanubhav.com',
        icons: [ {
            src: 'https://about.theanubhav.com/favicon.ico',
            type: 'image/x-icon'
        } ]
    }
    

Description properties of icon object:

  • property src contains an absolute URL for a favicon image and is required and unique;
  • property type equals an MIME-type's favicon image;
  • property sizes contains size's favicon image and in a simple case has the following format: HEIGHTxWIDTH in pixels.
  1. Failure :

All error messages have the following format

{
    "error": "Unresolved domain name."
}

Reference

favicongrab uses HTTP API from favicongrabber. Refer service API reference here.

Related Module

Environment

Currently, favicongrab is supported for Nodejs Environment only. Please open a issue for browser support, if required.

Related Module

Contribution

Suggestions and PRs are welcome!

Please create issue or open PR request for contribution.

License

Open Source Love

refer LICENSE file in this repository.