# Fetching pricelist data

The best practice successfully followed by the **hundreds** of connected project webs is the following:

* Fetch the pricelist **every hour** and store the result in a relational database for a quick frontend pricelist/unit detail rendering.
* Look at what resource UIDs your **local cache** is missing and fetch them.
* If there is any problem with the API **log** it and **retry** at some later time.

## Request

Use **HTTP POST** and the endpoint `https://cms.realpad.eu/ws/v10/get-project`\
\
Send the following required parameters as a **URL-encoded form**:

* `login` - string login obtained from our support.
* `password` - string password obtained from our support.
* `screenid` - integer value, typically constant, obtained from our support.
* `developerid` - integer value, typically constant, obtained from our support.
* `projectid` - integer value identifying the project, will change between projects.

{% hint style="danger" %}
Do not send data as JSON in this endpoint. The API expects to receive a URL-encoded form. See the cURL example for guidance.
{% endhint %}

To get `screenid`, `developerid`, `projectid` parameters you will need to call the `https://cms.realpad.eu/ws/v10/get-projects-info` API endpoint using **HTTP POST.** You will only need previously obtained `login` and `password` parameters to do this.

*Example call in **cURL:***

```bash
curl \
--data "login=...&password=...&screenid=...&projectid=...&developerid=..." \
https://cms.realpad.eu/ws/v10/get-project
```

## Response

The response consists of the HTTP Status Code and, if the call was successful, XML payload. Status codes:

* `200 OK` - all was fine, the call succeeded and the payload contains the XML data.
* `400 BAD REQUEST` - one of the IDs was invalid, e.g. unknown project was requested.
* `401 NOT AUTHORIZED` - the credentials are invalid or requesting IP is banned.
* `429 TOO MANY REQUESTS` - you are calling the endpoint too often - the body of the response tells you when it will be possible to call it again.

{% hint style="info" %}
**See also:** [Authentication & Error Handling](https://dev.realpadsoftware.com/integrations/introduction/authentication-and-error-handling) for details on the `Retry-After` header, banning behavior, `415 Unsupported Media Type`, and other shared error responses.
{% endhint %}

### **Payload**

The file is structured using this hierarchy:`export-> project -> building -> floor -> flat`. Typically you will only need to use the data in the `<flat>` elements containing the relevant units (so not only flats but also cellars parking spots etc).&#x20;

{% hint style="info" %}
Keep in mind that certain units might be withheld from this endpoint output by the CRM users.
{% endhint %}

The unit plan and PDF UIDs (see below) can be found in `<flat>` XML attributes, the rest of the important data is stored in `<flat-attribute>` sub-elements identified by their keys. Explanation follows:

* `flat_area` - unit net area in square meters (sqm).
* `flat_area_living`  - unit gross area in sqm.
* `flat_area_balcony` - balcony area in sqm.
* `flat_area_garden` - garden area in sqm.
* `flat_area_terrace` - terrace area in sqm.
* `flat_area_loggia` - loggia area in sqm.
* `flat_price_before_discount_vat` - unit pricelist price with VAT.
* `flat_price_before_discount_without_vat`  - unit pricelist price without VAT.
* `flat_discount_vat` - unit pricelist discount with VAT.
* `flat_discount_without_vat` - unit pricelist discount without VAT.
* `flat_disposition` - unit rooms (1+kk, 2+1 etc).
* `flat_category` - unit category.
* `flat_internal_id` - unit name / ID in the Realpad system.
* `flat_orientation` - unit window orientation (SV, J, W, S-E etc).
* `flat_price` - unit price with VAT.
* `flat_price_without_vat` - unit price without VAT.
* `associatedunits_internal_ids` - Realpad database IDs of units associated with the current one in a "bundle".
* `associatedunits_totalprice_novat` - price of the bundle of the current unit and its associated units, after pricelist discount, without VAT.
* `associatedunits_totalprice_vat` - price of the bundle of the current unit and its associated units, after pricelist discount, with VAT.
* `flat_status` - unit status (availability), typically project webs will only display units with availability 0 or 1. Possible values are:
  * 0 - free.
  * 1 - pre-reserved.
  * 2 - reserved.
  * 3 - sold.
  * 4 - not for sale.
  * 5 - delayed.
* `flat_type` - unit type, see the enumeration options below.

<details>

<summary>Available unit types</summary>

* 1 - flat.
* 2 - parking.
* 3 - cellar.
* 4 - outdoor parking.
* 5 - garage.
* 6 - commercial space.
* 7 - family house.
* 8 - land.
* 9 - atelier.
* 10 - office.
* 11 - art workshop.
* 12 - non-residential unit.
* 13 - motorbike parking.
* 14 - creative workshop.
* 15 - townhouse.
* 16 - utility room.
* 17 - condominium.
* 18 - storage.
* 19 - apartment.
* 20 - accommodation unit.
* 21 - bike stand.
* 22 - communal area.
* 23 - non-residential unit - other.
* 24 - berth.
* 25 - construction right.
* 26 - villa.
* 27 - technical space.
* 28 - outdoor parking position for motorbike.
* 29 - property management unit.
* 30 - attic.
* 31 - backyard.
* 32 - terrace.
* 33 - cubicle.
* 34 - tenement house.
* 35 - paved area.
* 36 - garage position.
* 99 - other.

</details>

## Resources

XML payload contains attributes and values in the form of *bd5563ae-abc...* These are the UIDs (Unique IDentifiers) of the resources you can retrieve: unit plans, PDFs, gallery pictures, etc. You can fetch resources using **HTTP GET** by retrieving a URL in the following form: `https://cms.realpad.eu/resource/<UID>`\
\
\&#xNAN;*Example call in **cURL:***

```bash
curl \
--output cached_resource \
https://cms.realpad.eu/resource/bd5563ae-abc...
```

**Important note: you must serve the resources from your application, you may not simply point to Realpad Flats CRM URLs. Always cache resources “forever”.** The resources you obtain this way are immutable. This means that the same UID will always refer to exactly the same data. If the data changes, you will see a different UID in one of the XMLs. You may freely cache the resources forever: you don’t have to re-download the same UID ever again.

{% @mailchimp/mailchimpSubscribe cta="Sign up to receive updates!" %}
