sparkapi / sparkapi4p2

A PHP wrapper for the flexmls REST API.
GNU General Public License v3.0
26 stars 28 forks source link

Retrieve listing photos using MLS number instead of Listing ID ? #53

Closed ygagnon closed 3 years ago

ygagnon commented 3 years ago

Good afternoon. I've been experimenting with the GetListingPhotos() method within the client library, It's apparent that it needs to be seeded with the listing ID number in order for it to work,, .. but I was wondering .. would it be at all possible to retrieve the photos by seeding using the MLS number .. instead of the Listing ID number? If so, .. how? And could it be done without having to query the API twice in a row? (first time = to retreive the listing id number -- PLUS -- second time to retrieve the photos).

Please advise.

Thanks! -- Yvan

dgmyrek commented 3 years ago

The underlying /listings/xx/photos service (http://sparkplatform.com/docs/api_services/listings/photos) for that method does require the ListingKey rather than ListingId (MLS #) in the service route. It would not be possible to hit that endpoint directly without first obtaining the ListingKey.

An alternative approach would be to instead use this service https://github.com/sparkapi/sparkapi4p2/blob/master/lib/Core.php#L375 with a _filter parameter like ListingId Eq 'MLS#HERE' and also include a _select or _expand of "Photos".

ygagnon commented 3 years ago

Thanks for your response! I just tested the GetListings() method with an _expand of "Photos" as you suggested, and it worked wonderfully just as I'd hoped it would.

Just one more quick question for you. Is the GetListings() method filtered with the ListingId just as effective as the GetListingPhotos() method seeded with the ListingKey? I ask because I presume that some of these data columns are indexed and likely faster and more efficient to run queries with. Or am I mistaken about that and both methods are actually equal with regards to speed / performance?

Thanks, -- Yvan

dgmyrek commented 3 years ago

There may be a small efficiency loss when using the _filter method, however, the difference is so small that it should be effectively unnoticeable to a consumer.