# Posticy Marketplace API documentation Documentation supplement 1.1.0, 4 December 2026. Existing API reference 1.3.0; no backend release. Primary documentation: https://marketplace.posticy.com/developers/api/reference Use the X-API-Key header and keep your key in POSTICY_API_KEY on your server or local machine. The following reference contains illustrative IDs, URLs and prices, not live offers. Exact error text may vary; rely on HTTP status and structured fields. --- title: Marketplace Website API Documentation --- # Marketplace Website API Documentation ## Overview The Marketplace Website API provides access to a curated list of verified websites with their pricing information. This API is designed for external partners and consumers who need to integrate website marketplace data into their applications. Every website exposes up to two purchasable services: a **guest post** and a **link insertion** (also called a *Niche Edit* on Posticy). Each service has its own availability, price and currency. See [Services and pricing](#Services-and-pricing). ## Base URL ``` https://marketplace.posticy.com/api/v1/marketplace/websites ``` ## Authentication All API requests require authentication using an API key. The API key must be provided in one of two ways: ### Method 1: HTTP Header (Recommended) ``` X-API-Key: MKT_your_api_key_here ``` ### Method 2: Query Parameter ``` ?api_key=MKT_your_api_key_here ``` **Note:** All valid API keys must start with the prefix `MKT_`. Never put a key in a URL you share, log or paste into tickets; prefer the header. ## Rate Limiting - **List Endpoint:** 300 requests per minute per IP address - **Single Item Endpoint:** 120 requests per minute per IP address Rate limits are tracked **per IP address**, not per API key. If multiple integrations share an outbound IP (e.g. behind a corporate proxy or NAT), they share the same limit. When rate limit is exceeded, the API returns a `429 Too Many Requests` response with a `retry_after` field indicating seconds to wait. With the maximum page size (100), a full crawl of a catalogue of about 14,000 websites is roughly 140 requests, well inside the list limit. ## Caching - **List Results:** Cached for 5 minutes - **Single Website:** Cached for 10 minutes Identical requests within the cache period will return cached results for improved performance. --- ## Services and pricing ### Services | Service | Meaning | Available when | |---------|---------|----------------| | `guest_post` | A new article is published on the website, with a link to the buyer. | The website has a guest post price greater than 0. | | `link_insertion` | A link is added into an article that is already published (a *Niche Edit*). | The website offers the *Niche Edit* format **and** has a price (see below). | Both services are returned for every website inside the `services` object. A service that is not offered has `available: false` and `null` for `price`, `currency` and `price_source`. An unavailable service must never be treated as purchasable, and a missing price is never returned as `0`. ### Price source for link insertion A website that offers link insertion normally has its own link insertion price. If the Publisher did not set one, Posticy charges the guest post price, and the API reports this explicitly: | `price_source` | Meaning | |----------------|---------| | `link_insertion` | The price is the Publisher's own link insertion price. | | `guest_post_fallback` | No separate link insertion price is set; the guest post price (and currency) applies. | | `null` | Link insertion is not available. | ### Price and currency semantics - `price` and `currency` always belong together. **Prices are not converted:** `currency` is the currency the Publisher quoted (`EUR`, `USD` or `GBP`). - A guest post and a link insertion on the same website can have different prices **and** different currencies. - The price is the **Publisher's quoted price**. It does **not** include Posticy's fees or tax, which are added at payment on Posticy. Do not present it to your users as an all-in price. - **Writing is not included.** The price covers publication of the link on the Publisher's website. Content writing is a separate Posticy service and is not part of any price returned by this API. The API does not return a writing field. - The flat `price` / `currency` fields at the top level of a website are the **guest post** price, kept unchanged for backward compatibility. For a website that only offers link insertion, the flat `price` is `0`; use `services` instead. ### Link insertion and Niche Edit On Posticy, *link insertion* and *Niche Edit* are the same product. This API uses the name `link_insertion`. --- ## Endpoints ### 1. Get Websites List Retrieve a paginated list of available websites with filtering options. #### Request ```http GET /api/v1/marketplace/websites ``` #### Headers ``` X-API-Key: MKT_your_api_key_here Accept: application/json ``` #### Query Parameters | Parameter | Type | Required | Default | Description | |-----------|------|----------|---------|-------------| | `per_page` | integer | No | 50 | Items per page (1-100) | | `page` | integer | No | 1 | Page number (min: 1) | | `min_price` | numeric | No | - | Minimum guest post price (raw amount, **not** currency-converted) | | `max_price` | numeric | No | - | Maximum guest post price (raw amount, **not** currency-converted) | | `country_id` | array | No | - | Filter by country IDs | | `category_id` | array | No | - | Filter by category IDs | | `language_id` | array | No | - | Filter by language IDs | | `link_type` | string | No | - | Filter by link type: `Dofollow` or `Nofollow` | | `min_da` / `max_da` | numeric (0-100) | No | - | Filter by Moz Domain Authority | | `min_dr` / `max_dr` | numeric (0-100) | No | - | Filter by Ahrefs Domain Rating | | `min_referring_domains` / `max_referring_domains` | integer | No | - | Filter by number of referring domains | | `min_backlinks` / `max_backlinks` | integer | No | - | Filter by total backlinks | | `min_spam_score` / `max_spam_score` | numeric | No | - | Filter by Moz Spam Score | | `min_organic_traffic` / `max_organic_traffic` | numeric | No | - | Filter by estimated organic traffic | | `min_organic_keywords` / `max_organic_keywords` | integer | No | - | Filter by number of ranking organic keywords | **Notes:** - `min_price` / `max_price` compare the raw guest post amount stored for each website, whatever its currency. A filter of `50-500` therefore matches a 400 USD site and a 400 EUR site alike. If you need a single currency, filter on the returned `currency` on your side. - Websites whose SEO metrics haven't been scraped yet (value `"unknown"` internally) are excluded from `min_*`/`max_*` SEO filters rather than being treated as `0` : a lone `max_spam_score` filter won't accidentally pull in unscraped sites. #### Ordering and pagination Results are ordered by the website's internal ID, ascending, so the order is the same on every request and every website appears on exactly one page. Pagination is offset based (`page` / `per_page`). The catalogue can change while you crawl it (a website is added, hidden, deactivated or its status changes). Because pages are offsets, a change between two page requests can shift the rows: a listing near a page boundary may be missed or seen twice in that crawl. There is currently no snapshot or cursor. Recommended crawl procedure: 1. Request pages `1…total_pages` using the same filters and a fixed `per_page`. 2. De-duplicate by `id`. 3. Compare the number of unique `id`s with `pagination.total`. If they differ by more than a few rows, treat the crawl as incomplete and run it again. 4. Treat a listing as removed or hidden only after a **complete, successful** crawl in which it did not appear. Never act on a partial crawl. #### Example Requests Basic pagination + price filter: ```bash curl --globoff -X GET "https://marketplace.posticy.com/api/v1/marketplace/websites?per_page=20&page=1&min_price=50&max_price=500&country_id[]=1&country_id[]=2" \ -H "X-API-Key: MKT_your_api_key_here" \ -H "Accept: application/json" ``` Only Dofollow websites with DR 50+ and low spam score: ```bash curl --globoff -X GET "https://marketplace.posticy.com/api/v1/marketplace/websites?link_type=Dofollow&min_dr=50&max_spam_score=5" \ -H "X-API-Key: MKT_your_api_key_here" \ -H "Accept: application/json" ``` High-authority sites (DA 80+ and DR 80+): ```bash curl --globoff -X GET "https://marketplace.posticy.com/api/v1/marketplace/websites?min_da=80&min_dr=80" \ -H "X-API-Key: MKT_your_api_key_here" \ -H "Accept: application/json" ``` Sites with strong link profile and good organic traffic: ```bash curl --globoff -X GET "https://marketplace.posticy.com/api/v1/marketplace/websites?min_referring_domains=500&min_backlinks=1000&min_organic_traffic=1000" \ -H "X-API-Key: MKT_your_api_key_here" \ -H "Accept: application/json" ``` Combine price, category, and SEO filters: ```bash curl --globoff -X GET "https://marketplace.posticy.com/api/v1/marketplace/websites?min_price=50&max_price=100&category_id[]=3&min_da=40&min_organic_keywords=100" \ -H "X-API-Key: MKT_your_api_key_here" \ -H "Accept: application/json" ``` #### Success Response (200 OK) The three websites below show the three service combinations: guest post only, both services with different prices and currencies, and link insertion on the guest post price. ```json { "success": true, "data": [ { "id": "abc123", "domain": "example.com", "full_domain": "https://www.example.com", "listing_url": "https://marketplace.posticy.com/marketplace/www-example-com", "price": 299.99, "currency": "EUR", "services": { "guest_post": { "available": true, "price": 299.99, "currency": "EUR" }, "link_insertion": { "available": false, "price": null, "currency": null, "price_source": null } }, "country": "United States", "language": "English", "category": ["Business"], "link_type": "Dofollow", "da": 64, "dr": 69, "referring_domains": 7609, "total_backlinks": 58185, "spam_score": 3, "organic_keywords": 2784, "organic_traffic": 3175.11 }, { "id": "def456", "domain": "another-site.net", "full_domain": "https://another-site.net", "listing_url": "https://marketplace.posticy.com/marketplace/another-site-net", "price": 150, "currency": "USD", "services": { "guest_post": { "available": true, "price": 150, "currency": "USD" }, "link_insertion": { "available": true, "price": 80, "currency": "EUR", "price_source": "link_insertion" } }, "country": "Poland", "language": "English", "category": ["Advertising", "Business"], "link_type": "Dofollow", "da": 34, "dr": 39, "referring_domains": 463, "total_backlinks": 3243, "spam_score": 1, "organic_keywords": 287, "organic_traffic": 273.15 }, { "id": "ghi789", "domain": "third-site.org", "full_domain": "https://third-site.org", "listing_url": "https://marketplace.posticy.com/marketplace/third-site-org", "price": 60, "currency": "GBP", "services": { "guest_post": { "available": true, "price": 60, "currency": "GBP" }, "link_insertion": { "available": true, "price": 60, "currency": "GBP", "price_source": "guest_post_fallback" } }, "country": "United Kingdom", "language": "English", "category": ["Technology"], "link_type": "Nofollow", "da": 28, "dr": 31, "referring_domains": 210, "total_backlinks": 980, "spam_score": 2, "organic_keywords": 95, "organic_traffic": 120.4 } ], "pagination": { "current_page": 1, "per_page": 20, "total": 150, "total_pages": 8, "has_next_page": true, "has_prev_page": false }, "filters_applied": { "min_price": 50, "max_price": 500, "country_ids": [1, 2], "category_ids": [], "language_ids": [], "link_type": null, "min_da": null, "max_da": null, "min_dr": null, "max_dr": null, "min_referring_domains": null, "max_referring_domains": null, "min_backlinks": null, "max_backlinks": null, "min_spam_score": null, "max_spam_score": null, "min_organic_traffic": null, "max_organic_traffic": null, "min_organic_keywords": null, "max_organic_keywords": null }, "message": "Found 150 websites" } ``` **Field notes:** - `id` : the stable listing identifier (Posticy custom ID). It does not change when a website is renamed; use it as your key. - `domain` : host name only; `full_domain` : the **Publisher's own website** URL, not a Posticy page. - `listing_url` : the public Posticy page of this listing (no login needed). It is built from the website's domain, so it changes if the domain is renamed; always re-read it from the API rather than storing it permanently. To resolve a listing from an `id`, call the single-website endpoint. - `price`, `currency` : the **guest post** price and its currency, unchanged from earlier versions. - `services` : see [Services and pricing](#Services-and-pricing). - `category` : array of all category names assigned to the website (a website can belong to more than one category), sorted alphabetically; empty array if none are set - `da` : Moz Domain Authority (0-100) - `dr` : Ahrefs Domain Rating (0-100) - `spam_score` : Moz Spam Score - `organic_keywords` : number of keywords the domain ranks for (Ahrefs, falls back to a secondary source when Ahrefs data is unavailable) - `organic_traffic` : Ahrefs' estimated monthly organic search traffic; any of the SEO fields above may be `null` for websites that haven't been scraped yet --- ### 2. Get Single Website Retrieve detailed information about a specific website by its ID. #### Request ```http GET /api/v1/marketplace/websites/{id} ``` #### Headers ``` X-API-Key: MKT_your_api_key_here Accept: application/json ``` #### URL Parameters | Parameter | Type | Required | Description | |-----------|------|----------|-------------| | `id` | string | Yes | Custom website ID (the `id` returned by the list) | #### Example Request ```bash curl --globoff -X GET "https://marketplace.posticy.com/api/v1/marketplace/websites/abc123" \ -H "X-API-Key: MKT_your_api_key_here" \ -H "Accept: application/json" ``` #### Success Response (200 OK) ```json { "success": true, "data": { "id": "abc123", "domain": "example.com", "full_domain": "https://www.example.com", "listing_url": "https://marketplace.posticy.com/marketplace/www-example-com", "price": 299.99, "currency": "EUR", "services": { "guest_post": { "available": true, "price": 299.99, "currency": "EUR" }, "link_insertion": { "available": true, "price": 120, "currency": "EUR", "price_source": "link_insertion" } }, "country_id": 1, "country": "United States", "language": "English", "category": ["Business"], "description": "High-quality technology blog with engaged audience", "link_type": "Dofollow", "da": 50, "dr": 40, "referring_domains": 351, "total_backlinks": 872, "spam_score": 5, "organic_keywords": 47, "organic_traffic": 0.18 } } ``` #### Unavailable or renamed listings - A listing that is **renamed** keeps the same `id`, so the single-website call still works; `domain`, `full_domain` and `listing_url` reflect the new name. - A listing that is **hidden, deactivated, unverified, or does not exist** returns `404 Not Found` with the same message in every case. The API does not tell these cases apart. - In the list endpoint, such a listing simply no longer appears. --- ## Error Responses ### 401 Unauthorized - Missing API Key ```json { "success": false, "message": "API key is required. Please provide it in X-API-Key header or api_key parameter." } ``` ### 401 Unauthorized - Invalid API Key Format Returned when the key doesn't start with the `MKT_` prefix. ```json { "success": false, "message": "Invalid API key format." } ``` ### 401 Unauthorized - Invalid API Key Returned when the key has a valid prefix but doesn't match a known key. ```json { "success": false, "message": "Invalid API key provided." } ``` ### 404 Not Found ```json { "success": false, "message": "Website not found or not available." } ``` ### 422 Unprocessable Entity - Validation Error ```json { "success": false, "message": "Validation failed", "errors": { "per_page": [ "The per page must be between 1 and 100." ], "min_price": [ "The min price must be at least 0." ] } } ``` ### 429 Too Many Requests ```json { "success": false, "message": "Too many requests. Please try again later.", "retry_after": 45 } ``` ### 500 Internal Server Error ```json { "success": false, "message": "An error occurred while fetching websites.", "error": "Detailed error message (only in debug mode)" } ``` --- ## Best Practices ### 1. Use Header Authentication Always use the `X-API-Key` header instead of query parameters for better security. ### 2. Implement Rate Limit Handling Monitor the `429` responses and wait for the number of seconds in the `retry_after` field: ```javascript async function fetchWithRetry(url, options, maxRetries = 3) { for (let i = 0; i < maxRetries; i++) { const response = await fetch(url, options); if (response.status === 429) { const data = await response.json(); const waitTime = data.retry_after * 1000; await new Promise(resolve => setTimeout(resolve, waitTime)); continue; } return response; } throw new Error('Max retries reached'); } ``` ### 3. Cache Results Locally Since the API implements caching, consider caching results on your end as well to reduce API calls. ### 4. Use Pagination Efficiently Request only the data you need by adjusting `per_page`. Larger page sizes reduce the number of requests but increase response time. Follow the crawl procedure in [Ordering and pagination](#Ordering-and-pagination). ### 5. Apply Filters Server-Side Use the available filters (`min_price`, `max_price`, `country_id`, etc.) instead of filtering results client-side. ### 6. Read `services`, not the flat `price` Use `services.guest_post` and `services.link_insertion` to decide what to offer your users, and always show the `currency` next to a price. --- ## Code Examples ### PHP (Laravel/Guzzle) ```php 'https://marketplace.posticy.com/api/v1/', 'headers' => [ 'X-API-Key' => 'MKT_your_api_key_here', 'Accept' => 'application/json', ] ]); try { $response = $client->get('marketplace/websites', [ 'query' => [ 'per_page' => 50, 'page' => 1, 'min_price' => 100, 'country_id' => [1, 2, 3] ] ]); $data = json_decode($response->getBody(), true); foreach ($data['data'] as $website) { $guestPost = $website['services']['guest_post']; $insertion = $website['services']['link_insertion']; echo "Domain: {$website['domain']}"; if ($guestPost['available']) { echo ", Guest post: {$guestPost['price']} {$guestPost['currency']}"; } if ($insertion['available']) { echo ", Link insertion: {$insertion['price']} {$insertion['currency']}"; } echo "\n"; } } catch (\Exception $e) { echo "Error: " . $e->getMessage(); } ``` ### Python ```python import requests API_KEY = 'MKT_your_api_key_here' BASE_URL = 'https://marketplace.posticy.com/api/v1/marketplace/websites' headers = { 'X-API-Key': API_KEY, 'Accept': 'application/json' } params = { 'per_page': 50, 'page': 1, 'min_price': 100, 'country_id[]': [1, 2, 3] } try: response = requests.get(BASE_URL, headers=headers, params=params) response.raise_for_status() data = response.json() for website in data['data']: parts = [f"Domain: {website['domain']}"] for name, service in website['services'].items(): if service['available']: parts.append(f"{name}: {service['price']} {service['currency']}") print(", ".join(parts)) except requests.exceptions.RequestException as e: print(f"Error: {e}") ``` ### JavaScript (Node.js) ```javascript const axios = require('axios'); const API_KEY = 'MKT_your_api_key_here'; const BASE_URL = 'https://marketplace.posticy.com/api/v1/marketplace/websites'; const headers = { 'X-API-Key': API_KEY, 'Accept': 'application/json' }; const params = { per_page: 50, page: 1, min_price: 100, 'country_id[]': [1, 2, 3] }; async function getWebsites() { try { const response = await axios.get(BASE_URL, { headers, params }); console.log(`Found ${response.data.pagination.total} websites`); response.data.data.forEach(website => { const offers = Object.entries(website.services) .filter(([, service]) => service.available) .map(([name, service]) => `${name}: ${service.price} ${service.currency}`); console.log(`Domain: ${website.domain}, ${offers.join(', ')}`); }); } catch (error) { console.error('Error:', error.response?.data || error.message); } } getWebsites(); ``` --- ## Frequently Asked Questions ### Q: What happens when I exceed rate limits? A: You'll receive a `429` status code with a `retry_after` field indicating how many seconds to wait. The limits are 300 requests per minute (list) and 120 requests per minute (single website), per IP address. ### Q: Which currency are prices in? A: Each price comes with its own `currency` (`EUR`, `USD` or `GBP`). Prices are **not** converted to a single currency, and a guest post and a link insertion on the same website can use different currencies. Always read the `currency` next to the price. ### Q: Do prices include tax or fees? A: No. Prices are the Publisher's quoted price. Posticy's fees and tax are added at payment. ### Q: Is writing included in the price? A: No. Prices cover publication of the link on the Publisher's website. Content writing is a separate Posticy service and is not exposed by this API. ### Q: What is the difference between a guest post and a link insertion? A: A guest post publishes a new article on the website. A link insertion (a *Niche Edit*) adds a link into an article that is already published. Check `services.guest_post.available` and `services.link_insertion.available` before offering either. ### Q: What does `guest_post_fallback` mean? A: The website offers link insertion but the Publisher has not set a separate price, so the guest post price and currency apply. See [Price source for link insertion](#Price-source-for-link-insertion). ### Q: How do I open the Posticy page for a listing? A: Use `listing_url` from the list or single-website response. The `id` is the stable key; `listing_url` follows the website's domain. ### Q: How often is the data updated? A: List/single responses are cached for 5-10 minutes as noted above. The underlying SEO metrics (`da`, `dr`, `referring_domains`, `total_backlinks`, `spam_score`, `organic_keywords`, `organic_traffic`) are refreshed on a separate, slower cycle : a scheduled job re-scrapes all websites monthly, with occasional out-of-cycle updates when a publisher boosts a listing. Treat these metrics as "up to ~30 days old", not real-time. ### Q: Why is a SEO field `null` for some websites? A: The website hasn't been scraped yet, or the scrape failed for that metric. `null` fields are also excluded from `min_*`/`max_*` filters on that metric (see the filter notes above) so they don't get miscounted as `0`. ### Q: What does "verified website" mean? A: Verified websites have been reviewed and approved by administrators and meet quality standards. --- ## Changelog ### Version 1.3.0 (Current) - **Added:** `services` object on both endpoints, with `guest_post` and `link_insertion` (`available`, `price`, `currency`, and `price_source` for link insertion). Additive; existing fields are unchanged. - **Added:** `listing_url` on both endpoints (public Posticy page of the listing). - **Fixed:** `currency` is now the website's real currency (`EUR`, `USD` or `GBP`). Previously the field was always `"EUR"` even for websites priced in another currency. Prices were never converted, so the amount is unchanged; only the label is corrected. - **Fixed:** the list is ordered by website ID, so pagination order is deterministic. - **Documented:** `min_price` / `max_price` compare raw amounts and are not currency-converted (earlier versions described them as EUR). - **Fixed:** the documented rate limits (300 requests per minute for the list, 120 for a single website, per IP) now apply. Previously a blanket limit of 60 requests per minute was applied first, so the documented numbers were never reached. - **Fixed:** `category` names are sorted alphabetically, so the order is the same on every request and on both endpoints. - **Documented:** price semantics (excludes fees and tax; writing not included), crawl procedure, and the behavior of renamed and unavailable listings. ### Version 1.2.0 - **Breaking:** `category` is now an array of all category names assigned to the website, instead of a single primary category string, on both endpoints ### Version 1.1.0 - Added SEO/backlink metrics to both endpoints: `da`, `dr`, `referring_domains`, `total_backlinks`, `spam_score`, `organic_keywords`, `organic_traffic` - Added `country`, `language`, and `category` names to both endpoints - Added `link_type` to the list endpoint (was previously single-website only) - Added SEO range filters: `min_da`/`max_da`, `min_dr`/`max_dr`, `min_referring_domains`/`max_referring_domains`, `min_backlinks`/`max_backlinks`, `min_spam_score`/`max_spam_score`, `min_organic_traffic`/`max_organic_traffic`, `min_organic_keywords`/`max_organic_keywords` - Added `link_type` filter ### Version 1.0.0 - Initial release - Get websites list endpoint - Get single website endpoint - Authentication via API key - Rate limiting implementation - Caching support - Comprehensive filtering options ## Additional PHP / Laravel / Guzzle example Requires Guzzle and Composer autoloading. Save beside vendor/ as catalog.php; set POSTICY_API_KEY privately and run php catalog.php. For Laravel use its existing autoloader instead of the standalone require line. Validated on 4 December in isolated PHP 8.5 WASM/Guzzle with local fixtures and a small live GET; this is not a full Posticy server bootstrap. The recorded 3 December results cover the original cURL, Python, JavaScript and Postman examples. ```php 'https://marketplace.posticy.com/api/v1/', 'headers' => ['X-API-Key' => $key, 'Accept' => 'application/json'], 'timeout' => 30, 'connect_timeout' => 10, 'allow_redirects' => false, 'http_errors' => false, ]); try { // One small read; no automatic retries or full-catalog crawl. $response = $client->get('marketplace/websites', [ 'query' => ['per_page' => 5, 'page' => 1, 'min_dr' => 30], ]); $status = $response->getStatusCode(); if ($status !== 200) { if ($status === 429) { $error = json_decode((string) $response->getBody(), true); $wait = is_array($error) ? ($error['retry_after'] ?? null) : null; if (is_numeric($wait) && is_finite((float) $wait) && $wait >= 0 && $wait <= 86400) { fwrite(STDERR, 'Rate limited. Wait ' . (int) ceil($wait) . " seconds before retrying.\n"); exit(1); } } throw new RuntimeException('Request failed'); } $body = json_decode((string) $response->getBody(), true, 512, JSON_THROW_ON_ERROR); if (!is_array($body) || ($body['success'] ?? false) !== true || !is_array($body['data'] ?? null) || !array_is_list($body['data'])) { throw new RuntimeException('Unexpected response'); } // Validate the entire page before printing anything, avoiding partial results. $lines = []; foreach ($body['data'] as $website) { if (!is_array($website) || !is_string($website['domain'] ?? null) || $website['domain'] === '' || !is_array($website['services'] ?? null)) { throw new RuntimeException('Unexpected listing'); } $offers = []; foreach (['guest_post', 'link_insertion'] as $name) { $service = $website['services'][$name] ?? null; if (!is_array($service) || !is_bool($service['available'] ?? null) || !array_key_exists('price', $service) || !array_key_exists('currency', $service)) { throw new RuntimeException('Unexpected service'); } if ($service['available']) { if (!is_numeric($service['price']) || !is_finite((float) $service['price']) || $service['price'] <= 0 || !in_array($service['currency'], ['EUR', 'USD', 'GBP'], true)) { throw new RuntimeException('Unexpected service price'); } $offers[] = $name . ': ' . $service['price'] . ' ' . $service['currency']; } elseif ($service['price'] !== null || $service['currency'] !== null) { throw new RuntimeException('Unexpected unavailable service'); } } // CLI output only; escape returned text if you render it in HTML. $lines[] = $website['domain'] . ' | ' . ($website['link_type'] ?? 'Unknown link type') . ' | ' . implode(', ', $offers); } if ($lines) { echo implode(PHP_EOL, $lines) . PHP_EOL; } } catch (Throwable $error) { // Do not log request headers, keys or raw exception messages. fwrite(STDERR, "Catalog request failed. Check access, input and connectivity.\n"); exit(1); } ```