capi.js

0.9.1 • Public • Published

gif of capi.js
travis npm MIT PR's welcome gzip size

Capi

The unofficial Codepen.io API

How it works

  • Uses node-fetch to request data relative to the users.
  • Parse the response with cheerio.
  • Make use of promises to fetch pages synchronously.

Demo

codepen (with front-end, as in gif):

https://codepen.io/lucagez/full/GPNJdE

glitch (api only):

Installation

npm install --save capi.js

Usage

const Capi = require('capi.js');
 
(async () => {
    const username = 'lucagez';
 
    // options:
    const maxPagesToFetch = 5 // if not set, Capi will continue to fetch pens until the very last one
    const order = 'latest' // defaults to 'popular'
    // const user = new Capi(username, maxPagesToFetch, order);
    
    const user = new Capi(username);
    const userData = await user.get();
 
    console.log(userData);
    // => object
    // [{
    //  title: "pen1", 
    //  views: 2000, 
    //  hearts: 200, 
    //  comments: 20}, 
    //  { other object }, 
    //  ...]
})();

Api

Capi accepts the following arguments:

argument type description required
user string Username yes
max number Max pages to fetch before stopping execution. If not set, Capi will simply continue to fetch pens until the very last one. no
order string Can be equal to popular or latest. Indicates the order with which the pens are retrieved. no

License

Licensed under the MIT license.

Package Sidebar

Install

npm i capi.js

Weekly Downloads

1

Version

0.9.1

License

MIT

Unpacked Size

735 kB

Total Files

10

Last publish

Collaborators

  • lucagez