Add-ons

 / 

Module 'REST API'

Module 'REST API'

For using methods REST API turn on the module in the section "Settings" -> "Modules management ". Also check to option "Use REST API" is available to the user. You can activate or deactivate the use of REST API for a user in the admin panel when editing a user.



Authorization.

As authorization for REST API is used "BASIC" authorization: login – email user address, password - generated user token (a unique token is generated for each user). All API methods can only be used after authorization.


If you use PHP curl, then "BASIC" authorization can be executed using CURLOPT_USERPWD:

$ch = curl_init();
...
$defaultOptions = array(
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HEADER => 1,
    CURLOPT_USERPWD => 'adminre@monoray.net:174cc583994a138b2bb204a1e005186d',
);     
...
curl_setopt_array($ch, $options);

$response = curl_exec($ch);

if ($response === false) {
    throw new \CException(curl_error($ch), curl_errno($ch));
}

$info = curl_getinfo($ch);

$header = substr($response, 0, $info['header_size']);
$body = substr($response, $info['header_size']);

preg_match("/Location: (.*?)\n/", $header, $matches);
$location = isset($matches[1]) ? $matches[1] : null;

return array('body' => $body, 'code' => $info['http_code'], 'location' => $location);



List of listings.

You can obtain a list of listings by sending the GET request to the following URL: YOUR_SITE/api/apartments.

$ wget --output-document="D:\listing_index.json" --http-user="adminre@monoray.net" --http-password="174cc583994a138b2bb204a1e005186d" "YOUR_SITE/api/apartments"


You can also use additional parameters by sending the GET request to the following URL YOUR_SITE/api/apartments to search and get a list of listings with any characteristics.


For a list of listings from a particular country, add to the request "?country=185", where 185 – id of the country, in this case Russia.

$ wget --output-document="D:\listing_index.json" --http-user="adminre@monoray.net" --http-password="174cc583994a138b2bb204a1e005186d" "YOUR_SITE/api/apartments?country=185"

For obtaining a list of listings from Russia->Moscow send the GET request to the following URL: YOUR_SITE/api/apartments?country=185&region=524894&city[]=524901.

$ wget --output-document="D:\listing_index.json" --http-user="adminre@monoray.net" --http-password="174cc583994a138b2bb204a1e005186d" "YOUR_SITE/api/apartments?country=185&region=524894&city[]=524901"



If you use the module “Location”, you can get a list of countries available on the site and their id using the GET request to the url YOUR_SITE/api/options/countryLocationList.

$ wget --output-document="D:\countryLocationList.json" --http-user="adminre@monoray.net" --http-password="174cc583994a138b2bb204a1e005186d" "YOUR_SITE/api/options/countryLocationList"

After the request has been completed, the system returns the reponse with Code 200. Sample Response:

{
    "object":"list",
    "count":14,
    "data":{
        "185":"Russia",
        "74":"France",
        "56":"Germany",
        "103":"India",
        "108":"Italia",
        "122":"Kazakhstan",
        "36":"Belarus",
        "187":"Saudi Arabia",
        "67":"Spain",
        "217":"Turkey",
        "222":"Ukraine",
        "4":"United Arab Emirates",
        "77":"United Kingdom",
        "225":"United States"
    }
}


You can get a list of available regions in the country and their id using a GET request to the url YOUR_SITE/api/options/regionLocationList?country_id=185. Where country_id – id of a country.

$ wget --output-document="D:\regionLocationList.json" --http-user="adminre@monoray.net" --http-password="174cc583994a138b2bb204a1e005186d" "YOUR_SITE/api/options/regionLocationList?country_id=185"

After the request has been completed, the system returns the reponse with Code 200. Sample Response:

{
    "object":"list",
    "count":83,
    "data":{
        "584222":"Adygeya",
        "1506272":"Altay",
        "1511732":"Altayskiy Kray",
        "2027748":"Amurskaya Oblast'",
        "581043":"Arkhangel'skaya Oblast'",
        "580491":"Astrakhanskaya Oblast'",
        "578853":"Bashkortostan",
        "578071":"Belgorodskaya Oblast'",
        "571473":"Bryanskaya Oblast'",
        "2050915":"Buryatiya",
        "569665":"Chechnya",
        "1508290":"Chelyabinskaya Oblast'",
        "2126099":"Chukotskiy Avtonomnyy Okrug",
        "567395":"Chuvashia",
        "567293":"Dagestan",
        "556349":"Ingushetiya",
        "2023468":"Irkutskaya Oblast'",
        "555235":"Ivanovskaya Oblast'",
        "554667":"Kabardino-Balkaria",
        "554230":"Kaliningradskaya Oblast'",
        "553972":"Kalmykiya",
        "553899":"Kaluzhskaya Oblast'",
        "2125072":"Kamtchatski Kray",
        "552927":"Karachayevo-Cherkesiya",
        "552548":"Kareliya",
        "1503900":"Kemerovskaya Oblast'",
        "2022888":"Khabarovskiy Kray",
        "1503834":"Khakasiya",
        "1503773":"Khanty-Mansiyskiy Avtonomnyy Okrug - Yugra",
        "548389":"Kirovskaya Oblast'",
        "545854":"Komi",
        "543871":"Kostromskaya Oblast'",
        "542415":"Krasnodarskiy Kray",
        "1502020":"Krasnoyarskiy Kray",
        "1501312":"Kurganskaya Oblast'",
        "538555":"Kurskaya Oblast'",
        "536199":"Leningradskaya Oblast'",
        "535120":"Lipetskaya Oblast'",
        "2123627":"Magadanskaya Oblast'",
        "529352":"Mariy-El",
        "525369":"Mordoviya",
        "524925":"Moskovskaya Oblast'",
        "524894":"Moskva",
        "524304":"Murmanskaya Oblast'",
        "522652":"Nenetskiy Avtonomnyy Okrug",
        "559838":"Nizhegorodskaya Oblast'",
        "519969":"North Ossetia",
        "519324":"Novgorodskaya Oblast'",
        "1496745":"Novosibirskaya Oblast'",
        "1496152":"Omskaya Oblast'",
        "515001":"Orenburgskaya Oblast'",
        "514801":"Orlovskaya Oblast'",
        "511555":"Penzenskaya Oblast'",
        "511180":"Perm Krai",
        "2017623":"Primorskiy Kray",
        "504338":"Pskovskaya Oblast'",
        "501165":"Rostovskaya Oblast'",
        "500059":"Ryazanskaya Oblast'",
        "2013162":"Sakha (Yakutiya)",
        "2121529":"Sakhalinskaya Oblast'",
        "499068":"Samarskaya Oblast'",
        "536203":"Sankt-Peterburg",
        "498671":"Saratovskaya Oblast'",
        "491684":"Smolenskaya Oblast'",
        "487839":"Stavropol'skiy Kray",
        "1490542":"Sverdlovskaya Oblast'",
        "484638":"Tambovskaya Oblast'",
        "484048":"Tatarstan",
        "1489421":"Tomskaya Oblast'",
        "480508":"Tul'skaya Oblast'",
        "480041":"Tverskaya Oblast'",
        "1488747":"Tyumenskaya Oblast'",
        "1488873":"Tyva",
        "479613":"Udmurtia",
        "479119":"Ulyanovsk Oblast",
        "826294":"Vladimirskaya Oblast'",
        "472755":"Volgogradskaya Oblast'",
        "472454":"Vologodskaya Oblast'",
        "472039":"Voronezhskaya Oblast'",
        "1486462":"Yamalo-Nenetskiy Avtonomnyy Okrug",
        "468898":"Yaroslavskaya Oblast'",
        "2026639":"Yevreyskaya Avtonomnaya Oblast'",
        "7779061":"Zabaykal'skiy Kray"
    }
}
 


You can get a list of available cities in the region of the country and their id using the GET request to the url YOUR_SITE/api/options/cityLocationList?country_id=185&region_id=524894. Where country_id – id of a country, region_id – id of a region.

$ wget --output-document="D:\cityLocationList.json" --http-user="adminre@monoray.net" --http-password="174cc583994a138b2bb204a1e005186d" "YOUR_SITE/api/options/cityLocationList?country_id=185&region_id=524894"

After the request has been completed, the system returns the reponse with Code 200. Sample Response:

{
    "object":"list",
    "count":6,
    "data":{
        "550280":"Khimki",
        "524901":"Moscow",
        "500591":"Rumyantsevo",
        "495260":"Shcherbinka",
        "481608":"Troitsk",
        "463829":"Zelenograd"
    }
}



If you are not using the module “Location”, you can get a list of available cities and their IDs using a GET request to the url YOUR_SITE/api/options/cityList.

$ wget --output-document="D:\cityList.json" --http-user="adminre@monoray.net" --http-password="174cc583994a138b2bb204a1e005186d" "YOUR_SITE/api/options/cityList"

After the request has been completed, the system returns the reponse with Code 200. Sample Response:

{
    "object":"list",
    "count":2,
    "data":{
        "7":"Moscow",
        "8":"New-York"
    }
}



You can obtain a list of listings of a certain type of transaction, add "?apType=1" to the GET request to the url YOUR_SITE/api/apartments, where 1 - transaction type code.

$ wget --output-document="D:\listing_index.json" --http-user="adminre@monoray.net" --http-password="174cc583994a138b2bb204a1e005186d" "YOUR_SITE/api/apartments?apType=1"


The list of available transaction types on the site and their IDs can be obtained by performing a GET request to the url YOUR_SITE/api/options/typeList.

$ wget --output-document="D:\typeList.json" --http-user="adminre@monoray.net" --http-password="174cc583994a138b2bb204a1e005186d" "YOUR_SITE/api/options/typeList"

After the request has been completed, the system returns the reponse with Code 200. Sample Response:

{
    "object":"list",
    "count":3,
    "data":{
        "1":"Rent out a property",
        "2":"Sell",
        "5":"Exchange"
    }
}



For a list of properties of a particular type of property, add "?objType = 1" to the GET request on the url YOUR_SITE/api/apartments, where 1 - property type code.

$ wget --output-document="D:\listing_index.json" --http-user="adminre@monoray.net" --http-password="174cc583994a138b2bb204a1e005186d" "YOUR_SITE/api/apartments?objType=1"


The list of the property types available on the site and their IDs can be obtained by performing a GET request to the url YOUR_SITE/api/options/objTypeList.

$ wget --output-document="D:\objTypeList.json" --http-user="adminre@monoray.net" --http-password="174cc583994a138b2bb204a1e005186d" "YOUR_SITE/api/options/objTypeList"

After the request has been completed, the system returns the reponse with Code 200. Sample Response:

{
    "object":"list",
    "count":8,
    "data":{
        "1":"apartment",
        "2":"house",
        "3":"commercial real estate",
        "4":"land plot",
        "5":"apartment house",
        "6":"hotel",
        "7":"hotel room",
        "8":"garage"
    }
}



For a list of listings with a given price range, add "?price_min=100&price_max=2000" to GET request on url YOUR_SITE/api/apartments, where price_min and price_max - cost from 100 to 2000 conventional units (conventional unit - default currency on the site: USD/RUB/EUR/SAR etc.).

$ wget --output-document="D:\listing_index.json" --http-user="adminre@monoray.net" --http-password="174cc583994a138b2bb204a1e005186d" "YOUR_SITE/api/apartments?price_min=100&price_max=2000"


Also you can combine the above parameters for more accurate filtering of listings.

Example of GET request, which will return the list of listings from the city of Moscow with the type of transaction "rent", with the type of property "apartment" and cost from 100 to 2000 conventional units:

$ wget --output-document="D:\listing_index.json" --http-user="adminre@monoray.net" --http-password="174cc583994a138b2bb204a1e005186d" "YOUR_SITE/api/apartments?country=185&region=524894&city[]=524901&?apType=1&objType=1&price_min=100&price_max=2000"

After the request has been completed, the system returns the reponse with Code 200. Sample Response:

{
    "object":"list",
    "count":"1",
    "data":{
        "0":{
            "object":"apartment",
            "id":"26",
            "type":"1",
            "obj_type_id":"1",
            "price_type":"5",
            "loc_country":"185",
            "loc_region":"524894",
            "loc_city":"524901",
            "city_id":"7",
            "is_price_poa":"0",
            "price":"1200",
            "price_to":"0",
            "num_of_rooms":"1",
            "floor":"7",
            "floor_total":"14",
            "square":"35",
            "land_square":"0",
            "lat":"55.735955",
            "lng":"37.6186773",
            "rating":"0",
            "is_special_offer":"0",
            "owner_active":"1",
            "active":"1",
            "imagesList":{
                "imgCount":"3",
                "0":{
                    "file_name_path":"YOUR_SITE/uploads/objects/26/modified/full_cc48b9a67c1e05e242f556105b8fe842.jpg"
                },
                "1":{
                    "file_name_path":"YOUR_SITE/uploads/objects/26/modified/full_925abcaf701ddf5e858de3d1029d9ea6.jpg"
                },
                "2":{
                    "file_name_path":"YOUR_SITE/uploads/objects/26/modified/full_64d96740d5027df5c3647b43af88eeed.jpg"
                }
            },
            "in_currency":"USD",
            "title_en":"Apartment, Bolshaya Polyanka St., 28",
            "address_en":"Bolshaya Polyanka St., 28",
            "description_en":"<p>This apartment with nice shades of blue and a beautiful bathroom will help you to relax after work.</p>",
            "description_near_en":"Metro \"Polyanka\" is within 5 minutes walk.",
            "exchange_to_en":"",
            "title_ru":"Квартира, ул. Большая Полянка, д. 28",
            "address_ru":"ул. Большая Полянка, д. 28",
            "description_ru":"<p>Комната с приятными оттенками синего и красивая ванная комната помогут Вам расслабиться после трудового дня</p>",
            "description_near_ru":"Метро \"Полянка\" в пятиминутной доступности",
            "exchange_to_ru":"",
            "title_de":"Wohnung, Bolschaja Poljanka Str., 28",
            "address_de":"Bolschaja Poljanka Str., 28",
            "description_de":"<p>Ein Zimmer mit feinen Schattierungen von Blau und ein schönes Badezimmer wird Ihnen helfen, sich nach der Arbeit zu entspannen.</p>",
            "description_near_de":"Die U-Bahn-Haltestelle Polyanka ist 5 Minuten entfernt",
            "exchange_to_de":"",
            "title_es":"Apartamento, Bolshaya Polyanka St., 28",
            "address_es":"Bolshaya Polyanka St., 28",
            "description_es":"<p>This apartment with nice shades of blue and a beautiful bathroom will help you to relax after work.</p>",
            "description_near_es":"Metro \"Polyanka\" is within 5 minutes walk.",
            "exchange_to_es":"",
            "title_ar":"شقة، بولشايا Polyanka شارع، 28",
            "address_ar":"Bolshaya Polyanka St., 28",
            "description_ar":"<p>وهذه الشقة مع ظلال جميلة من الحمام الأزرق وجميلة تساعدك على الاسترخاء بعد العمل.</p>",
            "description_near_ar":"مترو \"Polyanka\" هو على بعد 5 دقائق مشيا على الأقدام.",
            "exchange_to_ar":""
        }
    }
}


Detailed description of the fields:

"id":"Listing ID",
"type":"Transaction type",
"obj_type_id":"Property type",
"price_type":"Price type",
"loc_country":"Country id",
"loc_region":"Region id",
"loc_city":"City id",
"city_id":"City id, if module 'Location' turn off",
"is_price_poa":"Price on asking. Possible values can be '1' - yes, '0' - no",
"price":"Price",
"price_to":"Price 'Up to'. It is used for property types Rent property from somebody|Buy.Do not fill in the field for other property types",
"num_of_rooms":"Number of rooms",
"floor":"Floor",
"floor_total":"Total number of floors",
"square":"Square",
"land_square":"Land square",
"lat":"Latitude",
"lng":"Longitude",
"rating":"Rating. From 0 to 10",
"is_special_offer":"Is special offer?. Possible values can be '1' - yes, '0' - no",
"owner_active":"Owner active. Possible values can be '1' - Active, '0' - Inactive",
"active":"Active: Possible values can be '2' - Awaiting moderation, '1' - Active, '0' - Inactive",
"imagesList":{
"imgCount":"Images count",
"0":{
"file_name_path":"image path"
},
"1":{
"file_name_path":"image path"
},
"2":{
"file_name_path":"image path"
}
},
"in_currency":"Currency",
"title_en":"'Title' for lang 'en'",
"address_en":"'Address' for lang 'en'",
"description_en":"'Description' for lang 'en'",
"description_near_en":"'What is near' for lang 'en'",
"exchange_to_en":"'Exchange for' for lang 'en'",
"title_ru":"'Title' for lang 'ru'",
"address_ru":"'Address' for lang 'ru'",
"description_ru":"'Description' for lang 'ru'",
"description_near_ru":"'What is near' for lang 'ru'",
"exchange_to_ru":"'Exchange for' for lang 'ru'",
"title_de":"'Title' for lang 'de'",
"address_de":"'Address' for lang 'de'",
"description_de":"'Description' for lang 'de'",
"description_near_de":"'What is near' for lang 'de'",
"exchange_to_de":"'Exchange for' for lang 'de'",
"title_es":"'Title' for lang 'es'",
"address_es":"'Address' for lang 'es'",
"description_es":"'Description' for lang 'es'",
"description_near_es":"'What is near' for lang 'es'",
"exchange_to_es":"'Exchange for' for lang 'es'",
"title_ar":"'Title' for lang 'ar'",
"address_ar":"'Address' for lang 'ar'",
"description_ar":"'Description' for lang 'ar'",
"description_near_ar":"'What is near' for lang 'ar'",
"exchange_to_ar":"'Exchange for' for lang 'ar'"



The list of available price types on the site and their codes can be obtained by running a GET request to the url YOUR_SITE/api/options/priceTypeList.

$ wget --output-document="D:\priceTypeList.json" --http-user="adminre@monoray.net" --http-password="174cc583994a138b2bb204a1e005186d" "YOUR_SITE/api/options/priceTypeList"

After the request has been completed, the system returns the reponse with Code 200. Sample Response:

{
    "object":"list",
    "count":3,
    "data":{
        "1":{
            "typeId":1,
            "typeName":"Rent out a property",
            "priceTypes":{
                "2":"per hour",
                "3":"per day",
                "4":"per week",
                "5":"per month"
            }
        },
        "2":{
            "typeId":2,
            "typeName":"Sell",
            "priceTypes":{
                "1":"Sale"
            }
        },
        "5":{
            "typeId":5,
            "typeName":"Exchange",
            "priceTypes":{
                "8":""
            }
        }
    }
}



The list of languages available on the site and their codes can be obtained by performing a GET request to the url YOUR_SITE/api/options/langList.

$ wget --output-document="D:\langList.json" --http-user="adminre@monoray.net" --http-password="174cc583994a138b2bb204a1e005186d" "YOUR_SITE/api/options/langList"

After the request has been completed, the system returns the reponse with Code 200. Sample Response:

{
    "object":"list",
    "count":5,
    "data":{
        "en":"English",
        "ru":"Русский",
        "de":"Deutsch",
        "es":"Español",
        "ar":"العربية"
    }
}



You can get a list of available currencies on the site and their codes by running a GET request to the url YOUR_SITE/api/options/currencyList.

$ wget --output-document="D:\currencyList.json" --http-user="adminre@monoray.net" --http-password="174cc583994a138b2bb204a1e005186d" "YOUR_SITE/api/options/currencyList"

After the request has been completed, the system returns the reponse with Code 200. Sample Response:

{
    "object":"list",
    "count":4,
    "data":{
        "RUB":"RUB",
        "USD":"$",
        "EUR":"EUR",
        "SAR":"SAR"
    }
}



You can get a list of available activity statuses and their codes by running a GET request to the url YOUR_SITE/api/options/ownerStatusList.

$ wget --output-document="D:\ownerStatusList.json" --http-user="adminre@monoray.net" --http-password="174cc583994a138b2bb204a1e005186d" "YOUR_SITE/api/options/ownerStatusList"

After the request has been completed, the system returns the reponse with Code 200. Sample Response:

{
    "object":"list",
    "count":2,
    "data":{
        "0":"Inactive",
        "1":"Active"
    }
}



You can get a list of available global activity statuses and their codes by running a GET request to the url YOUR_SITE/api/options/statusList.

$ wget --output-document="D:\statusList.json" --http-user="adminre@monoray.net" --http-password="174cc583994a138b2bb204a1e005186d" "YOUR_SITE/api/options/statusList"

After the request has been completed, the system returns the reponse with Code 200. Sample Response:

{
    "object":"list",
    "count":3,
    "data":{
        "0":"Inactive",
        "1":"Active",
        "2":"Awaiting moderation"
    }
}



Information about the listing.

Send GET request to url YOUR_SITE/api/apartments/ID_OBJECT, where ID_OBJECT - id of the object.

$ wget --output-document="D:\listing_view.json" --http-user="adminre@monoray.net" --http-password="174cc583994a138b2bb204a1e005186d" "YOUR_SITE/api/apartments/28"

After the request has been completed, the system returns the reponse with Code 200. Sample Response:

{
    "object":"apartment",
    "id":"28",
    "type":"1",
    "obj_type_id":"1",
    "price_type":"2",
    "loc_country":"185",
    "loc_region":"524894",
    "loc_city":"524901",
    "city_id":"7",
    "is_price_poa":"0",
    "price":"25",
    "price_to":"0",
    "num_of_rooms":"1",
    "floor":"9",
    "floor_total":"14",
    "square":"36",
    "land_square":"0",
    "lat":"55.7506831",
    "lng":"37.5968604",
    "rating":"0",
    "is_special_offer":"0",
    "owner_active":"1",
    "active":"1",
    "imagesList":{
        "imgCount":"5",
        "0":{
            "file_name_path":"YOUR_SITE/uploads/objects/28/modified/full_5372cfe2f6db3f4c7de4fa2f54030223.jpg"
        },
        "1":{
            "file_name_path":"YOUR_SITE/uploads/objects/28/modified/full_e3e068e1ef368a8c60666ac7708a5472.jpg"
        },
        "2":{
            "file_name_path":"YOUR_SITE/uploads/objects/28/modified/full_fca9b505abf952af7f2a052da7c27d84.jpg"
        },
        "3":{
            "file_name_path":"YOUR_SITE/uploads/objects/28/modified/full_dcf2bf49b9466dc400a12b4d3855a3ea.jpg"
        },
        "4":{
            "file_name_path":"YOUR_SITE/uploads/objects/28/modified/full_a18e663a61f5d6930bb851b60c62e51d.jpg"
        }
    },
    "in_currency":"USD",
    "title_en":"Apartment near Arbatskaya metro station, Bolshoy Afanasyevsky Lane, 10",
    "address_en":"Bolshoy Afanasyevsky Lane, 10",
    "description_en":"<p>Within 7 minutes walk from Arbatskaya metro station</p>",
    "description_near_en":"Underground",
    "exchange_to_en":"",
    "title_ru":"Квартира, ул. Большая Полянка, д. 28",
    "address_ru":"ул. Большая Полянка, д. 28",
    "description_ru":"<p>Комната с приятными оттенками синего и красивая ванная комната помогут Вам расслабиться после трудового дня</p>",
    "description_near_ru":"Метро \"Полянка\" в пятиминутной доступности",
    "exchange_to_ru":"",
    "title_de":"1-Zimmer-Wohnung, U-Bahn-Haltestelle Arbatskaya, Bolschoi Afanasjevskij Pereulok, 10",
    "address_de":"Bolschoi Afanasjevskij Pereulok, 10",
    "description_de":"<p>Die U-Bahn-Haltestelle Arbatskaja ist 7 Minuten entfernt</p>",
    "description_near_de":"U-Bahn",
    "exchange_to_de":"",
    "title_es":"Apartamento cerca de la estación de metro Arbatskaya, Bolshoy Afanasyevsky Lane, 10",
    "address_es":"Bolshoy Afanasyevsky Lane, 10",
    "description_es":"<p>Within 7 minutes walk from Arbatskaya metro station</p>",
    "description_near_es":"Underground",
    "exchange_to_es":"",
    "title_ar":"شقة، بولشايا Polyanka شارع، 28",
    "address_ar":"Bolshaya Polyanka St., 28",
    "description_ar":"<p>وهذه الشقة مع ظلال جميلة من الحمام الأزرق وجميلة تساعدك على الاسترخاء بعد العمل.</p>",
    "description_near_ar":"مترو \"Polyanka\" هو على بعد 5 دقائق مشيا على الأقدام.",
    "exchange_to_ar":""
}



Adding an listing.

Send a POST request to the url YOUR_SITE/api/apartments.
In the POST array, pass at least the following information:

  • Apartment[owner_active]. Owner status (0|1). To get a list of available statuses and their names send a GET request to the url YOUR_SITE/api/ownerStatusList;
  • Apartment[type]. Transaction type (1|2|3|4|5). To get a list of available id and their name send a GET request to the url YOUR_SITE/api/typeList;
  • Apartment[price_type]. Price type (1|2|3|4|5|6|7|8). To get a list of available id and their name send a GET request to the url YOUR_SITE/api/priceTypeList;
  • Apartment[obj_type_id]. Property type (1|2|3|4|5 etc). To get a list of available id and their name send a GET request to the url YOUR_SITE/api/objTypeList;
  • Apartment[price]. Price (1000|2000|3000 и т.п.);
  • Apartment[in_currency]. Currency (USD|RUB|EUR|SAR etc). Only if the multicurrency version is used. For a list of available currencies, send a GET request to the url YOUR_SITE/api/currencyList;

  • If the module "Location" is enabled
    Apartment[loc_country]. id of a country. To get a list of available countries and their names send a GET request to the url YOUR_SITE/api/options/countryLocationList
    Apartment[loc_region]. id of a region. To get a list of available regions of the country and their names send a GET request to the url YOUR_SITE/api/options/regionLocationList?country_id=ID_COUNTRY, where ID_COUNTRY – id of a country
    Apartment[loc_city]. id of a city. To get a list of available cities in the region and their names send a GET request to the url YOUR_SITE/api/options/cityLocationList?country_id=ID_COUNTRY®ion_id=ID_REGION, where ID_COUNTRY - id of a country and ID_REGION - id of a region

    If the module "Location" is disabled:
    Apartment[city_id]. id of a city. To get a list of available cities and their names send a GET request to the url YOUR_SITE/api/options/cityList

  • Apartment[imagesList]. List of links to images to add them to the object;
  • Apartment[title_en]|Apartment[title_ru]|Apartment[title_de]|Apartment[title_es]|Apartment[title_ar]. The title of the object in all active languages of the site. For a list of available languages send a GET request to the url YOUR_SITE/api/langList
  • Apartment[description_en]|Apartment[description_ru]|Apartment[description_de]|Apartment[description_es]|Apartment[description_ar]. Description of the object in all active site languages;
  • Apartment[address_en]|Apartment[address_ru]|Apartment[address_de]|Apartment[address_es]|Apartment[address_ar]. The address of the object (street, house) in all active languages of the site.

Example:

$postData = array(
    'Apartment[owner_active]' => 1,
    'Apartment[type]' => 2,
    'Apartment[price_type]' => 2,
    'Apartment[obj_type_id]' => 1,
    'Apartment[price]' => 400,
    'Apartment[in_currency]' => 'USD',
    'Apartment[loc_country]' => 185,
    'Apartment[loc_region]' => 524894,
    'Apartment[loc_city]' => 524901,
    'Apartment[city_id]' => 0,
    'Apartment[imagesList]' => array(
        'https://demo-pro.open-real-estate.info/uploads/objects/18/modified/full_c5d10612afa120b285ccfb817e0a2303.jpg',
        'https://demo-pro.open-real-estate.info/uploads/objects/18/modified/full_2eec995ba4a4a51736f9c8b70c4bb206.jpg',
        'https://demo-pro.open-real-estate.info/uploads/objects/18/modified/full_32edbdf4361baa92fbe8f9c6ca97f4ef.jpg'
    ),
    Apartment[title_en] => 'My First REST API Listing',
    Apartment[title_ru] => 'Моё первое REST API объявление',
    Apartment[title_de] => 'My First REST API Listing',
    Apartment[title_es] => 'My First REST API Listing',
    Apartment[title_ar] => 'My First REST API Listing',
    Apartment[description_en] => 'Description',
    Apartment[description_ru] => 'Описание',
    Apartment[description_de] => 'Description',
    Apartment[description_es] => 'Description',
    Apartment[description_ar] => 'Description',
    Apartment[address_en] => 'Aviamotornaya St., 28',
    Apartment[address_ru] => 'Авиамоторная ул., 28',
    Apartment[address_de] => 'Aviamotornaya St., 28',
    Apartment[address_es] => 'Aviamotornaya St., 28',
    Apartment[address_ar] => 'Aviamotornaya St., 28',
);

$ch = curl_init();
$options = array(
    CURLOPT_URL => $url,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HEADER => 1,
    CURLOPT_USERPWD => 'adminre@monoray.net:174cc583994a138b2bb204a1e005186d',
    CURLOPT_POST => 1,
    CURLOPT_POSTFIELDS => http_build_query($postData, null, '&'),
   
);
if (strtolower(substr($url, 0, 5)) == "https") {
    $options[CURLOPT_SSL_VERIFYPEER] = false;
    $options[CURLOPT_SSL_VERIFYHOST] = false;
}
curl_setopt_array($ch, $options);

$response = curl_exec($ch);
if ($response === false) {
    throw new \CException(curl_error($ch), curl_errno($ch));
}

$info = curl_getinfo($ch);

$header = substr($response, 0, $info['header_size']);
$body = substr($response, $info['header_size']);

preg_match("/Location: (.*?)\n/", $header, $matches);
$location = isset($matches[1]) ? $matches[1] : null;

return array('body' => $body, 'code' => $info['http_code'], 'location' => $location);


After the request has been completed, the system returns the reponse with Code 200. Sample Response:

{
    "object":"list",
    "count":1,
    "data":{
        "id":"38"
    }
}

The response will have the id value of the created object equal to 38 ("id":"38"), which, if necessary can be used for their own purposes.



Updating information about the listing.

Send a PUT request to the url YOUR_SITE/api/apartments/ID_OBJECT, where ID_OBJECT – id of editable object, for example, 56.

...
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
...

All transmitted fields and values are identical to the method of adding an object.

After the request has been completed, the system returns the reponse with Code 200. Sample Response:

{
    "object":"list",
    "count":1,
    "data":{
        "id":"56"
    }
}



Deleting an listing.

Send a DELETE request to the url YOUR_SITE/api/apartments/ID_OBJECT, where ID_OBJECT – id of deleted object, for example, 82.

...
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
...

After the request has been completed, the system returns the reponse with Code 200. Sample Response:

{
    "object":"list",
    "count":1,
    "data":{
        "id":"82"
    }
}



You can familiarize yourself with the functions of the module by sending requests to the url: https://demo-pro.open-real-estate.info instead YOUR_SITE
Login and password for HTTP authorization - adminre@monoray.net:174cc583994a138b2bb204a1e005186d


If you need any improvements of the functions of the module, then we can do it for an additional fee.
Contact us through the form "Contacts".