Skip to Content
Paywall Server-Side SDKGet prices

Get Prices

Retrieve paywall prices and their corresponding IDs for use in checkout creation and subscription management.

Server-Side Only: This is a server-side API that requires authentication with your API key.

Overview

The Get Prices API endpoint allows you to retrieve all available prices for a specific paywall. This is essential for:

  • Dynamic pricing displays - Show current prices in your application
  • Checkout creation - Get price IDs for creating checkout sessions
  • Plan comparison - Build pricing tables and comparison views
  • Integration setup - Programmatically access pricing information

API Reference

Endpoint

GET https://onlineapp.pro/api/v1/paywall/{paywallId}/prices

Authentication

Include the x-api-key header with your API key.

Get your API key

API Key Location

Get your paywall ID

Navigate to your paywall settings page and get the ID from the Paywall ID field:

Paywall ID location

URL Parameters

ParameterTypeRequiredDescription
paywallIdstringYesYour paywall identifier

Response Format

{ "error": null, "data": [ { "id": 98, "unit_amount": 9.99, "interval": "month" }, { "id": 99, "unit_amount": 59.99, "interval": "year" } ], "count": null, "status": 200, "statusText": "OK" }

Response Fields

FieldTypeDescription
errorstringError message if request failed, null if successful
dataarrayArray of price objects
countnumberNumber of prices returned (null in this endpoint)
statusnumberHTTP status code
statusTextstringHTTP status text

Price Object Fields

FieldTypeDescription
idnumberUnique price identifier
unit_amountnumberPrice amount (in your currency)
intervalstringBilling interval: “month”, “year”, “lifetime”

Basic Usage

Sample Implementation

const paywallId = '123'; const response = await fetch(`https://onlineapp.pro/api/v1/paywall/${paywallId}/prices`, { method: 'GET', headers: { 'Content-Type': 'application/json', 'x-api-key': 'your-secret-api-key' } }); const result = await response.json(); if (result.error) { console.error('Error:', result.error); } else { console.log('Prices:', result.data); }

Error Handling

Common Error Responses

StatusErrorDescription
400Bad RequestInvalid paywall ID format
401UnauthorizedInvalid or missing API key
404Not FoundPaywall not found
500Internal ErrorServer error

Error Handling Example

const safeFetchPrices = async (paywallId, apiKey) => { try { const response = await fetch(`https://onlineapp.pro/api/v1/paywall/${paywallId}/prices`, { method: 'GET', headers: { 'Content-Type': 'application/json', 'x-api-key': apiKey } }); if (!response.ok) { let errorMessage = 'Unknown error occurred'; switch (response.status) { case 400: errorMessage = 'Invalid paywall ID provided.'; break; case 401: errorMessage = 'Authentication failed. Please check your API key.'; break; case 404: errorMessage = 'Paywall not found. Please verify the paywall ID.'; break; default: errorMessage = 'Unable to fetch prices. Please try again later.'; } throw new Error(errorMessage); } const result = await response.json(); if (result.error) { throw new Error(result.error); } return result.data; } catch (error) { console.error('Price fetch error:', error); throw error; } };

Security Guidelines

1. Store API keys securely

// Good: Server-side environment variable const apiKey = process.env.PAYWALL_API_KEY; // Bad: Client-side exposure // const apiKey = 'your-api-key'; // Never do this!

2. Use HTTPS for all requests

All API requests must use HTTPS to ensure secure communication.

Next Steps

Last updated on