https://github.com/patricevignola/skype-web-api
An unofficial Skype API for JavaScript.
https://github.com/patricevignola/skype-web-api
api javascript javascript-library skype unofficial
Last synced: about 1 year ago
JSON representation
An unofficial Skype API for JavaScript.
- Host: GitHub
- URL: https://github.com/patricevignola/skype-web-api
- Owner: PatriceVignola
- License: mit
- Created: 2018-06-15T17:13:58.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-09-22T20:07:05.000Z (over 7 years ago)
- Last Synced: 2024-04-24T07:26:12.837Z (about 2 years ago)
- Topics: api, javascript, javascript-library, skype, unofficial
- Language: JavaScript
- Size: 145 KB
- Stars: 6
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Skype API
[](https://circleci.com/gh/PatriceVignola/skype-web-api) [](https://coveralls.io/github/PatriceVignola/skype-web-api?branch=master) [](https://badge.fury.io/js/skype-web-api) [](https://github.com/prettier/prettier) [](https://github.com/facebook/jest)
An unofficial Skype API for JavaScript.
# Getting Started
## Install with npm
```sh
$ npm i skype-web-api
```
## Install with yarn
```sh
$ yarn add skype-web-api
```
## Include the package
```js
import SkypeWebApi from 'skype-web-api';
```
# Usage
## `SkypeWebApi()`
Initialize a new `SkypeWebApi` object with an empty session.
```js
const skypeApi = new SkypeWebApi();
```
## `login(username: string, password: string): Tokens`
Login with the Skype credentials of a user.
```js
const tokens = skypeApi.login('SkypeUsernameOrEmail', 'SkypePassword');
```
This function returns a `Tokens` object defined as the following flow type:
```js
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.
## `SkypeWebApi(tokens?: Tokens)`
Loads an existing user session from a `Tokens` object (defined above).
```js
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.
## `getMyUserProfile(): UserProfile`
Fetches the `UserProfile` of the currently logged-in user.
```js
const myUserProfile = skypeApi.getMyUserProfile();
```
This function returns a user profile defined as the following flow type:
```js
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,
};
```
## `getContacts(): Contact[]`
Fetches all the currently logged-in user's contacts.
```js
const contacts = skypeApi.getContacts();
```
This function returns a `Contact` defined as the following flow type:
```js
type Contact = {
profile: UserProfile,
blocked: boolean,
suggested: boolean,
relationshipHistory: ?({
type: string,
subType: ?string,
dateTime: string,
}[]),
displayName: string,
mri: string,
};
```
## `getUserProfile(username: string): UserProfile`
Fetches the full `UserProfile` of a contact from his username (possibly retrieved from an earlier `getContacts()` call).
```js
const username = 'ContactUsername';
const userProfile = skypeApi.getUserProfile(username);
```
Like `getMyUserProfile()`, this function returns a single `UserProfile`.
## `getUserProfiles(usernames: string[]): UserProfile[]`
Fetches the full `UserProfile` of many contacts instead of repeatedly calling `getUserProfile()`.
```js
const contactUsernames = [
'Username1',
'Username2',
'Username3',
];
const contactProfiles = skypeApi.getUserProfiles(contactUsernames);
```
This function returns an array of `UserProfile`.
## `sendMessage(text: string, recipientMri: string)`
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: `:live::`. You can get the MRI of a contact with the `getContacts()` function.
```js
skypeApi.sendMessage('Hello World', '8:live:bob');
```
## `sendFile(fileBuffer: Buffer, fileName: string, recipientMri: string): number`
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: `:live::`. 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.
```js
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.
## `getMessages(contactMri: string): Message[]`
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: `:live::`.
```js
const messages = skypeApi.getMessages('8:live:bob');
```
The function returns an array of `Message`, defined by the following flow type:
```js
type Message = {
id: number,
arrivalDateTime: string,
composeDateTime: string,
content: string,
senderMri: string,
};
```