An unofficial Python library for interacting with the Skype HTTP API.
Project description
An unofficial Python library for interacting with the Skype HTTP API.
Here be dragons
The upstream APIs used here are undocumented and are liable to change, which may cause parts of this library to fall apart in obvious or non-obvious ways. You have been warned.
Requirements
Python 2.6+ (includes 3.x)
Responses (for tests)
Getting started
The documentation gives some examples in more detail, as well as a full API specification, but here are the basics to get you started:
from skpy import Skype
sk = Skype(username, password) # connect to Skype
sk.user # you
sk.contacts # your contacts
sk.chats # your conversations
ch = sk.chats.create(["joe.4", "daisy.5"]) # new group conversation
ch = sk.contacts["joe.4"].chat # 1-to-1 conversation
ch.sendMsg(content) # plain-text message
ch.sendFile(open("song.mp3", "rb"), "song.mp3") # file upload
ch.sendContact(sk.contacts["daisy.5"]) # contact sharing
ch.getMsgs() # retrieve recent messages
Rate limits and sessions
If you make too many authentication attempts, the Skype API may temporarily rate limit you, or require a captcha to continue. For the latter, you will need to complete this in a browser with a matching IP address.
To avoid this, you should reuse the Skype token where possible. A token only appears to last 24 hours (web.skype.com forces re-authentication after that time), though you can check the expiry with sk.tokenExpiry. Pass a filename as the third argument to the Skype() constructor to read and write session information to that file.
Event processing
Make your class a subclass of SkypeEventLoop, then override the onEvent(event) method to handle incoming messages and other events:
from skpy import SkypeEventLoop, SkypeNewMessageEvent
class SkypePing(SkypeEventLoop):
def __init__(self):
super(SkypePing, self).__init__(username, password)
def onEvent(self, event):
if isinstance(event, SkypeNewMessageEvent) \
and not event.msg.userId == self.userId \
and "ping" in event.msg.content:
event.msg.chat.sendMsg("Pong!")
Create an instance and call its loop() method to start processing events. For programs with a frontend (e.g. a custom client), you’ll likely want to put the event loop in its own thread.
Tests and documentation
Unit tests can be found in the test folder – client test cases are designed to test the library’s behaviour and parsing of mocked API responses, whereas server cases connect to the live Skype API.
The SkPy docs repo holds, in addition to docs for this library, a collection of unofficial documentation for the Skype HTTP APIs at large.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file SkPy-0.10.7.tar.gz
.
File metadata
- Download URL: SkPy-0.10.7.tar.gz
- Upload date:
- Size: 53.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3fd72ac4aeb803644a2ec20003baa92b46e1173f4358cc62621d42fc1852b66b |
|
MD5 | 39d36a6d13fc1aa833e87e204df4ca47 |
|
BLAKE2b-256 | f9517b113f0d75da4da8d0acb0db994c58bc13dc71098938c4e1be4eb415a1a7 |
File details
Details for the file SkPy-0.10.7-py3-none-any.whl
.
File metadata
- Download URL: SkPy-0.10.7-py3-none-any.whl
- Upload date:
- Size: 49.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2843479c691ceecdf32a8a1cb0f1aa03b55059334b2efc30f42cd1044533557b |
|
MD5 | cf83759912ef13a836b4ade197b31119 |
|
BLAKE2b-256 | 91e5c70389cba6146b26cb19644d272ec4d054c9f81efd3b020f77ff6cd1da59 |