Tutorial Web Development · 7 min read

Building a Propstack API Integration Plugin for WordPress

A developer's guide to building a plugin that seamlessly fetches and displays real estate listings from the Propstack API.

Real estate websites live or die by their listings. If you manage your properties in Propstack but your public site runs on WordPress, you're faced with a tedious choice: copy every listing over by hand, or build a bridge between the two.

This post walks through how I built that bridge — a WordPress plugin that pulls listings straight from the Propstack API and renders them on your site, automatically and on demand.

The goal

The plugin needs to do four things well:

  1. Authenticate against the Propstack API and fetch property data.
  2. Cache that data so the site stays fast and the API stays happy.
  3. Render listings through clean, themeable templates.
  4. Let a non-technical site owner configure and use it without touching code.

Everything else is detail. Let's go through each piece.

Talking to the API

Propstack exposes a REST API (version 2) at https://api.propstack.de/v2. The entire integration is built around a single PropstackAPI class that wraps every request to that endpoint. Centralizing API access in one class means authentication, error handling, and caching all live in one place rather than being scattered across the codebase.

Propstack v2 authenticates via an HTTP header, X-Api-Key, rather than passing the key in the URL. That's both more secure (keys don't leak into server logs or browser history) and cleaner:

PHP
$args = array(
    'timeout' => 30,
    'headers' => array(
        'X-Api-Key'  => $this->api_key,
        'Accept'     => 'application/json',
        'User-Agent' => $this->get_user_agent(),
    ),
    'sslverify' => true,
);

$response = wp_remote_get($final_url, $args);

Notice this uses WordPress's own wp_remote_get() rather than raw cURL. That's deliberate: the built-in HTTP API inherits WordPress's filters, proxy settings, and error handling, and it returns tidy WP_Error objects you can check with is_wp_error(). You get robust networking for free.

Caching: don't hammer the API

Calling an external API on every single page load is slow for your visitors and wasteful for Propstack's servers. The plugin solves this with WordPress transients — the native key-value cache.

Each API response is stored under a transient key with a configurable expiry. The default is five minutes, exposed as an admin setting so site owners can tune freshness versus speed. There's a sensible 60-second floor so nobody accidentally sets it to zero and DDoSes the API:

PHP
// Convert the minutes setting into seconds, never below 60.
$this->cache_duration = max(60, intval($cache_setting) * 60);

Repeat visitors get instant cached results; the API only gets touched when the cache expires.

Rendering listings with shortcodes

The friendliest way to let WordPress users place dynamic content anywhere is the shortcode. The plugin registers several:

  • [propstack_listings] — a paginated grid of properties
  • [propstack_property] — a single property detail view
  • [propstack_search] — a search form with live AJAX results

A site owner just drops a shortcode into any page or post. The listings grid accepts a rich set of attributes for filtering and layout:

[propstack_listings limit="9" columns="3" city="Berlin" min_price="200000" max_price="800000"]

Under the hood, every attribute is sanitized and clamped to safe ranges before it ever reaches the API — columns is forced between 1 and 4, limit between 1 and 50, prices cast to floats, and so on. Never trust shortcode input.

For a single property:

[propstack_property id="123" show_gallery="true" show_contact="true"]

Themeable templates

Output is rendered through PHP template files (a property grid template, a single-property template, a search form), kept separate from the data-fetching logic. This separation matters: it means the markup can be overridden by the active theme without editing the plugin.

The plugin checks the theme directory first, then falls back to its own bundled templates:

  1. your-theme/propstack/property-card.php
  2. your-theme/propstack-property-card.php
  3. plugin/templates/property-card.php

Designers can restyle listings entirely from the theme, and their changes survive plugin updates.

A "load more" that doesn't reload the page

Pagination via full page reloads feels dated. The plugin registers an AJAX endpoint — wired up for both logged-in and anonymous visitors — that fetches the next page of properties and appends them to the grid:

PHP
add_action('wp_ajax_load_more_properties', array($this, 'load_more_properties'));
add_action('wp_ajax_nopriv_load_more_properties', array($this, 'load_more_properties'));

Every AJAX request is protected with a WordPress nonce to guard against cross-site request forgery.

Making it usable for non-developers

A good integration is invisible to the person running the site. The admin side includes:

  • A settings page under Settings with the API key field, cache duration, currency symbol, and image defaults.
  • A "Test Connection" button that fires an AJAX call to Propstack so you get instant confirmation your key works — no guessing.
  • Admin notices that nudge you to add your API key if it's missing.
  • Contextual help tabs explaining setup and shortcode usage right where you need them.

Being a good WordPress citizen

The finishing touches separate a hobby plugin from a maintainable one:

  • Requirement checks on activation. The plugin verifies PHP 7.4+ and WordPress 5.0+ and refuses to activate gracefully if they aren't met, rather than throwing fatal errors.
  • Translation-ready. Every user-facing string is wrapped in WordPress i18n functions with a text domain, so the plugin can be localized.
  • Clean uninstall. A dedicated uninstall.php removes all options, cached transients, and user meta when the plugin is deleted — no orphaned junk left behind in your database.

Takeaways

The architecture here generalizes to almost any third-party API integration in WordPress:

  1. Wrap the API in one class so authentication and caching live in a single place.
  2. Lean on native WordPress APIs — wp_remote_get() for HTTP, transients for caching, shortcodes for placement.
  3. Separate data from presentation with overridable templates.
  4. Expose configuration through a settings page and clean up after yourself on uninstall.

Get those four things right, and the rest really is just templates. The result is a Propstack-powered real estate site that updates itself — your listings live in one place, and your website simply reflects them.

Have a puzzle?

If your project involves complex requirements that standard platforms can't handle—let's talk.