IQ Stanza#

class slixmpp.stanza.Iq(*args, recv=False, **kwargs)[source]#

XMPP <iq> stanzas, or info/query stanzas, are XMPP’s method of requesting and modifying information, similar to HTTP’s GET and POST methods.

Each <iq> stanza must have an ‘id’ value which associates the stanza with the response stanza. XMPP entities must always be given a response <iq> stanza with a type of ‘result’ after sending a stanza of type ‘get’ or ‘set’.

Most uses cases for <iq> stanzas will involve adding a <query> element whose namespace indicates the type of information desired. However, some custom XMPP applications use <iq> stanzas as a carrier stanza for an application-specific protocol instead.

Example <iq> Stanzas:

<iq to="" type="get" id="314">
  <query xmlns="" />

<iq to="user@localhost" type="result" id="17">
  <query xmlns='jabber:iq:roster'>
    <item jid=''
          name='John Doe'
Stanza Interface:
  • query: The namespace of the <query> element if one exists.

  • types: May be one of: get, set, result, or error.


Remove the <query> element.


Return the namespace of the <query> element.

Return type



Create a new <iq> stanza replying to self.

Overrides StanzaBase.reply

Sets the ‘type’ to ‘result’ in addition to the default StanzaBase.reply behavior.


clear (bool) – Indicates if existing content should be removed before replying. Defaults to True.

send(callback=None, timeout=None, timeout_callback=None)[source]#

Send an <iq> stanza over the XML stream.

A callback handler can be provided that will be executed when the Iq stanza’s result reply is received.

Returns a future which result will be set to the result Iq if it is of type ‘get’ or ‘set’ (when it is received), or a future with the result set to None if it has another type.

Overrides StanzaBase.send

  • callback (function) – Optional reference to a stream handler function. Will be executed when a reply stanza is received.

  • timeout (int) – The length of time (in seconds) to wait for a response before the timeout_callback is called, instead of the regular callback

  • timeout_callback (function) – Optional reference to a stream handler function. Will be executed when the timeout expires before a response has been received for the originally-sent IQ stanza.

Return type



Set the XML contents of the <iq> stanza.


value (list or XML object) – An XML object or a list of XML objects to use as the <iq> stanza’s contents


Add or modify a <query> element.

Query elements are differentiated by their namespace.


value (str) – The namespace of the <query> element.


Send a feature-not-implemented error if the stanza is not handled.

Overrides StanzaBase.unhandled.