GithubHelp home page GithubHelp logo

grandmatits's Introduction

Kik Node API

A chatting API for kik built with Node.js, based on https://github.com/tomer8007/kik-bot-api-unofficial

THIS IS NOT AN OFFICIAL API

npm npm

Join the group chat on kik #kiknodeapi

Installation

NPM:

npm i kik-node-api

Usage

Events
  1. The Basics
  2. Group Events
  3. Private Events
Requests
  1. Common Requests
  2. Group Requests
  3. Profile Requests

Getting Started

You can use the API by creating an instance of KikClient, you'll use it to listen to events and send requests to kik

const KikClient = require("kik-node-api");

Kik = new KikClient({
    username: "username",
    password: "1234",
    promptCaptchas: true,
    trackUserInfo: true,
    trackFriendInfo: true
});

Kik.connect()

username: your kik account's username

password: your kik account's password

promptCaptchas: prompt in the console to solve captchas. If not you must handle it yourself using the event

trackUserInfo: track users and return their usernames and display names in the events when possible

trackFriendInfo: track friends and return their usernames and display names in the events when possible

All users are represented in a js object that looks like this:

user: { 
    jid: "[email protected]", 
    username: "kikteam",
    displayName: "Kik Team",
    pic: "http://profilepics.cf.kik.com/luN9IXX3a4sks-RzyiC7xlK-HdE"
}

groups are represented in the following js object:

group: {
    jid: "[email protected]",
    code: "#kikbotapi",
    name: "Kik Bot API Unofficial",
    users: [
        {jid: "jid1", isOwner: true, isAdmin: true},
        {jid: "jid2", isAdmin: true},
        {jid: "jid3"}
    ]
}

private groups have a code of null

Events

The Basics

KikClient uses Node's Event Emitter class to handle events, all events are attached in the following way:

Kik.on(eventname, (param1, param2) => {
    //do stuff with params here
})

Below are the details of all events emitted by the KikClient class

Authenticated
Kik.on("authenticated", () => {
    console.log("Authenticated")
})
Received Roster
Kik.on("receivedroster", (groups, friends) => {
    console.log(groups);
    console.log(friends)
})

groups: an array of group objects representing the groups you are in

friends: an array of user objects, each representing a friend

Received Captcha
Kik.on("receivedcaptcha", (captchaUrl) => {
    console.log("Please solve captcha" + captchaUrl)
})

captchaUrl: url to the captcha page

Received JID Info
Kik.on("receivedjidinfo", (users) => {
    console.log("We got peer info:");
    console.log(users)
})

users: an array of user objects returned as a result of requesting jids

Group Events

Received Group Message
Kik.on("receivedgroupmsg", (group, sender, msg) => {
    console.log(`Received message from ${sender.jid} in group ${group.jid}`)
})

group: a group object representing the group where the message was sent

sender: a user object representing the message sender

msg: the received message

Received Group Image
Kik.on("receivedgroupimg", (group, sender, img) => {
    console.log(`Received image from ${sender.jid} in group ${group.jid}`)
})

group: a group object representing the group where the message was sent

sender: a user object representing the message sender

img: a buffer object representing the image

Group is Typing
Kik.on("grouptyping", (group, sender, isTyping) => {
    if(isTyping){
        console.log(`${sender.jid} is typing in ${group.jid}`)
    }else{
        console.log(`${sender.jid} stopped typing in ${group.jid}`)
    }
})

group: a group object representing the group where the message was sent

sender: a user object representing the message sender

isTyping: true if the user is typing, false if he stopped

User Left Group
Kik.on("userleftgroup", (group, user, kickedBy) => {
    console.log(`${user.jid} left the group: ${group.jid}`)
})

group: a group object representing the group

user: WIP

kickedBy: WIP

User Joined Group
Kik.on("userjoinedgroup", (group, user, invitedBy) => {
    console.log(`${user.jid} joined the group: ${group.jid}`)
})

group: a group object representing the group

user: WIP

invitedBy: WIP

Private Events

Received Private Message
Kik.on("receivedprivatemsg", (sender, msg) => {
    console.log(`Received message from ${sender.jid}`)
})

sender: a user object representing the message sender

msg: the received message

Received Private Image
Kik.on("receivedprivateimg", (sender, img) => {
    console.log(`Received image from ${sender.jid}`)
})

sender: a user object representing the message sender

img: a buffer object representing the image

Private Is Typing
Kik.on("privatetyping", (sender, isTyping) => {
    if(isTyping){
        console.log(`${sender.jid} is typing`)
    }else{
        console.log(`${sender.jid} stopped typing`)
    }
})

sender: a user object representing the message sender

isTyping: true if the user is typing, false if he stopped

Requests

Note that all callback functions can be excluded

Common Requests

Get User Info

This function can be used to search users by username

Kik.getUserInfo(usernamesOrJids, useXiphias, (users) => {
    
});

usernamesOrJids: a single username or a single jid string. Also accepts an array of jid strings or username strings

useXiphias: if true will use the xiphias endpoint. This endpoint accepts jids only and returns different data

useXiphias = true useXiphias = false
username ✔️
displayName ✔️ ✔️
profilePic ✔️
backgroundPic ✔️
registrationTimestamp ✔️
kinId ✔️

note that some data will only be returned if you're chatting with a user

returns an array of user objects, or an empty array if no results are found

Send Message

You can provide a group's or a user's jid, they will automatically use the appropriate format

Kik.sendMessage(jid, msg, (delivered, read) => {
    if(delivered){
        console.log("Delivered")
    }else if(read){
        console.log("Read")
    }
})
Send Image

You can provide a group's or a user's jid, they will automatically use the appropriate format

Kik.sendImage(jid, imgPath, allowForwarding, allowSaving)

allowForwarding: boolean, if false this image will not give the receiver a forwarding option. true by default

allowSaving: boolean, if false this image will not give the receiver a download option. true by default

returns a promise, make sure to use this inside an async function with the await keyword

Add Friend
Kik.addFriend(jid)
Remove Friend
Kik.removeFriend(jid)

Group Requests

Search Groups
Kik.searchGroups(searchQuery, (groups) => {
    
})

groups: an array of group objects representing the search results, the group objects here have a special joinToken variable used for joining the group

Join Group
Kik.joinGroup(groupJid, groupCode, joinToken)
Leave Group
Kik.leaveGroup(groupJid)
Kick/Add
Kik.setGroupMember(groupJid, userJid, bool)
Promote/Demote
Kik.setAdmin(groupJid, userJid, bool)
Ban/Unban
Kik.setBanned(groupJid, userJid, bool)
Change Group Name
Kik.setGroupName(groupJid, name)

Profile Requests

Set Profile Name
Kik.setProfileName(firstName, lastName)
Set Email
Kik.setEmail(newEmail, password)
Set Password
Kik.setPassword(newPassword, oldPassword)

License

GNU AGPLv3

grandmatits's People

Contributors

xblazek1ng420x avatar

Watchers

 avatar

Forkers

mac0r0ni

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.