npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

fb-kit

v0.1.0

Published

Facebook Graph API JS Kit

Downloads

2

Readme

Facebook Kit

Facebook Graph API JS Kit - A modern JS library for Graph API. Uses access token for working with API.

Requirements

  • Latest Browsers

Installation

In a browser:

<script src="https://unpkg.com/fb-kit/dist/fb-kit.min.js"></script>

Or You can install the package via npm or yarn:

NPM:

$ npm i -s fb-kit

Yarn:

$ yarn add fb-kit

Usage

import fbKit from 'fb-kit';

let opts = {
    version: 'v2.8',
    accessToken: 'User / Page / App Access Token',
    beta: false, // Optional - To make API calls to beta graph api.
    appId: '', // Optional - Used for generating login URL.
    debug: false // Debug mode for API requests.
};

const FB = new fbKit(opts);

// OR

const FB = fbKit.instance(opts);

Available Methods

getApiVersion()

Get Graph API version

Defaults: v2.8

let graphApiVersion = FB.getApiVersion();

setApiVersion(version)

Set default Graph API version to use for all requests.

let version = 'v2.2';

FB.setApiVersion(accessToken);

getAccessToken()

Get the access token (if previously set)

Defaults: null

let accessToken = FB.getAccessToken();

setAccessToken(accessToken)

Set an Access Token for all API calls.

let accessToken = '';

FB.setAccessToken(accessToken);

get(endpoint, params = {})

Make get requests.

FB.get('me')
  .then(response => {
    console.log(response)
  }).catch(error => {
    console.log(error)
  });

post(endpoint, params = {})

Make post requests.

let message = 'Hello World!';

FB.post('me/feed', { message: message })
  .then(response => {
    console.log(response)
  }).catch(error => {
    console.log(error)
  });

delete(endpoint)

Make delete requests.

let commentId = 12345678; // Comment ID to Delete

FB.delete(commentId)
  .then(response => {
    console.log(response)
  }).catch(error => {
    console.log(error)
  });

batch(batch = [])

Make batch requests.

let batch = [
    { method: 'get', relative_url: '4' },
    { method: 'get', relative_url: 'me/friends?limit=50' },
    { method: 'get', relative_url: '4', headers: { 'If-None-Match': '"7de572574f2a822b65ecd9eb8acef8f476e983e1"' } }, /* etags */
    { method: 'get', relative_url: 'me/friends?limit=1', name: 'one-friend' /* , omit_response_on_success: false */ },
    { method: 'get', relative_url: '{result=one-friend:$.data.0.id}/feed?limit=5'}
]

FB.batch(batch)
  .then(response => {
    console.log(response)
  }).catch(error => {
    console.log(error)
  });

getLoginUrl(opts = {})

Generate a login OAuth URL.

let loginUrl = FB.getLoginUrl({
    redirectUri: 'https://domain...',
    appId: '123456', // Optional - Default to the appId set in constructor.
    version: 'v2.8', // Optional - Default as per getApiVersion().
    scope: 'email', // Optional
    responseType: 'code' // Optional - Default: token
    display: 'pop', // Optional
    state: '123456789' // Optional
})

TODO

  • [ ] Add all kit methods.

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.