PleasureStock API

RESTful API Documentation v1.0

Back to PleasureStock

Overview

The PleasureStock API provides programmatic access to our comprehensive adult products database, enabling seamless integration of inventory management and smart reordering capabilities into your systems.

Base URL: https://dev.pleasurestock.com/api/v1

Key Features

  • Access to complete product catalog with adult toys and accessories
  • Submit sales data for inventory tracking
  • Get AI-powered smart reordering recommendations
  • RESTful design with JSON responses
  • Secure API key authentication

AI/LLM Quick Reference

API Structure Summary

Base URL: https://dev.pleasurestock.com/api/v1
Auth: Header "X-API-Key: YOUR_API_KEY"
Format: JSON request/response
Rate Limit: 1000 req/hour

Key Endpoints:
- GET  /products        → List products (paginated)
- GET  /products/{id}   → Get single product
- POST /sales          → Submit sales data
- GET  /smart-reordering → Get AI recommendations

Common Request Pattern

# Example: Get products with filters
curl -H "X-API-Key: YOUR_KEY" \
  "https://dev.pleasurestock.com/api/v1/products?category=vibrators&limit=10"

# Response structure:
{
  "success": true,
  "data": {
    "products": [...],
    "pagination": {...}
  },
  "meta": {
    "timestamp": "2025-07-30T12:00:00Z",
    "version": "1.0"
  }
}

For AI Agents: This API follows RESTful conventions. All timestamps are ISO 8601. Product IDs use format "pl_XXXXXXXXXX". Prices are in USD cents (multiply by 100).

Authentication

All API requests require authentication using an API key. Include your API key in the request header:

curl -H "X-API-Key: YOUR_API_KEY" \
  https://dev.pleasurestock.com/api/v1/products

Important: Keep your API key secure and never expose it in client-side code.

Getting an API Key

  1. Log in to your PleasureStock account as a company manager
  2. Navigate to Settings → API Keys
  3. Click "Generate New Key"
  4. Give your key a descriptive name
  5. Copy and securely store your API key

API Endpoints

Submit Sales Data

POST /api/v1/sales

Submit sales data for products to track inventory and enable smart reordering.

Request Body

{
  "sales": [
    {
      "internal_id": "pl_1234567890",
      "date": "2025-01-15",
      "quantity": 5,
      "stock_on_hand": 20  // optional
    }
  ]
}

Response

{
  "success": true,
  "message": "Sales data processed successfully",
  "processed": 1,
  "errors": []
}

Get Smart Reordering Recommendations

GET /api/v1/smart-reordering

Get AI-powered recommendations for product reordering based on sales history.

Query Parameters

Parameter Type Description
page integer Page number (default: 1)
limit integer Items per page (default: 20, max: 100)

Response

{
  "recommendations": [
    {
      "product": {
        "id": "123e4567-e89b-12d3-a456-426614174000",
        "internal_id": "pl_1234567890",
        "name": "Premium Vibrator",
        "sku": "VIB-001"
      },
      "recommended_quantity": 45,
      "current_stock": 10,
      "average_daily_sales": 1.5,
      "forecast_accuracy": 92.3
    }
  ],
  "pagination": {
    "total": 25,
    "page": 1,
    "pages": 2,
    "limit": 20
  }
}

Get Products Catalog

GET /api/v1/products

Retrieve the product catalog with filtering and pagination options.

Query Parameters

Parameter Type Description
search string Search by name, SKU, or internal ID
category string Filter by category
page integer Page number (default: 1)
limit integer Items per page (default: 20, max: 100)

Response

{
  "products": [
    {
      "id": "123e4567-e89b-12d3-a456-426614174000",
      "internal_id": "pl_1234567890",
      "name": "Premium Vibrator",
      "sku": "VIB-001",
      "category": "Vibrators",
      "price": 89.99,
      "currency": "EUR",
      "in_stock": true,
      "images": [
        "https://dev.pleasurestock.com/uploads/products/vib-001-1.jpg"
      ]
    }
  ],
  "pagination": {
    "total": 150,
    "page": 1,
    "pages": 8,
    "limit": 20
  }
}

Rate Limits

To ensure fair usage and system stability, the API enforces the following rate limits:

Endpoint Limit Window
All endpoints 1000 requests Per hour
POST /sales 100 requests Per hour

Rate limit information is included in response headers:

  • X-RateLimit-Limit - Request limit per hour
  • X-RateLimit-Remaining - Remaining requests
  • X-RateLimit-Reset - Time when limit resets

Error Handling

The API uses standard HTTP status codes to indicate success or failure of requests.

Status Code Description
200 OK Request successful
400 Bad Request Invalid request parameters
401 Unauthorized Missing or invalid API key
404 Not Found Resource not found
429 Too Many Requests Rate limit exceeded
500 Internal Server Error Server error

Error Response Format

{
  "error": {
    "code": "INVALID_REQUEST",
    "message": "The internal_id field is required",
    "details": {
      "field": "internal_id",
      "value": null
    }
  }
}

Code Examples

Python Example

import requests
import json

# Your API key
api_key = "YOUR_API_KEY"
base_url = "https://dev.pleasurestock.com/api/v1"

# Headers
headers = {
    "X-API-Key": api_key,
    "Content-Type": "application/json"
}

# Submit sales data
sales_data = {
    "sales": [
        {
            "internal_id": "pl_1234567890",
            "date": "2025-01-15",
            "quantity": 5,
            "stock_on_hand": 20
        }
    ]
}

response = requests.post(
    f"{base_url}/sales",
    headers=headers,
    json=sales_data
)

print(response.json())

# Get smart reordering recommendations
response = requests.get(
    f"{base_url}/smart-reordering",
    headers=headers,
    params={"limit": 10}
)

recommendations = response.json()
for rec in recommendations["recommendations"]:
    print(f"Product: {rec['product']['name']}")
    print(f"Recommended quantity: {rec['recommended_quantity']}")
    print("---")

Node.js Example

const axios = require('axios');

const API_KEY = 'YOUR_API_KEY';
const BASE_URL = 'https://dev.pleasurestock.com/api/v1';

// Configure axios instance
const api = axios.create({
  baseURL: BASE_URL,
  headers: {
    'X-API-Key': API_KEY,
    'Content-Type': 'application/json'
  }
});

// Submit sales data
async function submitSales() {
  try {
    const salesData = {
      sales: [
        {
          internal_id: 'pl_1234567890',
          date: '2025-01-15',
          quantity: 5,
          stock_on_hand: 20
        }
      ]
    };
    
    const response = await api.post('/sales', salesData);
    console.log('Sales submitted:', response.data);
  } catch (error) {
    console.error('Error:', error.response.data);
  }
}

// Get recommendations
async function getRecommendations() {
  try {
    const response = await api.get('/smart-reordering', {
      params: { limit: 10 }
    });
    
    response.data.recommendations.forEach(rec => {
      console.log(`Product: ${rec.product.name}`);
      console.log(`Recommended: ${rec.recommended_quantity}`);
      console.log('---');
    });
  } catch (error) {
    console.error('Error:', error.response.data);
  }
}

// Run examples
submitSales();
getRecommendations();

cURL Example

# Submit sales data
curl -X POST https://dev.pleasurestock.com/api/v1/sales \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "sales": [{
      "internal_id": "pl_1234567890",
      "date": "2025-01-15",
      "quantity": 5,
      "stock_on_hand": 20
    }]
  }'

# Get smart reordering recommendations
curl -X GET "https://dev.pleasurestock.com/api/v1/smart-reordering?limit=10" \
  -H "X-API-Key: YOUR_API_KEY"

# Search products
curl -X GET "https://dev.pleasurestock.com/api/v1/products?search=vibrator&limit=5" \
  -H "X-API-Key: YOUR_API_KEY"

Support

Need help with the API? We're here to assist you.

Technical Support

For API-related questions and issues

api@pleasurestock.com

Account Support

For account and billing questions

support@pleasurestock.com