Skip to content

Products Guide

Learn how to work with products via the Pixlpay API.

List Products

Retrieve all products with optional filtering and pagination.

bash
curl "https://yourstore.pixlpay.net/api/external/v1/products" \
  -H "Authorization: Bearer YOUR_API_TOKEN"

Query Parameters

ParameterTypeDescription
searchstringSearch by name or description
typestringFilter by type: digital, physical, subscription
category_idintegerFilter by category
is_activebooleanFilter by active status
sort_bystringSort field: created_at, name, price
sort_orderstringasc or desc
pageintegerPage number
per_pageintegerItems per page (max 100)

Example with Filters

bash
curl "https://yourstore.pixlpay.net/api/external/v1/products?type=digital&is_active=true&sort_by=price&sort_order=asc" \
  -H "Authorization: Bearer YOUR_API_TOKEN"

Response

json
{
  "success": true,
  "data": [
    {
      "id": 1,
      "name": "VIP Rank",
      "description": "Access to VIP features and commands",
      "price": "9.99",
      "type": "digital",
      "is_active": true,
      "stock_quantity": null,
      "category": {
        "id": 1,
        "name": "Ranks"
      },
      "images": [
        {
          "id": 1,
          "url": "https://cdn.pixlpay.net/products/vip-rank.png",
          "is_primary": true
        }
      ],
      "created_at": "2025-01-15T10:00:00Z",
      "updated_at": "2025-01-15T10:00:00Z"
    }
  ],
  "meta": {
    "current_page": 1,
    "last_page": 3,
    "per_page": 15,
    "total": 42
  }
}

Get Single Product

Retrieve detailed information about a specific product.

bash
curl "https://yourstore.pixlpay.net/api/external/v1/products/1" \
  -H "Authorization: Bearer YOUR_API_TOKEN"

Response

json
{
  "success": true,
  "data": {
    "id": 1,
    "name": "VIP Rank",
    "description": "Access to VIP features and commands",
    "price": "9.99",
    "compare_at_price": "14.99",
    "type": "digital",
    "is_active": true,
    "is_featured": false,
    "stock_quantity": null,
    "sku": "VIP-001",
    "category": {
      "id": 1,
      "name": "Ranks"
    },
    "images": [
      {
        "id": 1,
        "url": "https://cdn.pixlpay.net/products/vip-rank.png",
        "is_primary": true
      }
    ],
    "metadata": {
      "discord_role_id": "123456789",
      "duration_days": 30
    },
    "created_at": "2025-01-15T10:00:00Z",
    "updated_at": "2025-01-15T10:00:00Z"
  }
}

Product Types

TypeDescription
digitalDownloadable or virtual items (ranks, keys, etc.)
physicalPhysical goods that require shipping
subscriptionRecurring billing products

Pagination

All list endpoints return paginated results:

json
{
  "meta": {
    "current_page": 1,
    "last_page": 5,
    "per_page": 15,
    "total": 72
  }
}

Iterating Through Pages

javascript
async function getAllProducts() {
  const products = [];
  let page = 1;
  let hasMore = true;

  while (hasMore) {
    const response = await fetch(
      `${BASE_URL}/products?page=${page}&per_page=100`,
      { headers: { Authorization: `Bearer ${token}` } }
    );
    const data = await response.json();

    products.push(...data.data);

    hasMore = page < data.meta.last_page;
    page++;
  }

  return products;
}

Common Use Cases

Sync Products to External System

javascript
async function syncProducts() {
  const products = await pixlpay.getProducts();

  for (const product of products) {
    await externalSystem.upsert({
      external_id: product.id,
      name: product.name,
      price: product.price,
      active: product.is_active,
    });
  }
}

Display Products by Category

javascript
async function getProductsByCategory(categoryId) {
  const response = await fetch(
    `${BASE_URL}/products?category_id=${categoryId}&is_active=true`,
    { headers: { Authorization: `Bearer ${token}` } }
  );
  return response.json();
}

Search Products

javascript
async function searchProducts(query) {
  const response = await fetch(
    `${BASE_URL}/products?search=${encodeURIComponent(query)}`,
    { headers: { Authorization: `Bearer ${token}` } }
  );
  return response.json();
}

Required Scopes

EndpointRequired Scope
GET /productsproducts:read
GET /products/:idproducts:read

Built for game developers, by game developers.