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

happn-api

v1.0.7

Published

happn api wrapper for nodejs

Downloads

14

Readme

happn-api

Wrapper of happn api for nodeJS. Working may 2022 - Only facebook auth.

Exemple of use : https://github.com/christophe77/happn-bot

Installation

npm i happn-api
// or
yarn add happn-api

then in your project :

const happnApi = require("happn-api").default;
// or
import happnApi from "happn-api"

Available commands

All return types can be found here : types

Auth

Only with facebook for the moment.

const { auth } = happnApi;

const facebookCredentials = {
    email: "[email protected]",
    password: "12345",
};

async function login() {
    return auth.withFacebook(facebookCredentials);
}

Auth is mandatory before any action.

Me

Used to get your profile datas.

const { me } = happnApi;

async function getMyDatas() {
    return me();
}

Recommandations

const { recommandations } = happnApi;

async function getMyRecommandations() {
    return recommandations();
}

Shortlist

const { shortList } = happnApi;

async function getShortList() {
    return shortList();
}

Like

const { recommandations, like } = happnApi;

async function likeUserExample() {
    const myRecs = await recommandations();
      if (myRecs.length > 0) {
        const userToLike = myRecs[0].content.user;
        try {
                const likeResponse = await like(userToLike.id, userToLike.picture.id);
                const remainingLikes = likeResponse.data.renewable_likes;
                const hasLikedMe = likeResponse.data.has_liked_me;
                const hasCrushed = likeResponse.data.has_crushed;
                console.log(`you liked ${userToLike.first_name} ${userToLike.age}`);
                console.log(`remaining likes : ${remainingLikes}`);
                if (hasLikedMe) {
                    console.log("she liked you");
                }
                if (hasCrushed) {
                    console.log("we have a crush");
                }
            } catch (error) {
                console.log(error);
            }
        }
    }

Dislike

const { recommandations, dislike } = happnApi;

async function disLikeUserExample() {
    const myRecs = await recommandations();
    if (myRecs.length > 0) {
       const userToDisLike = myRecs[0].content.user;
       await dislike(userToLike.id);
    }
}

Example

Full implementation for a bot usage can be found here happn-bot

const happnApi = require("happn-api").default;

const { auth, recommandations, like } = happnApi;

const facebookCredentials = {
    email: "[email protected]",
    password: "12345",
};

async function login() {
    return auth.withFacebook(facebookCredentials);
}

async function getRecommandations() {
    const loginSuccess = await login();
    if (loginSuccess) {
        const myRecommandations = await recommandations();
        return myRecommandations.data || [];
    }
    return [];
}

async function example() {
    const myRecs = await getRecommandations();
    if (myRecs.length > 0) {
        const userToLike = myRecs[0].content.user;
        try {
        const likeResponse = await like(userToLike.id, userToLike.picture.id);
        const remainingLikes = likeResponse.data.renewable_likes;
        const hasLikedMe = likeResponse.data.has_liked_me;
        const hasCrushed = likeResponse.data.has_crushed;
        console.log(`you liked ${userToLike.first_name} ${userToLike.age}`);
        console.log(`remaining likes : ${remainingLikes}`);
        if (hasLikedMe) {
            console.log("she liked you");
        }
        if (hasCrushed) {
            console.log("we have a crush");
        }
        } catch (error) {
            console.log(error);
        }
    }
}

example();

TODO

Implement other happn routes.