Preliminary

pip install itchat

Note: the API changes quite often, but documentations does not. What I suggest is install from git:

git clone https://github.com/littlecodersh/ItChat.git

and stick to a stable version (current version: v1.3.9, July 15, 2017).

Start

import itchat
itchat.auto_login(enableCmdQR=True)

 

Class

itchat.storage.templates.User

  • UserName (string): a long string that starts with ‘@’
  • City (string): city
  • DisplayName
  • UniFriend
  • MemberList
  • PYQuanPin
  • Province (string): province
  • RemarkName (string): the remark name of the person (input by yourself)
  • ChatRoomId
  • AttrStatus
  • MemberCount
  • Alias
  • Signature (string): signature
  • NickName (string): the name of the person
  • HeadImgUrl (string): a relative url to the head image
  • Sex (int): 1 for male; 2 for female; (default 0)
  • StarFriend
  • Statues

 

 

Friends API

itchat.get_friends()

returns a itchat.storage.templates.ContactList object, which contains a list ofitchat.storage.templates.User object.

 

 

Message API

itchat.send(message: string, username: string)