{
    "openapi": "3.1.0",
    "info": {
        "title": "Straply API",
        "description": "Property-facts data API covering 140M+ US properties, matched across sources and refreshed continuously. Every record is source-blind (facts only — no owner PII, no estimates) and identified by an opaque Straply ID (e.g. stp_x7Kd9Qm2Rb). Query one property with its full price + tax history, search/filter by geography and attributes, get per-ZIP market statistics, or stream the recent-changes feed. Verify any figure against public records.",
        "contact": {
            "name": "Straply",
            "url": "https://straply.com/",
            "email": "support@straply.com"
        },
        "license": {
            "name": "Proprietary",
            "url": "https://straply.com/terms"
        },
        "version": "1.1.0"
    },
    "servers": [
        {
            "url": "https://api.straply.com",
            "description": "Production"
        }
    ],
    "security": [
        {
            "ApiKeyAuth": []
        }
    ],
    "paths": {
        "/golden/property/{property_id}": {
            "get": {
                "summary": "Get property by Straply ID",
                "description": "Fetch a single property by its opaque Straply ID (e.g. stp_x7Kd9Qm2Rb, as returned by /golden/search). Returns the full source-blind record: address, location, facts, market status, parcel, plus complete price history and tax history. An unknown or malformed ID returns 404.",
                "operationId": "get_property",
                "parameters": [
                    {
                        "name": "property_id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "title": "Straply property ID",
                            "examples": ["stp_x7Kd9Qm2Rb"]
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "The property record",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Property"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "No property with that ID",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/golden/search": {
            "get": {
                "summary": "Search properties",
                "description": "Search and filter properties. At least one filter is required (zip, state, city+state, property_type, status, min_beds, min_price, or max_price). Returns up to 100 source-blind property records (without history). Use the id of a result with /golden/property/{property_id} to fetch full history.",
                "operationId": "search_properties",
                "parameters": [
                    {"name": "zip", "in": "query", "required": false, "schema": {"type": "string", "title": "5-digit ZIP"}},
                    {"name": "state", "in": "query", "required": false, "schema": {"type": "string", "title": "2-letter state code"}},
                    {"name": "city", "in": "query", "required": false, "schema": {"type": "string", "title": "City name (requires state)"}},
                    {"name": "property_type", "in": "query", "required": false, "schema": {"$ref": "#/components/schemas/PropertyType"}},
                    {"name": "status", "in": "query", "required": false, "schema": {"$ref": "#/components/schemas/Status"}},
                    {"name": "min_beds", "in": "query", "required": false, "schema": {"type": "integer", "minimum": 0}},
                    {"name": "min_price", "in": "query", "required": false, "schema": {"type": "integer", "minimum": 0}},
                    {"name": "max_price", "in": "query", "required": false, "schema": {"type": "integer", "minimum": 0}},
                    {"name": "limit", "in": "query", "required": false, "schema": {"type": "integer", "minimum": 1, "maximum": 100, "default": 25}},
                    {"name": "offset", "in": "query", "required": false, "schema": {"type": "integer", "minimum": 0, "default": 0}}
                ],
                "responses": {
                    "200": {
                        "description": "Matching properties",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "count": {"type": "integer"},
                                        "results": {"type": "array", "items": {"$ref": "#/components/schemas/Property"}}
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "No filter provided",
                        "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}
                    }
                }
            }
        },
        "/golden/market/{zip}": {
            "get": {
                "summary": "Market statistics for a ZIP code",
                "description": "Aggregated market statistics for a ZIP code: total properties and, per listing status, the count and average list price.",
                "operationId": "market_stats",
                "parameters": [
                    {"name": "zip", "in": "path", "required": true, "schema": {"type": "string", "title": "5-digit ZIP"}}
                ],
                "responses": {
                    "200": {
                        "description": "Market statistics",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "zip": {"type": "string"},
                                        "total_properties": {"type": "integer"},
                                        "by_status": {
                                            "type": "object",
                                            "additionalProperties": {
                                                "type": "object",
                                                "properties": {
                                                    "count": {"type": "integer"},
                                                    "avg_price": {"type": "integer"}
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/golden/changes": {
            "get": {
                "summary": "Change feed",
                "description": "Source-blind feed of what moved in the market, each event keyed by the opaque Straply ID. Backed by a nightly value-diff of consecutive national snapshots, so it is complete across every source rather than reflecting whichever one happened to update, and self-correcting: a re-write that does not change a value is never reported as a change. The daily diff is the atom \u2014 days=N sums N daily diffs rather than diffing the endpoints, so churn inside the window (listed and sold in the same week) is preserved. Defaults to real market events; roughly three quarters of raw daily changes are reference-price movement on off-market homes, so pass include=all for every bucket.",
                "operationId": "change_feed",
                "parameters": [
                    {"name": "days", "in": "query", "required": false, "description": "How many daily diffs to sum (the atom is 1 day).", "schema": {"type": "integer", "minimum": 1, "maximum": 30, "default": 1}},
                    {"name": "include", "in": "query", "required": false, "description": "'market' = real market events only; 'all' = every bucket including data churn.", "schema": {"type": "string", "enum": ["market", "all"], "default": "market"}},
                    {"name": "change_type", "in": "query", "required": false, "description": "Comma-separated filter, e.g. price_cut,just_sold.", "schema": {"type": "string"}},
                    {"name": "state", "in": "query", "required": false, "schema": {"type": "string", "title": "2-letter state code"}},
                    {"name": "zip", "in": "query", "required": false, "schema": {"type": "string", "title": "5-digit ZIP"}},
                    {"name": "limit", "in": "query", "required": false, "schema": {"type": "integer", "minimum": 1, "maximum": 5000, "default": 1000}},
                    {"name": "offset", "in": "query", "required": false, "schema": {"type": "integer", "minimum": 0, "default": 0}},
                    {"name": "hours", "in": "query", "required": false, "deprecated": true, "description": "Deprecated alias for days; rounded up to whole days.", "schema": {"type": "integer", "minimum": 1, "maximum": 720}}
                ],
                "responses": {
                    "200": {
                        "description": "Change events",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "as_of": {"type": "string", "format": "date", "nullable": true, "description": "Snapshot date of the newest diff in the window"},
                                        "days": {"type": "integer"},
                                        "include": {"type": "string"},
                                        "count": {"type": "integer"},
                                        "changes": {"type": "array", "items": {"$ref": "#/components/schemas/ChangeEvent"}}
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/golden/changes/summary": {
            "get": {
                "summary": "Change feed summary",
                "description": "Bucket counts for the change feed \u2014 how much moved, without pulling the rows. Use it to size a sync, or to show how much has happened since a snapshot was taken.",
                "operationId": "change_feed_summary",
                "parameters": [
                    {"name": "days", "in": "query", "required": false, "schema": {"type": "integer", "minimum": 1, "maximum": 30, "default": 1}}
                ],
                "responses": {
                    "200": {
                        "description": "Bucket counts",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "as_of": {"type": "string", "format": "date", "nullable": true},
                                        "days": {"type": "integer"},
                                        "versions": {"type": "array", "items": {"type": "string", "format": "date"}},
                                        "total": {"type": "integer", "description": "All change events in the window"},
                                        "market_total": {"type": "integer", "description": "Real market events only"},
                                        "headline": {"type": "object", "properties": {"new_listings": {"type": "integer"}, "price_cuts": {"type": "integer"}, "just_sold": {"type": "integer"}, "went_pending": {"type": "integer"}}},
                                        "buckets": {"type": "object", "additionalProperties": {"type": "integer"}}
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/v1/health": {
            "get": {
                "summary": "Health check",
                "operationId": "health_check",
                "security": [],
                "responses": {
                    "200": {
                        "description": "Service is healthy",
                        "content": {
                            "application/json": {
                                "schema": {"$ref": "#/components/schemas/HealthResponse"}
                            }
                        }
                    }
                }
            }
        }
    },
    "components": {
        "securitySchemes": {
            "ApiKeyAuth": {
                "type": "http",
                "scheme": "bearer",
                "description": "Send your Straply API key as a Bearer token: `Authorization: Bearer <api_key>`. Get a free key at https://straply.com/dashboard."
            }
        },
        "schemas": {
            "ChangeEvent": {
                "type": "object",
                "properties": {
                    "id": {"type": "string", "title": "Straply property ID", "examples": ["stp_x7Kd9Qm2Rb"]},
                    "as_of": {"type": "string", "format": "date", "description": "Snapshot date this change was detected on"},
                    "change": {"type": "string", "enum": ["just_sold", "went_pending", "fell_through", "came_on_market", "back_on_market", "delisted", "price_cut", "price_increase", "new_listing", "reference_price_change", "status_other", "new_to_dataset", "other_change", "removed"]},
                    "status": {"type": "object", "properties": {"from": {"type": "string", "nullable": true}, "to": {"type": "string", "nullable": true}}},
                    "list_price": {"type": "object", "properties": {"from": {"type": "integer", "nullable": true}, "to": {"type": "integer", "nullable": true}}},
                    "sold_price": {"type": "integer", "nullable": true},
                    "zip": {"type": "string", "nullable": true},
                    "state": {"type": "string", "nullable": true},
                    "property_type": {"type": "string", "nullable": true}
                }
            },
            "Property": {
                "type": "object",
                "description": "A source-blind property record. Facts only — no owner PII, no estimates.",
                "properties": {
                    "id": {"type": "string", "description": "Opaque Straply ID", "examples": ["stp_x7Kd9Qm2Rb"]},
                    "address": {
                        "type": "object",
                        "properties": {
                            "street": {"type": "string", "nullable": true},
                            "unit": {"type": "string", "nullable": true},
                            "city": {"type": "string", "nullable": true},
                            "state": {"type": "string", "nullable": true},
                            "zip": {"type": "string", "nullable": true}
                        }
                    },
                    "location": {
                        "type": "object",
                        "properties": {
                            "lat": {"type": "number", "nullable": true},
                            "lng": {"type": "number", "nullable": true}
                        }
                    },
                    "facts": {
                        "type": "object",
                        "properties": {
                            "property_type": {"$ref": "#/components/schemas/PropertyType"},
                            "beds": {"type": "integer", "nullable": true},
                            "baths": {"type": "number", "nullable": true},
                            "sqft": {"type": "integer", "nullable": true},
                            "lot_sqft": {"type": "integer", "nullable": true},
                            "year_built": {"type": "integer", "nullable": true}
                        }
                    },
                    "market": {
                        "type": "object",
                        "properties": {
                            "status": {"$ref": "#/components/schemas/Status"},
                            "list_price": {"type": "integer", "nullable": true},
                            "last_sold_price": {"type": "integer", "nullable": true},
                            "last_sold_date": {"type": "string", "nullable": true}
                        }
                    },
                    "parcel": {
                        "type": "object",
                        "properties": {
                            "apn": {"type": "string", "nullable": true},
                            "county_fips": {"type": "string", "nullable": true}
                        }
                    },
                    "data_points": {"type": "integer", "description": "How many sources corroborate this record (not which)"},
                    "price_history": {
                        "type": "array",
                        "description": "Only present on /golden/property/{property_id}",
                        "items": {
                            "type": "object",
                            "properties": {
                                "date": {"type": "string"},
                                "event": {"type": "string"},
                                "price": {"type": "integer", "nullable": true}
                            }
                        }
                    },
                    "tax_history": {
                        "type": "array",
                        "description": "Only present on /golden/property/{property_id}",
                        "items": {
                            "type": "object",
                            "properties": {
                                "year": {"type": "integer"},
                                "amount": {"type": "integer", "nullable": true},
                                "assessment": {"type": "integer", "nullable": true}
                            }
                        }
                    }
                }
            },
            "PropertyType": {
                "type": "string",
                "enum": ["single_family", "condo", "townhouse", "multi_family", "manufactured", "land", "apartment", "coop", "other"]
            },
            "Status": {
                "type": "string",
                "enum": ["active", "pending", "contingent", "sold", "off_market", "coming_soon", "other"]
            },
            "Error": {
                "type": "object",
                "properties": {
                    "error": {"type": "string"}
                }
            },
            "HealthResponse": {
                "type": "object",
                "required": ["status", "version", "timestamp"],
                "properties": {
                    "status": {"type": "string"},
                    "version": {"type": "string"},
                    "timestamp": {"type": "string"}
                }
            }
        }
    }
}
