Search code examples
phpmysqlsearch-engine

Best practise for merging several APIs


all experienced programmers. I need advice on following.

What would be the best practice for the following problem

We have 2-3 apis of objects(apartments) (XML, JSON , SOAP , protocol doesn't matter now)

Each of them has several keypoints

a) Geographics - Each api has its own GeoDatabase with own names and IDs for the same cities and places

b) Each api has different ways of object attribute description ... like what a house has(swimming pool, wheelchair friendly, etc )

So what we need is to import those data , merge them locally and search ....

What would be architecturally the right way of this type of problem solving....

A very near example is hotel search engines , where they are searching the data from 10-20 different systems. ...

So we need a similar stuff but totally on another type of objects. Your notes , comments and answers are really appreciated . Thanks a lot for participating.


Solution

  • This is a very generic question, so sadly the answer will be pretty generic too. I would approach this problem so:

    • Create wrappers for each of the various APIs, this will standardize the way in which they are internally invoked, making it easier to interact with them.

    • Convert all the results into a uniform format (if possible), at least those fields which will be searched, sorted, acted upon.

    If you persist this information into database, then it would be important to make the structure in such a way that it is easily query-able.

    E.g. Storing a whole JSON string that defines a house into a field called description is not desirable. So is having fields created for each attribute of the house like swimming pool (BOOLEAN yes/no). Instead have key-value fields like attribute-name and attribute-value which might have records like:

    • swimming pool: YES
    • No: of bedrooms: THREE

    etc. You get the point. From my experience, as much you can have a unified data model into which you can mould the API value to be contained, the easier it will be to collate and compare them.