2

I'm currently working on an website and pulling in listings from the RETS (Real Estate Transaction Standard) API. I have everything working fine, but my issue comes when trying to dig deeper with queries. For reference i'm using Node RETS Client but i'm not sure it has anything to do with the issue.

When i run the following query, it returns results from the appropriate association (REBGV = Real Estate Board of Greater Vancouver)

{ QueryType: 'DMQL2',
 Format: 'COMPACT-DECODED',
 Count: 1,
 StandardNames: 0,
 RestrictedIndicator: '***',
 Limit: 10,
 SearchType: 'Property',
 Class: 'RD_1',
 Query: '(LM_Char10_4=REBGV)' }

However when I run this query, I get the error Illegal number in range for field [L_Area]:

{ QueryType: 'DMQL2',
 Format: 'COMPACT-DECODED',
 Count: 1,
 StandardNames: 0,
 RestrictedIndicator: '***',
 Limit: 10,
 SearchType: 'Property',
 Class: 'RD_1',
 Query: '(LM_Char10_4=REBGV),(L_Area=Vancouver)' }

... which is confusing to me since there are no numbers anywhere in that option. Has anybody encountered something like this or have any insight into what i'm doing wrong in the query?

Shan Robertson
  • 2,742
  • 3
  • 25
  • 43
  • Haven't messed with RETS, but... have you tried using a number? Does it work? It's possible there's another API endpoint for looking up the ID number by the name of the area, so that you can translate `Vancouver` into `nnnn` – jpaugh Jan 29 '18 at 19:52
  • 1
    damnit you are right! It takes a number. Not that the metadata or response ever uses a number to tell you.... Thank you! – Shan Robertson Jan 29 '18 at 20:00
  • NP! Never trust an API that calls itself `REST`... or in this case, `RETS`! – jpaugh Jan 29 '18 at 20:09
  • BTW, when you figure out how to translate areas into the correct IDs, I recommend posting a self-answer that demonstrates that. That would be more helpful to someone else than for me to answer with 'I got lucky.' – jpaugh Jan 29 '18 at 20:11
  • man, this API is like none other, so terrible to use. But yes i'm definitely going to answer once i get a good solution. Thanks! – Shan Robertson Jan 29 '18 at 20:13

1 Answers1

2

Figured it out using the Node RETS Client but i'll post anyways to maybe help somebody along if they come across this.

When you get the metadata for a class, it gives you the appropriate names for finding out more info in different contexts

{ 
  MetadataEntryID: '0166D2F74FDC3AF8',
  SystemName: 'L_Area',
  StandardName: 'ListingArea',
  LongName: 'Area',
  DBName: 'Area',
  ShortName: 'Area',
  MaximumLength: '5',
  DataType: 'Small',
  Precision: '',
  Searchable: '1',
  Interpretation: 'Lookup',
  Alignment: 'Right',
  UseSeparator: '0',
  EditMaskID: 'int_5',
  LookupName: 'Area',
}

In my case, the area field is actually referenced by numbers, so to get a list of all the possible values for a field, you use the 'METADATA-LOOKUP-TYPE' header. In Node Rets client this is done like so

client.metadata.getLookupTypes("Property", "Area")

So it searches in the Property class for the field with the LookupName of Area which then returns a nice list of all the possible values.

Then when you query, you can search like (L_Area=1,2,3) and know what areas you are searching for.

Shan Robertson
  • 2,742
  • 3
  • 25
  • 43