An unofficial Skype API for JavaScript.
$ npm i skype-web-api
$ yarn add skype-web-api
import SkypeWebApi from 'skype-web-api';
Initialize a new SkypeWebApi
object with an empty session.
const skypeApi = new SkypeWebApi();
Login with the Skype credentials of a user.
const tokens = skypeApi.login('SkypeUsernameOrEmail', 'SkypePassword');
This function returns a Tokens
object defined as the following flow type:
type Tokens = {
skypeToken: {
value: string,
epochMillisecondsExpiration: number,
},
registrationToken: {
value: string,
epochMillisecondsExpiration: number,
},
};
Tokens
are useful if you're working on a stateless application (e.g. website backend) and want to resume an existing session without requiring the user to login every time. To load a session from existing Tokens
, refer to the constructor call below. Tokens are valid for 24 hours.
Loads an existing user session from a Tokens
object (defined above).
const tokens = skypeApi.login('SkypeUsernameOrEmail', 'SkypePassword');
const skypeApi = new SkypeWebApi(tokens);
Tokens
expire after 24 hours, after which the user has au authenticate again via the login()
function.
Fetches the UserProfile
of the currently logged-in user.
const myUserProfile = skypeApi.getMyUserProfile();
This function returns a user profile defined as the following flow type:
type UserProfile = {
about: ?string,
avatarUrl: ?string,
birthday: ?string,
city: ?string,
countryCode: ?string
emails: string[],
firstName: ?string,
lastName: ?string,
gender: 'Unspecified' | 'Male' | 'Female',
homePage: ?string,
jobTitle: ?string,
languageCode: ?string,
mood: ?string,
phoneHome: ?string,
phoneMobile: ?string,
phoneOffice: ?string,
province: ?string,
richMood: ?string,
username: ?string,
namespace: ?string,
};
Fetches all the currently logged-in user's contacts.
const contacts = skypeApi.getContacts();
This function returns a Contact
defined as the following flow type:
type Contact = {
profile: UserProfile,
blocked: boolean,
suggested: boolean,
relationshipHistory: ?({
type: string,
subType: ?string,
dateTime: string,
}[]),
displayName: string,
mri: string,
};
Fetches the full UserProfile
of a contact from his username (possibly retrieved from an earlier getContacts()
call).
const username = 'ContactUsername';
const userProfile = skypeApi.getUserProfile(username);
Like getMyUserProfile()
, this function returns a single UserProfile
.
Fetches the full UserProfile
of many contacts instead of repeatedly calling getUserProfile()
.
const contactUsernames = [
'Username1',
'Username2',
'Username3',
];
const contactProfiles = skypeApi.getUserProfiles(contactUsernames);
This function returns an array of UserProfile
.
Sends a message from the current user to one of his contact. recipientMri
is the Windows Live ID of the contact with one of the following formats: <number>:live:<username
or <number>:<email>
. You can get the MRI of a contact with the getContacts()
function.
skypeApi.sendMessage('Hello World', '8:live:bob');
Sends a file from the current user to one of his contact. recipientMri
is the Windows Live ID of the contact with one of the following formats: <number>:live:<username
or <number>:<email>
. You can get the MRI of a contact with the getContacts()
function. Buffer
is a standard Node.js buffer obtained by reading a file from the disk.
import fs from 'fs';
const buffer = fs.readFileSync('path/to/the/file');
skypeApi.sendFile(buffer, 'FileName.pdf', '8:live:bob');
The function returns the arrival timestamp of the file in milliseconds since epoch.
Fetches the messages exchanged by the logged-in user and one of his contacts. contactMri
is the Windows Live ID of the contact with one of the following formats: <number>:live:<username
or <number>:<email>
.
const messages = skypeApi.getMessages('8:live:bob');
The function returns an array of Message
, defined by the following flow type:
type Message = {
id: number,
arrivalDateTime: string,
composeDateTime: string,
content: string,
senderMri: string,
};