Understand an area · Use case
How do I analyse a zip code or postcode area with Casafari?
To analyse a postcode with Casafari, turn it into a boundary. The References operation POST /api/v1/references/zipcode-boundary takes zip_code and country_code and returns the zip code's boundary. Pass that boundary as a closed polygon to comparables_get_comparables, property search or alert search.
Products: References, Comparables & Valuation, Property Sourcing, New Market Leads
Short answer
The References operation POST /api/v1/references/zipcode-boundary returns the boundary of a zip code. You then use that boundary in other calls:
comparables_get_comparablestakes it aslocation_boundary.polygon.- Property search (
POST /api/v2/properties/search) takes it ascustom_location_boundary. - Alert search takes it as
custom_location.
Area Insights over MCP is different: it takes location ids or a circle, not polygons.
Steps
POST /api/v1/references/zipcode-boundary with zip_code and country_code
Send
POST /api/v1/references/zipcode-boundarywith:zip_code.country_code(ISO 3166-1 alpha-2).
The response format is documented on the operation page.
Pass the polygon: comparables_get_comparables location_boundary.polygon (first and last points match, at least 4)
Call
comparables_get_comparableswithlocation_boundary.polygon. The polygon must meet these rules:- It is a list of
latitudeandlongitudeobjects. - It has at least 4 points.
- The first and last points are the same.
Also send the required
comparables_count(1 to 50),operationandcomparables_types.- It is a list of
POST /api/v2/properties/search custom_location_boundary; POST /api/v1/listing-alerts/search custom_location
- For property search, send
POST /api/v2/properties/searchwithcustom_location_boundary, which accepts a polygon of geo-points or a circle. - For alert search, send
POST /api/v1/listing-alerts/searchwithcustom_location, a closed polygon. Alert search also acceptscustom_locations, a list of polygons, for several postcodes at once.
Reverse lookup: GET /api/v1/references/locations/by-coordinates
- To find which location in Casafari's location tree contains a point, call
GET /api/v1/references/locations/by-coordinates(Casafari client accounts), or Location Lookup'sGET /v1/locations/by-coordinateson the self-serve platform, which takeslatandlon. Its parameters are on the operation page.
Example: a Lisbon postcode
Goal: "What are 2-bedroom apartments for sale in postcode 1200, Lisbon, worth?"
First, a Casafari client account requests the boundary over REST:
{"zip_code": "1200", "country_code": "PT"}Then the boundary's points go into comparables_get_comparables. An assistant or script can make this call over MCP:
{
"comparables_count": 20,
"location_boundary": {"polygon": [
{"latitude": LAT_1, "longitude": LON_1},
{"latitude": LAT_2, "longitude": LON_2},
{"latitude": LAT_3, "longitude": LON_3},
{"latitude": LAT_1, "longitude": LON_1}
]},
"operation": "sale",
"comparables_types": ["apartment"],
"bedrooms": 2
}In practice, the polygon carries every boundary point, closed on the first one. Read the result in this order:
estimated_pricesfor a value range:fast_sell_price,fair_market_priceandout_of_market_price.statisticsforaverage_price_per_sqmandaverage_time_on_the_market.resultsfor the comparable properties, each with asimilarity_scorebetween 0 and 1.
The figures come from the live calls; these docs publish none.
How to read the result
distance is not calculated for polygon searches
In polygon searches, distance in each comparable is not calculated. Rank comparables by similarity_score, which shows how close each property's parameters are to the ones you requested.
Location breadcrumbs for the containing district
Each comparable carries location and locations_structure. locations_structure lists every parent location up to the country, and both include zip_codes where known. Use them to name the district that contains the postcode. Over MCP, locations_search returns the same kind of parent chain as breadcrumbs.
Limits
Availability for Casafari client accounts:
- The References operations: zip-code boundary, the REST typeahead,
POST /api/v1/references/locationsand the REST by-coordinates lookup. Zip-code boundary has no self-serve equivalent. - Property Sourcing's
POST /api/v2/properties/search. - Alert search.
Availability on the self-serve Casafari API and MCP Platform:
comparables_get_comparables, which accepts the polygon, over MCP and over REST.- Location Lookup:
GET /v1/locations/by-coordinates, plus search by name, get by id and children (the MCP toolslocations_searchandlocations_get).locations_searchalso looks places up by postcode, free, over MCP and REST: exact or prefix match, the matching places smallest area first, and every location carries itspostcodes. Postcode coverage is Spain fully and France partly; Portugal is not covered yet. They do not return a zip-code boundary.
Coverage:
- Spanish cadastral references are an alternative target point in
comparables_get_comparables; that input is Spain only. - See per-tool coverage.
The REST typeahead takes country codes ES or PT
POST /api/v1/references/locations/typeahead accepts:
country_codes:ESandPTonly.name.size: default 30, maximum 100.lang:en,pt,esorde.
For other markets, use POST /api/v1/references/locations with name or zip_codes.
Area Insights MCP boundaries are location ids or a circle, not polygons
The Area Insights MCP tools take location_ids (up to 10) or a circle of 50 to 50,000 metres. A zip-code polygon cannot be passed to them directly.
Questions
Can I get a price trend for a single postcode?
Only approximately over MCP. Area Insights tools take location ids or a circle, not polygons. You can pass a circle of 50 to 50,000 metres centred inside the postcode. Or, as a client account, find a matching location id with POST /api/v1/references/locations and its zip_codes filter, then use it in area-insights_get_time_series_data. A circle will not follow the postcode's exact boundary.
Which countries does the zip-code boundary operation support?
The hub publishes no country list for POST /api/v1/references/zipcode-boundary. The operation takes a zip_code and an ISO 3166-1 alpha-2 country_code. The API's permissions cover 16 markets, but support for a given country's postcodes is not stated. Check the operation page or ask Casafari at https://www.casafari.com/ before you rely on a specific country.
Can I search several postcodes at once?
It depends on the operation. Alert search accepts custom_locations, a list of closed polygons. Property search accepts a list of location_ids. comparables_get_comparables takes one polygon or one circle per request, so for comparables run one request per postcode.
How do I find the location id for a postcode?
Over REST, as a Casafari client account, send POST /api/v1/references/locations with zip_codes; it returns matching locations from the location tree. In Spain and Portugal, the REST typeahead also finds locations by name. Over MCP, Location Lookup's locations_search takes English place names, and also a postcode (exact or prefix match): Spain is covered fully, France partly and Portugal not yet. Comparables results also show zip_codes inside each location.