How to make a RETS request
A RETS server is basically a web server that talks HTTP. If you are familiar with making calls to REST API endpoints you'll feel right at home. Before you can get any information from the server you must authenticate your client. Our server uses Digest Authentication to authenticate clients.
Note: There are several free and open source tools that are available that handle the technical aspects of issuing requests and reading responses to and from a RETS server. Many of the specific details mentioned here are handled automatically behind-the-scenes within most RETS clients.
Terminology
Resource – Best thought of as a main category. Examples: “Property”, “Agent”, “Office”. These names are defined in the RETS specification and are consistent across RETS servers.
Class – Best thought of as a sub category. Examples: The “Property” Resource may have Classes such as “tt_res” for Residential, “tt_land” for Land, “tt_res_lease” for Residential Lease, etc. while the “Agent” Resource may have a class such as “Agent”. Each Class represents a different fieldset, allowing (for example) Residential to include fields that Land may not need.
Lookup – When a specific field is described as having Lookup values, the content of that field can only contain a pre-determined set of values. To learn what those values are and what they stand for, a request can be made that returns a list of all possible values within that field. An example would be the Listing Status field to learn that the possible values are Active, Under Contract, Expired, Sold, etc.
COMPACT – This is one format responses can be returned as (you’ll see it used often in the examples below). The contents of these responses are returned back in a tab delimited format. COMPACT-DECODED is a very similar format except that fields containing Lookup values have their codes replaced with their human-readable meanings.
For a full glossary of commonly used terms related to RETS, see www.rets.org/glossary.
Recipes
Below is are some examples of how to perform various tasks.
Authentication
Step 1 - Make a request to get a session cookie
Request:
GET /contact/rets/login HTTP/1.1
Host: rets18.utahrealestate.com
Accept: */*
RETS-Version: RETS/1.8
User-Agent: YourUserAgent
There are two headers that should be included with each request, RETS-Version and User-Agent. The RETS-Version is which RETS specification your client is using. Our server supports version 1.5, 1.7, 1.7.2 and 1.8. The User-Agent header is a string that represents the name of your client. This is important because we use the User-Agent to control what each client can do.
Response:
HTTP/1.1 401 Unauthorized
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=A743FD28E5D6D3D62D4073459D9286FF; Path=/contact/; HttpOnly
Set-Cookie: JSESSIONID=A743FD28E5D6D3D62D4073459D9286FF; Path=/contact
MIME-Version: 1.0
Cache-Control: private
RETS-Version: RETS/1.8
WWW-Authenticate: Digest realm="rets@retsiq.com",qop="auth",nonce="500e4fc7e5ffc3f9e55b89989fd94d38", opaque="5089f3bded782"
Content-Length: 0
Date: Thu, 22 Dec 2016 18:21:09 GMT
The server response includes a header to set a cookie. That cookie (JSESSIONID) is the token used to keep track of your authentication throughout your session. Each subsequent request must include that cookie. The server also includes a RETS-Version header as part of the response. That value will mimic you the value you sent of your request if that version of the RETS specification is supported. If the requested RETS version is not support the server will default to the 1.7.2 specification. That header will tell you the RETS specification that was used in creating the response to your request.
Step 2 - Make digest authentication request passing back the session cookie
Request:
GET /contact/rets/login HTTP/1.1
Authorization: Digest username="YOURLOGIN", realm="rets@retsiq.com", nonce="500e4fc7e5ffc3f9e55b89989fd94d38", uri="/contact/rets/login", cnonce="MTQ4MjQz", nc=00000001, qop="auth", response="e874b07616af5d923eb22b10db917cfa", opaque="5089f3bded782"
Host: rets18.utahrealestate.com
Cookie: JSESSIONID=A743FD28E5D6D3D62D4073459D9286FF; JSESSIONID=A743FD28E5D6D3D62D4073459D9286FF
Accept: */*
RETS-Version: RETS/1.8
User-Agent: YourUserAgent
Response:
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=A743FD28E5D6D3D62D4073459D9286FF; Path=/contact
MIME-Version: 1.0
Cache-Control: private
RETS-Version: RETS/1.8
Set-Cookie: RETS-Session-ID=e89d6972233a672cbae953e70699beb215927c3f489; Path=/contact
Content-Type: text/xml
Content-Length: 791
Date: Thu, 22 Dec 2016 18:21:10 GMT
Proxy-Connection: Keep-alive
<RETS ReplyCode="0" ReplyText="Operation Successful">
<RETS-RESPONSE>
Info=BROKERCODE;Character;YOURLOGIN
Info=MEMBERNAME;Character;AgentWebsitesUtah.com - Clientopoly
Info=MetadataTimestamp;DateTime;2016-12-21T20:15:49
Info=MetadataVersion;Character;1.00.00191
Info=MinMetadataTimestamp;DateTime;2016-12-21T20:15:49
Info=TimeoutSeconds;Int;1800000
Info=USERID;Character;YOURLOGIN
Info=USERCLASS;Character;VENDOR
Info=USERLEVEL;Int;0
Info=AGENTCODE;Character;YOURLOGIN
Action=/contact/rets/action
GetMetadata=/contact/rets/getMetadata
GetObject=/contact/rets/getObject
Login=/contact/rets/login
Logout=/contact/rets/logout
PostObject=/contact/rets/postObject
Search=/contact/rets/search
X-Selector=/contact/rets/selector
Update=/contact/rets/update
</RETS-RESPONSE>
</RETS>
If your authentication fails you will again receive a 401 Unauthorized response. Please check your credentials and try again.
If you receive a 200 OK response, your session is now authenticated. The body of the response will include an XML document with some important information. The most important are the GetMetadata and Search values. The GetMetadata location is where your client can pull detailed information about the resouces and data you have access to. The Search location is where you client will pull all information.
Step 3 - Logout
Request:
GET /contact/rets/logout HTTP/1.1
Authorization: Digest username="YOURLOGIN", realm="rets@retsiq.com", nonce="500e4fc7e5ffc3f9e55b89989fd94d38", uri="/contact/rets/logout", cnonce="MTQ4MjQz", nc=00000008, qop="auth", response="b5a208a4dc1dd04bc664c9129fe38975", opaque="5089f3bded782"
Host: rets18.utahrealestate.com
Cookie: JSESSIONID=A743FD28E5D6D3D62D4073459D9286FF; RETS-Session-ID=e89d6972233a672cbae953e70699beb215927c3f489; JSESSIONID=A743FD28E5D6D3D62D4073459D9286FF
Accept: */*
RETS-Version: RETS/1.8
User-Agent: YourUserAgent
Response:
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=A743FD28E5D6D3D62D4073459D9286FF; Path=/contact
MIME-Version: 1.0
Cache-Control: private
RETS-Version: RETS/1.8
Content-Type: text/xml
Content-Length: 142
Date: Thu, 22 Dec 2016 18:21:14 GMT
Proxy-Connection: Keep-alive
<RETS ReplyCode="0" ReplyText="Operation Successful">
<RETS-RESPONSE>
ConnectTime=3
SignOffMessage=Logged out.
</RETS-RESPONSE>
</RETS>
Get System Metadata
Step 1 - Authenticate
Step 2 - request system metadata
Request:
GET /contact/rets/getMetadata?Type=METADATA-RESOURCE&ID=%2A&Format=STANDARD-XML HTTP/1.1
Authorization: Digest username="YOURLOGIN", realm="rets@retsiq.com", nonce="500e4fc7e5ffc3f9e55b89989fd94d38", uri="/contact/rets/getMetadata?Type=METADATA-RESOURCE&ID=%2A&Format=STANDARD-XML", cnonce="MTQ4MjQz", nc=00000003, qop="auth", response="89ab6ec658df9d04754a15ee81d46b54", opaque="5089f3bded782"
Host: rets18.utahrealestate.com
Cookie: JSESSIONID=A743FD28E5D6D3D62D4073459D9286FF; RETS-Session-ID=e89d6972233a672cbae953e70699beb215927c3f489; JSESSIONID=A743FD28E5D6D3D62D4073459D9286FF
Accept: */*
RETS-Version: RETS/1.8
User-Agent: YourUserAgent
Response:
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=A743FD28E5D6D3D62D4073459D9286FF; Path=/contact
MIME-Version: 1.0
Cache-Control: private
RETS-Version: RETS/1.8
Content-ID: METADATA-RESOURCE
Content-Type: text/xml
Date: Thu, 22 Dec 2016 18:21:10 GMT
Transfer-Encoding: chunked
Proxy-Connection: Keep-alive
<RETS ReplyCode="0" ReplyText="Operation Successful">
<METADATA>
<METADATA-RESOURCE Date="2016-12-21T20:15:49" Version="1.00.00191">
<Resource>
... body to long
</Resource>
</METADATA-RESOURCE>
</METADATA>
</RETS>
This request will return the MetaData for the entire system that you have access to. The complete XML document is very long and was not included. You can request COMPACT as the value of the Format variable to receive a plain text version.
Step 3 - Logout
Discover all Classes for the Property resource
Step 1 - Authenticate
Step 2 - request classes for the property resource
Request:
GET /contact/rets/getMetadata?Type=METADATA-CLASS&ID=Property&Format=STANDARD-XML HTTP/1.1
Authorization: Digest username="YOURLOGIN", realm="rets@retsiq.com", nonce="500e4fc7e5ffc3f9e55b89989fd94d38", uri="/contact/rets/getMetadata?Type=METADATA-CLASS&ID=Property&Format=STANDARD-XML", cnonce="MTQ4MjQz", nc=00000004, qop="auth", response="dff464c41f472216d536975729d75938", opaque="5089f3bded782"
Host: rets18.utahrealestate.com
Cookie: JSESSIONID=A743FD28E5D6D3D62D4073459D9286FF; RETS-Session-ID=e89d6972233a672cbae953e70699beb215927c3f489; JSESSIONID=A743FD28E5D6D3D62D4073459D9286FF
Accept: */*
RETS-Version: RETS/1.8
User-Agent: YourUserAgent
Resposne:
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=A743FD28E5D6D3D62D4073459D9286FF; Path=/contact
MIME-Version: 1.0
Cache-Control: private
RETS-Version: RETS/1.8
Content-ID: METADATA-CLASS
Content-Type: text/xml
Date: Thu, 22 Dec 2016 18:21:13 GMT
Transfer-Encoding: chunked
Proxy-Connection: Keep-alive
<RETS ReplyCode="0" ReplyText="Operation Successful">
<METADATA>
<METADATA-CLASS Resource="Property" Date="2016-11-21T18:11:34" Version="1.00.00110">
<Class>
<ClassName>tt_res</ClassName>
<StandardName/>
<VisibleName>tt_res</VisibleName>
<Description>tt_res</Description>
<TableVersion>1.00.00018</TableVersion>
<TableDate>2016-10-27T20:40:08</TableDate>
<UpdateVersion>1.00.00000</UpdateVersion>
<UpdateDate>2015-10-28T21:43:46</UpdateDate>
<ClassTimeStamp/>
<DeletedFlagField/>
<DeletedFlagValue/>
<HasKeyIndex>1</HasKeyIndex>
<OffsetSupport/>
</Class>
... body to long
</METADATA-CLASS>
</METADATA>
</RETS>
Step 3 - Logout
Discover detailed field information for the tt_res class
Step 1 - Authenticate
Step 2 - request classes for the property resource
Request:
GET /contact/rets/getMetadata?Type=METADATA-TABLE&ID=Property%3Att_res&Format=STANDARD-XML HTTP/1.1
Authorization: Digest username="YOURLOGIN", realm="rets@retsiq.com", nonce="500e4fc7e5ffc3f9e55b89989fd94d38", uri="/contact/rets/getMetadata?Type=METADATA-TABLE&ID=Property%3Att_res&Format=STANDARD-XML", cnonce="MTQ4MjQz", nc=00000005, qop="auth", response="bf553a2fd2cb6e4600371c3ce9008db4", opaque="5089f3bded782"
Host: rets18.utahrealestate.com
Cookie: JSESSIONID=A743FD28E5D6D3D62D4073459D9286FF; RETS-Session-ID=e89d6972233a672cbae953e70699beb215927c3f489; JSESSIONID=A743FD28E5D6D3D62D4073459D9286FF
Accept: */*
RETS-Version: RETS/1.8
User-Agent: YourUserAgent
Response:
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=A743FD28E5D6D3D62D4073459D9286FF; Path=/contact
MIME-Version: 1.0
Cache-Control: private
RETS-Version: RETS/1.8
Content-ID: METADATA-TABLE
Content-Type: text/xml
Date: Thu, 22 Dec 2016 18:21:13 GMT
Transfer-Encoding: chunked
Proxy-Connection: Keep-alive
<RETS ReplyCode="0" ReplyText="Operation Successful">
<METADATA>
<METADATA-TABLE Class="tt_res" Resource="Property" Date="2016-10-27T20:40:08" Version="1.00.00018">
... response truncated
<Field>
<MetadataEntryID>listno</MetadataEntryID>
<SystemName>listno</SystemName>
<StandardName/>
<LongName>listno</LongName>
<DBName/>
<ShortName>listno</ShortName>
<MaximumLength>11</MaximumLength>
<DataType>Int</DataType>
<Precision/>
<Searchable>1</Searchable>
<Interpretation/>
<Alignment/>
<UseSeparator/>
<EditMaskID/>
<LookupName/>
<MaxSelect/>
<Units/>
<Index>1</Index>
<Minimum/>
<Maximum/>
<Default/>
<Required/>
<SearchHelpID/>
<Unique>1</Unique>
<ModTimeStamp/>
<ForeignKeyName/>
<ForeignField/>
<InKeyIndex>1</InKeyIndex>
<FilterParentField/>
<DefaultSearchOrder/>
<Case/>
</Field>
<Field>
<MetadataEntryID>listprice</MetadataEntryID>
<SystemName>listprice</SystemName>
<StandardName/>
<LongName>listprice</LongName>
<DBName/>
<ShortName>listprice</ShortName>
<MaximumLength>11</MaximumLength>
<DataType>Int</DataType>
<Precision/>
<Searchable>1</Searchable>
<Interpretation/>
<Alignment/>
<UseSeparator/>
<EditMaskID/>
<LookupName/>
<MaxSelect/>
<Units/>
<Index>1</Index>
<Minimum/>
<Maximum/>
<Default/>
<Required/>
<SearchHelpID/>
<Unique/>
<ModTimeStamp/>
<ForeignKeyName/>
<ForeignField/>
<InKeyIndex/>
<FilterParentField/>
<DefaultSearchOrder/>
<Case/>
</Field>
<Field>
<MetadataEntryID>status</MetadataEntryID>
<SystemName>status</SystemName>
<StandardName/>
<LongName>status</LongName>
<DBName/>
<ShortName>status</ShortName>
<MaximumLength>4</MaximumLength>
<DataType>Tiny</DataType>
<Precision/>
<Searchable>1</Searchable>
<Interpretation>Lookup</Interpretation>
<Alignment/>
<UseSeparator/>
<EditMaskID/>
<LookupName>STATUS</LookupName>
<MaxSelect/>
<Units/>
<Index>1</Index>
<Minimum/>
<Maximum/>
<Default/>
<Required/>
<SearchHelpID/>
<Unique/>
<ModTimeStamp/>
<ForeignKeyName/>
<ForeignField/>
<InKeyIndex/>
<FilterParentField/>
<DefaultSearchOrder/>
<Case/>
</Field>
... body to long
</METADATA-TABLE>
</METADATA>
</RETS>
The tt_res table has to many fields to include all of their definitions here. I have included only listno, listprice and status. Each field definition includes everything you need to know to use the field. Most of the information is self explanatory. However, the status field is a lookup field. That means that value contained in the data can be translasted into text. A lookup field has an associated list of possible lookup values. Those are inclueded in the system metadata or can be discovered individually.
Step 3 - Logout
Discover all values for a listings status field
Step 1 - Authenticate
Step 2 - request lookup values for status in the Property resource
Request:
GET /contact/rets/getMetadata?Type=METADATA-LOOKUP_TYPE&ID=Property%3ASTATUS&Format=STANDARD-XML HTTP/1.1
Authorization: Digest username="YOURLOGIN", realm="rets@retsiq.com", nonce="500e4fc7e5ffc3f9e55b89989fd94d38", uri="/contact/rets/getMetadata?Type=METADATA-LOOKUP_TYPE&ID=tt_res%3Astatus&Format=STANDARD-XML", cnonce="MTQ4MjQz", nc=00000006, qop="auth", response="2a7a0549a83835f29839e4ae0b11c6e4", opaque="5089f3bded782"
Host: rets18.utahrealestate.com
Cookie: JSESSIONID=A743FD28E5D6D3D62D4073459D9286FF; RETS-Session-ID=e89d6972233a672cbae953e70699beb215927c3f489; JSESSIONID=A743FD28E5D6D3D62D4073459D9286FF
Accept: */*
RETS-Version: RETS/1.8
User-Agent: YourUserAgent
Response:
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=A743FD28E5D6D3D62D4073459D9286FF; Path=/contact
MIME-Version: 1.0
Cache-Control: private
RETS-Version: RETS/1.8
Content-ID: METADATA-LOOKUP_TYPE
Content-Type: text/xml
Date: Thu, 22 Dec 2016 18:21:14 GMT
Transfer-Encoding: chunked
Proxy-Connection: Keep-alive
<RETS ReplyCode="0" ReplyText="Operation Successful">
<METADATA>
<METADATA-LOOKUP_TYPE Lookup="STATUS" Resource="Property" Date="2016-10-19T18:47:03" Version="1.00.00003">
<LookupType>
<MetadataEntryID>1</MetadataEntryID>
<LongValue>Active</LongValue>
<ShortValue>Active</ShortValue>
<Value>1</Value>
</LookupType>
<LookupType>
<MetadataEntryID>2</MetadataEntryID>
<LongValue>Active-TC</LongValue>
<ShortValue>Active-TC</ShortValue>
<Value>2</Value>
</LookupType>
<LookupType>
<MetadataEntryID>20</MetadataEntryID>
<LongValue>Leased</LongValue>
<ShortValue>Leased</ShortValue>
<Value>20</Value>
</LookupType>
<LookupType>
<MetadataEntryID>3</MetadataEntryID>
<LongValue>Under Contract</LongValue>
<ShortValue>Under Contract</ShortValue>
<Value>3</Value>
</LookupType>
<LookupType>
<MetadataEntryID>4</MetadataEntryID>
<LongValue>Withdrawn</LongValue>
<ShortValue>Withdrawn</ShortValue>
<Value>4</Value>
</LookupType>
<LookupType>
<MetadataEntryID>40</MetadataEntryID>
<LongValue>Withdrawn(Unconditional)</LongValue>
<ShortValue>Withdrawn(Unconditional)</ShortValue>
<Value>40</Value>
</LookupType>
<LookupType>
<MetadataEntryID>5</MetadataEntryID>
<LongValue>Offmarket</LongValue>
<ShortValue>Offmarket</ShortValue>
<Value>5</Value>
</LookupType>
<LookupType>
<MetadataEntryID>6</MetadataEntryID>
<LongValue>Expired</LongValue>
<ShortValue>Expired</ShortValue>
<Value>6</Value>
</LookupType>
<LookupType>
<MetadataEntryID>7</MetadataEntryID>
<LongValue>Backup</LongValue>
<ShortValue>Backup</ShortValue>
<Value>7</Value>
</LookupType>
<LookupType>
<MetadataEntryID>8</MetadataEntryID>
<LongValue>Sold</LongValue>
<ShortValue>Sold</ShortValue>
<Value>8</Value>
</LookupType>
<LookupType>
<MetadataEntryID>9</MetadataEntryID>
<LongValue>Active-SS</LongValue>
<ShortValue>Active-SS</ShortValue>
<Value>9</Value>
</LookupType>
</METADATA-LOOKUP_TYPE>
</METADATA>
</RETS>
Step 3 - Logout
Preforming a query
Almost all information you receive from the RETS server is the result of a query. Included below are the steps to retrieving 20 listings that were modified after 12/22/2016 at 07:35:46.
Step 1 - Authenticate
Step 2 - make a request for records
Request:
GET /contact/rets/search?SearchType=Property&Class=tt_res&Query=%28dtlastmod%3D2016-12-22T07%3A36%3A46%2B%29&QueryType=DMQL2&Count=0&Format=COMPACT&Limit=20&Select=ListNo%2C+dtlastmod%2C+dtphoto%2C+status%2Cts HTTP/1.1
Authorization: Digest username="YOURLOGIN", realm="rets@retsiq.com", nonce="500e4fc7e5ffc3f9e55b89989fd94d38", uri="/contact/rets/search?SearchType=Property&Class=tt_res&Query=%28dtlastmod%3D2016-12-22T07%3A36%3A46%2B%29&QueryType=DMQL2&Count=0&Format=COMPACT&Limit=20&Select=ListNo%2C+dtlastmod%2C+dtphoto%2C+status%2Cts&StandardNames=0", cnonce="MTQ4MjQz", nc=00000007, qop="auth", response="dabadf0af0c65eb5c3ee23c8b38186eb", opaque="5089f3bded782"
Host: rets18.utahrealestate.com
Cookie: JSESSIONID=A743FD28E5D6D3D62D4073459D9286FF; RETS-Session-ID=e89d6972233a672cbae953e70699beb215927c3f489; JSESSIONID=A743FD28E5D6D3D62D4073459D9286FF
Accept: */*
RETS-Version: RETS/1.8
User-Agent: YourUserAgent
Response:
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=A743FD28E5D6D3D62D4073459D9286FF; Path=/contact
MIME-Version: 1.0
Cache-Control: private
RETS-Version: RETS/1.8
Content-Type: text/xml
Content-Length: 1880
Date: Thu, 22 Dec 2016 18:21:14 GMT
Proxy-Connection: Keep-alive
<RETS ReplyCode="0" ReplyText="Operation Successful">
<DELIMITER value="09" />
<COLUMNS> ListNo dtlastmod dtphoto status ts </COLUMNS>
<DATA> 1423569 2016-12-22T07:37:19 2016-12-22T07:05:49 1 2016-12-22T07:37:19 </DATA>
<DATA> 1422823 2016-12-22T07:40:27 2016-12-15T13:53:42 1 2016-12-22T07:40:27 </DATA>
<DATA> 1423571 2016-12-22T07:44:53 1800-01-01T00:00:00 1 2016-12-22T07:44:53 </DATA>
<DATA> 1400182 2016-12-22T07:47:37 2016-08-11T19:29:34 3 2016-12-22T07:47:37 </DATA>
<DATA> 1419110 2016-12-22T07:52:28 2016-11-16T16:08:46 1 2016-12-22T07:52:28 </DATA>
<DATA> 1410044 2016-12-22T08:19:23 2016-09-29T15:22:18 3 2016-12-22T08:19:23 </DATA>
<DATA> 1413458 2016-12-22T08:22:02 2016-10-15T20:59:57 3 2016-12-22T08:22:02 </DATA>
<DATA> 1422684 2016-12-22T08:23:23 2016-12-14T16:00:51 1 2016-12-22T08:23:23 </DATA>
<DATA> 1423572 2016-12-22T08:25:18 2016-12-22T08:18:58 1 2016-12-22T08:25:18 </DATA>
<DATA> 1422531 2016-12-22T08:28:09 2016-12-13T18:04:35 1 2016-12-22T08:28:09 </DATA>
<DATA> 1421809 2016-12-22T08:42:45 2016-12-16T10:23:42 1 2016-12-22T08:42:45 </DATA>
<DATA> 1422712 2016-12-22T08:43:17 2016-12-14T18:27:42 1 2016-12-22T08:43:17 </DATA>
<DATA> 1421726 2016-12-22T08:46:07 2016-12-07T09:38:47 3 2016-12-22T08:46:07 </DATA>
<DATA> 1421063 2016-12-22T08:49:29 2016-12-02T10:34:51 1 2016-12-22T08:49:29 </DATA>
<DATA> 1378606 2016-12-22T08:50:11 2016-08-01T11:00:08 1 2016-12-22T08:50:11 </DATA>
<DATA> 1423573 2016-12-22T08:50:20 2016-12-22T08:50:20 1 2016-12-22T08:50:20 </DATA>
<DATA> 1421913 2016-12-22T08:56:46 2016-12-08T12:23:14 3 2016-12-22T08:56:46 </DATA>
<DATA> 1423389 2016-12-22T08:58:19 2016-12-20T17:54:51 1 2016-12-22T08:58:19 </DATA>
<DATA> 1419192 2016-12-22T08:59:08 2016-11-18T13:29:30 1 2016-12-22T08:59:08 </DATA>
<DATA> 1422922 2016-12-22T09:00:15 2016-12-19T15:08:46 1 2016-12-22T09:00:15 </DATA>
<MAXROWS />
</RETS>
This query includes some of the possible options but not all that are used in receiving data by querying. Most of the queries you will create will follow is simmilar pattern.
SearchType = Property: This type of search if for Property records. The possible values of SearchType are the list of Resources you received from requesting the system metadata.
Class = tt_res: The class is the table that you want to retrieve data from. The list of classes you have access to is included in the response from requesting classes for a resource.
Query = (dtlastmod=2016-12-22T07:36:46+): The query is made up of the DMQL used to limit the results. This query is asking for records that have a dtlastmod (last modification datetime) greater "+" than 2016-12-22T07:36:46.
QueryType = DMQL2: This is the what DMLQ version to use to interpret your query.
Count = 0: This tells the server whether or not to return the total number of records that match the query. If it is set to "1" the count is included in the response. If it is set to "0" the count is not included. Note: to increase performance, if you do not need to know the number of results set this to "0". This will keep the server from dong an unnecessary query.
Format = COMPACT: This is what format you would like the records returned. Possible values include; COMPACT, COMPACT-DECODED,
Limit = 20: The Limit value will limit the number of records return from the server.
Select = ListNo, dtlastmod, dtphoto, status,ts: This is the list of fields that should be included in the result. If this is ommitted all fields will be returned.
Step 3 - Logout
Getting Photos
URLs to photos are stored in the Media table in the Media resource. We do not support GetObject transactions. You easily get all of the photos for a listing by doing a simple query.
Step 1 - Authenticate
Step 2 - make a request for the Media records.
Request:
GET /contact/rets/search?SearchType=Media&Class=Media&Query=%28listno%3D1419192%29&QueryType=DMQL2&Count=0&Format=COMPACT&Limit=99999999 HTTP/1.1
Authorization: Digest username="YOURLOGIN", realm="rets@retsiq.com", nonce="c97495a3003c8277b37d4dfcd54efec5", uri="/contact/rets/search?SearchType=Media&Class=Media&Query=%28listno%3D1419192%29&QueryType=DMQL2&Count=0&Format=COMPACT&Limit=99999999&StandardNames=0", cnonce="MTQ4MjQz", nc=00000003, qop="auth", response="836f016277dcf412f0b2a730fbec7714", opaque="eeb809d310180"
Host: rets18.utahrealestate.com
Cookie: JSESSIONID=A743FD28E5D6D3D62D4073459D9286FF; RETS-Session-ID=e89d6972233a672cbae953e70699beb215927c3f489; JSESSIONID=A743FD28E5D6D3D62D4073459D9286FF
Accept: */*
RETS-Version: RETS/1.8
User-Agent: YourUserAgent
Response:
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=B67F9EB93929AD9D4D7B29BD634C4911; Path=/contact
MIME-Version: 1.0
Cache-Control: private
RETS-Version: RETS/1.8
Content-Type: text/xml
Content-Length: 3065
Date: Thu, 22 Dec 2016 19:37:46 GMT
Proxy-Connection: Keep-alive
<RETS ReplyCode="0" ReplyText="Operation Successful">
<DELIMITER value="09" />
<COLUMNS> listno caption category lastmod name place title ts url </COLUMNS>
<DATA> 1419192 1 2016-12-22T09:15:05 1419192_0c1ea9d667815108dd38decae1a62f6e_3998388.jpg 2 2016-12-22T09:15:05 http://assets.utahrealestate.com/photos/640x480/1419192_0c1ea9d667815108dd38decae1a62f6e_3998388.jpg </DATA>
<DATA> 1419192 1 2016-12-22T09:15:05 1419192_1a4e80ac51c51ebc85cc597665650d2f_116814.jpg 11 2016-12-22T09:15:05 http://assets.utahrealestate.com/photos/640x480/1419192_1a4e80ac51c51ebc85cc597665650d2f_116814.jpg </DATA>
<DATA> 1419192 1 2016-12-22T09:15:05 1419192_274bfdeb113ad54878354611db85cb66_4023459.jpg 6 2016-12-22T09:15:05 http://assets.utahrealestate.com/photos/640x480/1419192_274bfdeb113ad54878354611db85cb66_4023459.jpg </DATA>
<DATA> 1419192 1 2016-12-22T09:15:05 1419192_5401425256f005fdf2fda7734385d343_190172.jpg 12 2016-12-22T09:15:05 http://assets.utahrealestate.com/photos/640x480/1419192_5401425256f005fdf2fda7734385d343_190172.jpg </DATA>
<DATA> 1419192 1 2016-12-22T09:15:05 1419192_5745132a495681ead62ff49069ddcb34_221410.jpg 9 2016-12-22T09:15:05 http://assets.utahrealestate.com/photos/640x480/1419192_5745132a495681ead62ff49069ddcb34_221410.jpg </DATA>
<DATA> 1419192 1 2016-12-22T09:15:05 1419192_783c5b92e0769eed7ea3af21787273b8_3592367.jpg 5 2016-12-22T09:15:05 http://assets.utahrealestate.com/photos/640x480/1419192_783c5b92e0769eed7ea3af21787273b8_3592367.jpg </DATA>
<DATA> 1419192 1 2016-12-22T09:15:05 1419192_7ce8c637d1b607e8aa4077c952f62f2c_137605.jpg 8 2016-12-22T09:15:05 http://assets.utahrealestate.com/photos/640x480/1419192_7ce8c637d1b607e8aa4077c952f62f2c_137605.jpg </DATA>
<DATA> 1419192 1 2016-12-22T09:15:05 1419192_b9cfd65940186cb4ffbdc2d059385ef2_3394775.jpg 1 2016-12-22T09:15:05 http://assets.utahrealestate.com/photos/640x480/1419192_b9cfd65940186cb4ffbdc2d059385ef2_3394775.jpg </DATA>
<DATA> 1419192 1 2016-12-22T09:15:05 1419192_cfc5119ab47d426b3ed70daf28b6e743_4032918.jpg 4 2016-12-22T09:15:05 http://assets.utahrealestate.com/photos/640x480/1419192_cfc5119ab47d426b3ed70daf28b6e743_4032918.jpg </DATA>
<DATA> 1419192 1 2016-12-22T09:15:05 1419192_dadd0d617d86ddd73310a03c5eca50e2_169033.jpg 0 2016-12-22T09:15:05 http://assets.utahrealestate.com/photos/640x480/1419192_dadd0d617d86ddd73310a03c5eca50e2_169033.jpg </DATA>
<DATA> 1419192 1 2016-12-22T09:15:05 1419192_ddadad88299d71434c275549568860ff_4098504.jpg 7 2016-12-22T09:15:05 http://assets.utahrealestate.com/photos/640x480/1419192_ddadad88299d71434c275549568860ff_4098504.jpg </DATA>
<DATA> 1419192 1 2016-12-22T09:15:05 1419192_eb0dbc442244ec316203ef2d955fe54d_45619.jpg 10 2016-12-22T09:15:05 http://assets.utahrealestate.com/photos/640x480/1419192_eb0dbc442244ec316203ef2d955fe54d_45619.jpg </DATA>
<DATA> 1419192 1 2016-12-22T09:15:05 1419192_f411e35847db1f4f61d1cea58f4ad7a9_49200.jpg 3 2016-12-22T09:15:05 http://assets.utahrealestate.com/photos/640x480/1419192_f411e35847db1f4f61d1cea58f4ad7a9_49200.jpg </DATA>
</RETS>
The only really interesting thing about this request is the query: (listno=1419192). This will limit the media records to any with a listno of 1419192.
The results contain all of the fields from this class:
listno | listing number |
caption | photo caption |
catagory | type of media resource |
lastmod | date/time record was modified |
name | photo name |
place | order of the photo |
title | photo title |
ts | date/time record was modified |
url | URL of the photo on the internets |