Closed samgabrail closed 6 years ago
Hey @samgabrail. Can you provide the code that you're executing? Is it the usage guide verbatim?
I'm seeing correct output when I run it locally.
It feels like you're simply returning or outputting the result of the realtor.post method, when you need to chain .then and pass in a callback instead.
Yeah I ran the exact same code as in the usage guide. I first ran it as a JavaScript file and got no output except for the URL from the console.log command. I then ran it with node interactively and pasted the output that I got. What would I expect as the Json response? Would it be the listings of all the properties that match the URL?
Try this:
realtor.post(opts)
.then(data => {
console.log(data);
});
You'll need to define the opts
and realtor
as in the usage guide.
Hi @Froren yeah this worked and is returning results! Thanks! But it doesn't seem to paginate? I only see results from page 1 (9 total results because the RecordsPerPage is set to 9).
realtor.post(opts)
.then(data => {
console.log(data.Results);
console.log(data.Paging);
var counter = 0
for (i in data.Results){
counter+=1;
}
console.log("The count is: " + counter);
});
{ RecordsPerPage: 9, CurrentPage: 1, TotalRecords: 220764, MaxRecords: 500, TotalPages: 56, RecordsShowing: 500, Pins: 574 } The count is: 9
The other thing is that it shows MaxRecords of 500 is this a limitation or can it be increased? I tried defining MaximumResults: 1000000 but still shows up as 500
Thanks!!
Glad to hear it's working. You can set RecordsPerPage
as an option to be higher to get more results, though I think it maxes at 200.
How are you paging? You can navigate pages by increasing the CurrentPage
option.
Also, instead of looping over results with a counter, you can do data.Results.length
to verify the quantity.
CurrentPage
option is what I needed!! Thanks!
I have to say you did a pretty good job with this API!
What I still can't understand is the TotalPages
. In the example below I see that the TotalPages
is 3, when the TotalRecords
is 1499 and the RecordsPerPage
is 200.
I decided to ignore the TotalPages
and set CurrentPage
to higher than the TotalPages
and I'm getting results.
CurrentPage
= 8:{ RecordsPerPage: 200, CurrentPage: 8, TotalRecords: 1499, MaxRecords: 500, TotalPages: 3, RecordsShowing: 500, Pins: 766 } https://www.realtor.ca/Residential/Map.aspx#LongitudeMin=-79.6758985519409&LongitudeMax=-79.6079635620117&LatitudeMin=43.57601549736786&LatitudeMax=44.602250137362276&PriceMin=100000&RecordsPerPage=200&CurrentPage=8 Number of Results: 99
CurrentPage
= 9 gives 0 results which makes sense.{ RecordsPerPage: 200, CurrentPage: 9, TotalRecords: 1499, MaxRecords: 500, TotalPages: 3, RecordsShowing: 500, Pins: 766 } https://www.realtor.ca/Residential/Map.aspx#LongitudeMin=-79.6758985519409&LongitudeMax=-79.6079635620117&LatitudeMin=43.57601549736786&LatitudeMax=44.602250137362276&PriceMin=100000&RecordsPerPage=200&CurrentPage=9 Number of Results: 0
Also, what are MaxRecords
and RecordsShowing
? They always seem to be at 500.
I tried one last experiment to and put the RecordsPerPage
=9 and found that the TotalPages
=56. So it seems to be that the TotalPages
=ceiling(MaxRecords/RecordsPerPage)
{ RecordsPerPage: 9, CurrentPage: 8, TotalRecords: 1499, MaxRecords: 500, TotalPages: 56, RecordsShowing: 500, Pins: 766 } https://www.realtor.ca/Residential/Map.aspx#LongitudeMin=-79.6758985519409&LongitudeMax=-79.6079635620117&LatitudeMin=43.57601549736786&LatitudeMax=44.602250137362276&PriceMin=100000&RecordsPerPage=9&CurrentPage=8 Number of Results: 9
Finally, are Pins
just the longitude and latitude of the properties?
Hey @samgabrail, thanks for the praise! But I didn't do anything except hack together a way to call the API outside of the webpage. The team behind realtor.ca
are the ones who deserve the credit.
I appreciate your research, I wasn't aware that MaxRecords
and RecordsShowing
were always at 500. Nor the fact that TotalPages
was even an attribute.
The pins are indeed the lat and long coordinates with the results.
Good stuff and thanks for all your help!
Sorry I had to open this issue as I'm not sure if this is still working properly.
I've followed your Usage guide but not sure what to expect in the response to the POST. I'm getting the below. Is this still working?
Promise { _bitField: 0, _fulfillmentHandler0: undefined, _rejectionHandler0: undefined, _promise0: undefined, _receiver0: undefined, _cancellationParent: Promise { _bitField: 1, _fulfillmentHandler0: undefined, _rejectionHandler0: { [Function: runBound] domain: [Domain] }, _promise0: [Circular], _receiver0: undefined, _cancellationParent: Promise { _bitField: 1, _fulfillmentHandler0: [Function], _rejectionHandler0: undefined, _promise0: [Circular], _receiver0: undefined, _onCancelField: [Function], _branchesRemainingToCancel: 1 }, _branchesRemainingToCancel: 1 } }