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
Join the group chat on kik #kiknodeapi
Feeling generous? Send me a BTC donation at bc1q7fg5r35e4hqaqxgqaleyza9j3k0dm7efknp9lj
NPM:
npm i kik-node-api
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({
promptCaptchas: true,
device: {
},
logger: {
file: ["warning", "error", "info", "raw"],
console: ["warning", "error", "info", "raw"]
}
});
Kik.authenticate(username, password)
promptCaptchas
: prompt in the console to solve captchas. If not you must handle it yourself using the event
logger
: configuration for the logger, the array contains the type of logs
The user object:
user: {
jid: "kikteam@talk.kik.com",
username: "kikteam",
displayName: "Kik Team",
pic: "http://profilepics.cf.kik.com/luN9IXX3a4sks-RzyiC7xlK-HdE"
}
The group object
group: {
jid: "1100221067977_g@groups.kik.com",
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
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
Kik.on("connected", () => {
console.log("Connected")
})
Kik.on("authenticated", (isAnonymous) => {
console.log("Authenticated")
})
isAnonymous
: if true
the authentication was done anonymously
(no username/password)
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
Kik.on("receivedcaptcha", (captchaUrl) => {
console.log("Please solve captcha" + captchaUrl)
})
captchaUrl
: url to the captcha page
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
Kik.on("receivedgroupmsg", (groupJid, senderJid, msg) => {
console.log(`Received message from ${senderJid} in group ${groupJid}`)
})
Kik.on("receivedgroupimg", (groupJid, senderJid, img) => {
console.log(`Received image from ${sender.jid} in group ${group.jid}`)
})
img
: a buffer
object representing the image
Kik.on("grouptyping", (groupJid, senderJid, isTyping) => {
if(isTyping){
console.log(`${senderJid} is typing in ${groupJid}`)
}else{
console.log(`${senderJid} stopped typing in ${groupJid}`)
}
})
isTyping
: true if the user is typing, false if they stopped
Kik.on("userleftgroup", (groupJid, userJid, wasKicked) => {
console.log(`${userJid} left the group: ${groupJid}`)
})
wasKicked
: true
if the user was kicked
Kik.on("userjoinedgroup", (groupJid, userJid, wasInvited) => {
console.log(`${userJid} joined the group: ${groupJid}`)
})
wasInvited
: true
if the user was invited
Kik.on("receivedprivatemsg", (senderJid, msg) => {
console.log(`Received message from ${senderJid}`)
})
msg
: the received message
Kik.on("receivedprivateimg", (senderJid, img) => {
console.log(`Received image from ${senderJid}`)
})
img
: a buffer
object representing the image
Kik.on("privatetyping", (senderJid, isTyping) => {
if(isTyping){
console.log(`${senderJid} is typing`)
}else{
console.log(`${senderJid} stopped typing`)
}
})
isTyping
: true if the user is typing, false if he stopped
Note that all callback functions can be excluded
Kik.createAccount(email, username, password, firstName, lastName, birthdate, captchaResponse, () => {
console.log('Account created successfully')
})
Kik.authenticate(usernameOrEmail, password)
If username and password are not provided, the client will use anonymous authentication
Kik.getRoster((groups, friends) => {
});
See received roster for response information
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
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")
}
})
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
Kik.addFriend(jid)
Kik.removeFriend(jid)
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
Kik.joinGroup(groupJid, groupCode, joinToken)
Kik.leaveGroup(groupJid)
Kik.setGroupMember(groupJid, userJid, bool)
Kik.setAdmin(groupJid, userJid, bool)
Kik.setBanned(groupJid, userJid, bool)
Kik.setGroupName(groupJid, name)
Kik.setProfileName(firstName, lastName)
Kik.setEmail(newEmail, password)
Kik.setPassword(newPassword, oldPassword)