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

@ibaraki-douji/fanbox

v1.2.0

Published

A simple wrapper for the Fanbox API

Downloads

1

Readme

Fanbox

Get infos from Pixiv Fanbox

Getting started

npm i @ibaraki-douji/fanbox --save

Usage

Import the lib

const Fanbox = require('@ibaraki-douji/fanbox').default

Init the fanbox

const Fanbox = require('@ibaraki-douji/fanbox').default

const fanbox = new Fanbox();

❗ I will not show the import for the other exemple but you need it at least once.

Login to your account

const fanbox = new Fanbox();

fanbox.login("your cookies");

You can find how to get your cookies here. Why you want to login ? To get all subscriptions infos and account related actions (likes, follows)

Get User

const fanbox = new Fanbox();

const options = {
  withPosts: true,
  withPlans: true,
  withShop: true
};

fanbox.getUser("creatorID", options).then(user => {
    
});

Some of the fields way be null or undefined if they are not fetched All of the options are optionnals and the options agrument is optionnal too.

Get Self User

const fanbox = new Fanbox();

const options = {
  withPosts: true,
  withPlans: true,
  withShop: true
};

fanbox.getSelfUser(options).then(selfUser => {
    
});

Some of the fields way be null or undefined if they are not fetched All of the options are optionnals and the options agrument is optionnal too.

Get Post

const fanbox = new Fanbox();

fanbox.getPost("postID").then(post => {
    
})

Return a ImagePost or EntryPost or ArticlePost, if none of the type post is found it will return a Post with all the data from the request. If the creator from the post already exists it will add it to the stored user.

Classes / Interfaces

Fanbox

{
    public users: Array<User> = [];
    login: (cookies: string) => void;
    getUser: (creatorId: string, options?: {
        withPosts?: boolean,
        withPlans?: boolean,
        withShop?: boolean
    }) => Promise<User>;
    getPost: (id: string) => Promise<Post>
}

User

{
    name: string;
    followed: boolean;
    avatarURL: string;
    backgroundURL: string;
    references: Array<string>;
    plans: Array<Plan>;
    posts: {[k: string]: Post};
    shop: Shop;
    pixivId: string;
    creatorId: string;
    getShop: () => Promise<void>;
    getPlans: () => Promise<void>;
    getPosts: () => Promise<void>;
}

SelfUser

{
    twitter: {
        enabled: true,
        id: string,
        name: string,
        profileImageUrl: string,
        screenName: string,
        url: string
    } | {
        enabled: false
    };
    name: string;
    id: string;
    avatarUrl: string;
    followedCreatorIds: Array<string>;
    supportedCreatorIds: Array<string>;
    r18: boolean;
    unreadNewsletterCount: number;
    unreadMessageCount: number;
    unreadBellCount: number;
    creatorId: string;
    creator: User
}

Plan

{
    name: string;
    description: string;
    price: number;
    iconURL: string;
}

Shop

{
    name: string;
    url: string;
    items: Array<{
        adult: boolean,
        description: string,
        id: number,
        image: string,
        market_url: string,
        name: string,
        price: number,
        url: string,
        published_at: Date
    }>;
    total: number;
}

Post

{
    name: string;
    date: Date;
    price: number;
    iconURL: string;
    description: string;
    tags: Array<string>;
    type: string;
    id: string;
    liked: boolean;
    likeCount: number;
}

ImagePost (extends Post)

{
    text: string;
    images: Array<{
        id: string,
        extention: string,
        width: number,
        height: number,
        originalUrl: string,
        thumbnailUrl: string
    }>;
}

EntryPost (extends Post)

{
    html: string;
}

ArticlePost (extends Post)

blocks: Array<{
        type: 'p',
        text: string,
        styles?: Array<{
            type: string,
            offset: number,
            length: number
        }>,
        links?: Array<{
            offset: number,
            length: number,
            url: string
        }>
    } | {
        type: 'image',
        imageId: string
    } | {
        type: "header",
        text: string
    }>;
    imageMap: {
        [k: string]: {
            id: string,
            extension: "png" | "jpeg",
            width: number,
            height: number,
            originalUrl: string,
            thumbnailUrl: string
        }
    };
    fileMap: {
        [k: string]: {
            id: string,
            name: string,
            extension: string,
            size: number,
            url: string
        }
    };
    embedMap: {
        [k: string]: {
            id: string,
            serviceProvider: string,
            contentId: string
        }
    };
    urlEmbedMap: {
        [k: string]: {
            id: string,
            type: "fanbox.post",
            postInfo: {
                id: string,
                title: string,
                feeRequired: string,
                hasAdultContent: boolean,
                creatorId: string,
                coverImageUrl: string,
                excerpt: string,
                publishedDatetime: string
            }
        }
    };

Exemple

const Fanbox = require('@ibaraki-douji/fanbox').default
const fanbox = new Fanbox();

// MAKE A ASYNC FUNCTION AT START
(async () => {
   const user = await fanbox.getUser("qtonagi", {
       withPlans: false,
       withShop: false
   });
   console.log(user);
   console.log("Total posts from " + user.name + " : " + Object.keys(user.posts).length);
})()

More Help and Support

Discord : https://discord.gg/mD9c4zP4Er

Ask me for an update or to fix a bug in the Discord server