Select Page

Python Connection Example

  Basic connection code, works on virtually all MLS's that don't require a specific user-agent
import librets

class rets_connection:
  simple static object to keep all our credentials in one spot, for production code this might be a wrapper for a DB 
  or config file.
   user_id = "Joe"
   passwd = "Schmoe"
   login_url = ""

   session = librets.RetsSession(rets_connection.login_url)
   #At this point you're connected to the Rets server, but not authenticated so not even worth checking for success
   #If you need to change user-agent (Rapattoni servers)
   if (not session.Login(rets_connection.user_id, rets_connection.passwd)):
   metadata = session.GetMetadata()
   systemdata = metadata.GetSystem()
   for attribute in systemdata.GetAttributeNames():
         print attribute, systemdata.GetStringAttribute(attribute)

except Exception, e:
   print "Exception: ", e
DLU March 16th, 2016