### List Products (Node.js) Source: https://chariow.dev/api-reference/products/list-products Fetch a list of products using Node.js. This example demonstrates how to make a GET request and parse the JSON response. Remember to include your API key in the Authorization header. ```javascript const response = await fetch('https://api.chariow.com/v1/products?per_page=20&type=course', { headers: { 'Authorization': 'Bearer sk_live_YOUR_API_KEY' } }); const { data } = await response.json(); console.log(data); ``` -------------------------------- ### Example cURL Request Source: https://chariow.dev/en/introduction/authentication Make a GET request to the store endpoint with the required Authorization header. ```bash curl -X GET "https://api.chariow.com/v1/store" \ -H "Authorization: Bearer YOUR_API_KEY" ``` -------------------------------- ### List Products (Python) Source: https://chariow.dev/api-reference/products/list-products Make a GET request to list products using Python's requests library. This example includes setting query parameters and the Authorization header. Ensure you use your actual API key. ```python import requests response = requests.get( 'https://api.chariow.com/v1/products', params={'per_page': 20, 'type': 'course'}, headers={'Authorization': 'Bearer sk_live_YOUR_API_KEY'} ) data = response.json() ``` -------------------------------- ### Get License by License Key (Node.js) Source: https://chariow.dev/api-reference/licenses/get-license This Node.js example demonstrates how to fetch license information using the Fetch API. Ensure you replace the placeholder API key and license key. ```javascript const response = await fetch('https://api.chariow.com/v1/licenses/ABC-123-XYZ-789', { headers: { 'Authorization': 'Bearer YOUR_API_KEY' } }); const data = await response.json(); ``` -------------------------------- ### Get Store Information (Python) Source: https://chariow.dev/api-reference/store/get-store Make a GET request to the store endpoint using Python's `requests` library. This example includes setting the necessary headers for authentication. ```python import requests api_key = 'sk_live_abc123xyz...' response = requests.get( 'https://api.chariow.com/v1/store', headers={ 'Authorization': f'Bearer {api_key}', 'Content-Type': 'application/json' } ) data = response.json() print(data) ``` -------------------------------- ### List Sales (Python) Source: https://chariow.dev/api-reference/sales/list-sales Make a GET request to the sales endpoint using Python's requests library. This example includes setting query parameters and authorization headers. ```python import requests response = requests.get( 'https://api.chariow.com/v1/sales', params={ 'status': 'completed', 'per_page': 20, 'start_date': '2025-01-01' }, headers={'Authorization': 'Bearer sk_live_your_api_key'} ) data = response.json() sales = data['data'] ``` -------------------------------- ### Example Python Request Source: https://chariow.dev/en/introduction/authentication Send a GET request to the store endpoint using Python's requests library with the Authorization header. ```python import requests headers = { 'Authorization': 'Bearer YOUR_API_KEY' } response = requests.get('https://api.chariow.com/v1/store', headers=headers) ``` -------------------------------- ### Successful API Response Example Source: https://chariow.dev/en/introduction/overview An example of a successful API response, including product details like ID, name, and price. ```json { "message": "success", "data": { "id": "prd_abc123", "name": "Premium Course", "price": { "value": 99, "formatted": "$99.00", "short": "99", "currency": "USD" } }, "errors": [] } ``` -------------------------------- ### Example PHP Request Source: https://chariow.dev/en/introduction/authentication Set up a cURL request in PHP to the store endpoint, including the Authorization header. ```php $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://api.chariow.com/v1/store'); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Authorization: Bearer YOUR_API_KEY' ]); ``` -------------------------------- ### List Active Discounts (Python) Source: https://chariow.dev/api-reference/discounts/list-discounts Employ the requests library to perform a GET request to the discounts endpoint. Pass the API key in the headers and specify query parameters for status and pagination. This example retrieves active discounts, 20 per page. ```python import requests response = requests.get( 'https://api.chariow.com/v1/discounts', params={'status': 'active', 'per_page': 20}, headers={'Authorization': 'Bearer sk_live_your_api_key'} ) data = response.json()['data'] ``` -------------------------------- ### Affiliate Invitation Response Example Source: https://chariow.dev/en/guides/affiliates Example JSON response when sending affiliate invitations, showing successful and pending invitations. ```json { "message": "2 invitations sent successfully", "data": [ { "id": "affinv_abc123xyz", "email": "john@example.com", "status": "pending", "expires_at": "2026-02-10T10:30:00+00:00", "invited_by": { "id": "tm_abc123", "name": "Store Owner" }, "accepted_at": null, "created_at": "2026-01-11T10:30:00+00:00" }, { "id": "affinv_def456uvw", "email": "jane@example.com", "status": "pending", "expires_at": "2026-02-10T10:30:00+00:00", "invited_by": { "id": "tm_abc123", "name": "Store Owner" }, "accepted_at": null, "created_at": "2026-01-11T10:30:00+00:00" } ], "errors": [] } ``` -------------------------------- ### Not Found Response (404) Source: https://chariow.dev/api-reference/products/get-product This example shows the response when a requested product cannot be found. The data field will be empty. ```json { "message": "Product not found", "data": [], "errors": [] } ``` -------------------------------- ### Example JavaScript Request Source: https://chariow.dev/en/introduction/authentication Fetch data from the store endpoint using JavaScript, including the Authorization header. ```javascript const response = await fetch('https://api.chariow.com/v1/store', { headers: { 'Authorization': 'Bearer YOUR_API_KEY' } }); ``` -------------------------------- ### Get Affiliate by ID Source: https://chariow.dev/api-reference/affiliates/get-affiliate This example shows how to retrieve affiliate information using their unique identifier. ```APIDOC ## GET /v1/affiliates/{affiliateId} ### Description Retrieves the details of a specific affiliate. ### Method GET ### Endpoint /v1/affiliates/{affiliateId} ### Parameters #### Path Parameters - **affiliateId** (string) - Required - The unique identifier of the affiliate. ### Request Example ```json { "example": "" } ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message. - **data** (object) - Contains the affiliate details. - **id** (string) - Affiliate ID. - **status** (string) - Affiliate status (e.g., 'active'). - **source** (object) - Information about how the affiliate joined. - **label** (string) - Display label for the source. - **description** (string) - Detailed description of the source. - **value** (string) - Internal value for the source. - **total_visits** (integer) - Total number of visits attributed to the affiliate. - **total_sales** (integer) - Total number of sales generated by the affiliate. - **total_earnings** (object) - Total earnings generated. - **value** (integer) - Numerical value of earnings. - **formatted** (string) - Formatted earnings string (e.g., '$1,250.00'). - **short** (string) - Shortened earnings representation (e.g., '1.25K'). - **currency** (string) - Currency code (e.g., 'USD'). - **first_visit_at** (string) - Timestamp of the first visit. - **last_visit_at** (string) - Timestamp of the last visit. - **suspended_at** (string|null) - Timestamp when the affiliate was suspended. - **suspended_reason** (string|null) - Reason for suspension. - **account** (object) - Details of the affiliate's account. - **id** (string) - Account ID. - **pseudo** (string) - Account pseudo-name. - **country** (object) - Affiliate's country. - **code** (string) - Country code (e.g., 'US'). - **name** (string) - Country name (e.g., 'United States'). - **status** (string) - Account status. - **user** (object) - User associated with the account. - **name** (string) - User's name. - **email** (string) - User's email address. - **created_at** (string) - Timestamp of account creation. - **created_at** (string) - Timestamp of affiliate creation. - **updated_at** (string) - Timestamp of last affiliate update. - **errors** (array) - List of errors, if any. #### Response Example (200) ```json { "message": "Affiliate retrieved successfully", "data": { "id": "saff_xyz789abc", "status": "active", "source": { "label": "Invitation", "description": "Joined via invitation", "value": "invitation" }, "total_visits": 150, "total_sales": 25, "total_earnings": { "value": 1250, "formatted": "$1,250.00", "short": "1.25K", "currency": "USD" }, "first_visit_at": "2025-01-16T09:00:00+00:00", "last_visit_at": "2025-01-25T14:30:00+00:00", "suspended_at": null, "suspended_reason": null, "account": { "id": "aff_abc123def", "pseudo": "creative_studio", "country": { "code": "US", "name": "United States" }, "status": "active", "user": { "name": "John Doe", "email": "john@example.com" }, "created_at": "2025-01-15T10:30:00+00:00" }, "created_at": "2025-01-15T10:30:00+00:00", "updated_at": "2025-01-25T14:30:00+00:00" }, "errors": [] } ``` #### Response Example (404) ```json { "message": "Affiliate not found", "data": [], "errors": [] } ``` #### Response Example (401) ```json { "message": "Unauthenticated", "data": [], "errors": [] } ``` ``` -------------------------------- ### Initialize Checkout Source: https://chariow.dev/api-reference/checkout/init-checkout Use this endpoint to start a checkout. You need to provide product information, customer details, and optionally, discount codes, campaign IDs, custom fields, payment currency, redirect URLs, custom metadata, and shipping address if required. ```APIDOC ## POST /checkout/init ### Description Initiates a checkout process for a given product and customer. ### Method POST ### Endpoint /checkout/init ### Authentication This endpoint requires API key authentication via Bearer token: ``` Authorization: Bearer sk_live_your_api_key ``` ### Parameters #### Request Body - **product_id** (string) - Required - The product public ID or slug to purchase. Example: `prd_abc123xyz` or `premium-course` - **email** (string) - Required - Customer email address. Must be a valid email (max 255 characters). Example: `customer@example.com` - **first_name** (string) - Required - Customer first name (max 50 characters). Example: `John` - **last_name** (string) - Required - Customer last name (max 50 characters). Example: `Doe` - **phone** (object) - Required - Customer phone details - **phone.number** (string) - Required - Phone number (numeric only). Example: `1234567890` - **phone.country_code** (string) - Required - ISO country code (max 10 characters). Example: `US`, `FR`, `GB` - **discount_code** (string) - Optional - Discount code to apply (max 100 characters). Example: `SAVE20` - **campaign_id** (string) - Optional - Campaign public ID or tracking code for analytics. Example: `camp_xyz789` - **custom_fields** (object) - Optional - Custom field values for the product (key-value pairs). Must match the product's configured custom fields. - **payment_currency** (string) - Optional - Currency code for payment (ISO 4217). Defaults to store currency if not provided. Example: `USD`, `EUR`, `GBP` - **redirect_url** (string) - Optional - Custom URL to redirect customers after payment completion (max 2048 characters). When provided, customers will be redirected to this URL instead of the default Chariow post-purchase page. Must be a valid active URL. Example: `https://yoursite.com/thank-you` - **custom_metadata** (object) - Optional - Custom key-value metadata to store with the sale. Maximum 10 keys allowed, each value limited to 255 characters. This metadata is included in Pulse webhook payloads, making it useful for linking sales with external systems. Example: `{"order_ref": "ORD-123", "source": "landing_page"}` ### Shipping Address Fields *The following fields are **required** when the product has "Require shipping address" enabled. If shipping is not required for the product, these fields are ignored.* - **address** (string) - Optional - Customer street address for shipping (max 255 characters). Example: `123 Main Street` - **city** (string) - Optional - Customer city for shipping (max 100 characters). Example: `New York` - **state** (string) - Optional - Customer state or region for shipping (max 100 characters). Example: `NY` - **country** (string) - Optional - Customer country for shipping (ISO 3166-1 alpha-2 code, max 2 characters). Example: `US` - **zip** (string) - Optional - Customer postal/ZIP code for shipping (max 20 characters). Example: `10001` ### Request Example ```json { "product_id": "premium-course", "email": "customer@example.com", "first_name": "John", "last_name": "Doe", "phone": { "number": "1234567890", "country_code": "US" }, "discount_code": "SAVE20", "campaign_id": "camp_xyz789", "custom_fields": { "field_name": "field_value" }, "payment_currency": "USD", "redirect_url": "https://yoursite.com/thank-you", "custom_metadata": { "order_ref": "ORD-123", "source": "landing_page" }, "address": "123 Main Street", "city": "New York", "state": "NY", "country": "US", "zip": "10001" } ``` ### Response #### Success Response (200) *Response details not provided in the source text.* #### Response Example *Response details not provided in the source text.* ``` -------------------------------- ### List Customers with Python Source: https://chariow.dev/api-reference/customers/list-customers Use the `requests` library in Python to list customers. This example shows how to pass query parameters and headers for filtering and authentication. ```python import requests response = requests.get( 'https://api.chariow.com/v1/customers', params={'per_page': 20, 'search': 'john'}, headers={'Authorization': 'Bearer sk_live_your_api_key'} ) data = response.json()['data'] ``` -------------------------------- ### Get Store Information (JavaScript) Source: https://chariow.dev/api-reference/store/get-store Fetch store data using JavaScript's `fetch` API. This example demonstrates setting the Authorization and Content-Type headers. ```javascript const response = await fetch('https://api.chariow.com/v1/store', { method: 'GET', headers: { 'Authorization': 'Bearer sk_live_abc123xyz...', 'Content-Type': 'application/json' } }); const data = await response.json(); console.log(data); ``` -------------------------------- ### Activate License with Node.js Source: https://chariow.dev/api-reference/licenses/activate-license This Node.js example demonstrates how to activate a license using the fetch API. Ensure you include the Authorization header with your API key and the device identifier in the JSON payload. ```javascript const response = await fetch( 'https://api.chariow.com/v1/licenses/ABC-123-XYZ-789/activate', { method: 'POST', headers: { 'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json' }, body: JSON.stringify({ device_identifier: '00:1B:44:11:3A:B7' }) } ); const data = await response.json(); ``` -------------------------------- ### List Sales (JavaScript) Source: https://chariow.dev/api-reference/sales/list-sales Fetch sales data using JavaScript's fetch API. This example demonstrates how to make a GET request and parse the JSON response. ```javascript const response = await fetch('https://api.chariow.com/v1/sales?status=completed&per_page=20&start_date=2025-01-01', { headers: { 'Authorization': 'Bearer sk_live_your_api_key' } }); const result = await response.json(); console.log(result.data); // Array of sales console.log(result.pagination); // Pagination info ``` -------------------------------- ### Get Product by Slug (cURL) Source: https://chariow.dev/api-reference/products/get-product Use this command to fetch a product's details using its slug. Replace 'premium-course' with the actual product slug and 'YOUR_API_KEY' with your valid API key. ```bash curl -X GET "https://api.chariow.com/v1/products/premium-course" \ -H "Authorization: Bearer sk_live_YOUR_API_KEY" ``` -------------------------------- ### List Licenses (Node.js) Source: https://chariow.dev/api-reference/licenses/list-licenses This Node.js example demonstrates how to fetch licenses using the 'fetch' API. Ensure your API key is correctly formatted in the Authorization header. ```javascript const response = await fetch('https://api.chariow.com/v1/licenses?status=active&per_page=20', { headers: { 'Authorization': 'Bearer YOUR_API_KEY' } }); const data = await response.json(); ``` -------------------------------- ### Get a Specific Pulse (Node.js) Source: https://chariow.dev/api-reference/pulses/get-pulse This Node.js example demonstrates how to fetch pulse details using the Fetch API. It includes setting the Authorization header with your API key. ```javascript const response = await fetch('https://api.chariow.com/v1/pulses/pulse_abc123xyz', { headers: { 'Authorization': 'Bearer YOUR_API_KEY' } }); const data = await response.json(); ``` -------------------------------- ### Initialize Checkout with PHP Source: https://chariow.dev/api-reference/checkout/init-checkout This PHP example shows how to initialize a checkout using cURL. It sets up the POST request with necessary headers and JSON payload, then processes the response to redirect to payment or confirm completion. ```php $ch = curl_init('https://api.chariow.com/v1/checkout'); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Authorization: Bearer sk_live_your_api_key', 'Content-Type: application/json' ]); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([ 'product_id' => 'prd_abc123xyz', 'email' => 'customer@example.com', 'first_name' => 'John', 'last_name' => 'Doe', 'phone' => [ 'number' => '1234567890', 'country_code' => 'US' ], 'discount_code' => 'SAVE20', 'redirect_url' => 'https://yoursite.com/thank-you', 'custom_metadata' => [ 'order_ref' => 'ORD-123', 'source' => 'landing_page' ] ])); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); $data = json_decode($response, true); if ($data['data']['step'] === 'payment') { // Redirect to payment URL header('Location: ' . $data['data']['payment']['checkout_url']); } elseif ($data['data']['step'] === 'completed') { // Free product - sale completed echo 'Purchase completed: ' . $data['data']['purchase']['id']; } ``` -------------------------------- ### Configure Chariow Node via Docker Source: https://chariow.dev/en/n8n/setup Set the N8N_CUSTOM_EXTENSIONS environment variable in your docker-compose.yml file to install the Chariow node when the container starts. Restart the container after updating the configuration. ```yaml # docker-compose.yml services: n8n: image: n8nio/n8n environment: - N8N_CUSTOM_EXTENSIONS=@chariow/n8n-nodes-chariow # ... your other config ``` -------------------------------- ### Initialize Checkout with cURL Source: https://chariow.dev/api-reference/checkout/init-checkout Use this cURL command to make a POST request to the checkout endpoint. Ensure you replace 'sk_live_your_api_key' with your actual API key and provide the correct product ID and customer details. ```bash curl -X POST "https://api.chariow.com/v1/checkout" \ -H "Authorization: Bearer sk_live_your_api_key" \ -H "Content-Type: application/json" \ -d '{ \ "product_id": "prd_abc123xyz", \ "email": "customer@example.com", \ "first_name": "John", \ "last_name": "Doe", \ "phone": { \ "number": "1234567890", \ "country_code": "US" \ }, \ "discount_code": "SAVE20", \ "redirect_url": "https://yoursite.com/thank-you", \ "custom_metadata": { \ "order_ref": "ORD-123", \ "source": "landing_page" \ }' \ }' ``` -------------------------------- ### List All Licenses Source: https://chariow.dev/en/guides/licenses Retrieve all issued licenses for your store. Ensure you replace 'sk_live_your_api_key' with your actual API key. ```bash curl -X GET "https://api.chariow.com/v1/licenses" \ -H "Authorization: Bearer sk_live_your_api_key" ``` ```javascript const response = await fetch('https://api.chariow.com/v1/licenses', { headers: { 'Authorization': 'Bearer sk_live_your_api_key' } }); const { data } = await response.json(); ``` -------------------------------- ### Get Product by ID (PHP) Source: https://chariow.dev/api-reference/products/get-product Retrieve product details by ID using PHP. This example initializes a cURL session, sets the authorization header, and decodes the JSON response. Replace 'prd_abc123' and 'YOUR_API_KEY' accordingly. ```php $ch = curl_init('https://api.chariow.com/v1/products/prd_abc123'); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Authorization: Bearer sk_live_YOUR_API_KEY' ]); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); $data = json_decode($response, true); ``` -------------------------------- ### List Active Discounts (JavaScript) Source: https://chariow.dev/api-reference/discounts/list-discounts Use the fetch API to make a GET request to the discounts endpoint. Include your API key in the Authorization header. This example retrieves active discounts with 20 items per page. ```javascript const response = await fetch('https://api.chariow.com/v1/discounts?status=active&per_page=20', { headers: { 'Authorization': 'Bearer sk_live_your_api_key' } }); const { message, data } = await response.json(); ``` -------------------------------- ### Sync Products and Process Checkout with Chariow API (PHP) Source: https://chariow.dev/en/guides/use-cases Example demonstrates syncing products from Chariow and processing checkout by creating Chariow checkout sessions. Requires WordPress HTTP functions and Chariow API key. ```php [ 'Authorization' => 'Bearer ' . get_option('chariow_api_key') ] ]); $products = json_decode(wp_remote_retrieve_body($response), true); foreach ($products['data'] as $product) { update_or_create_wc_product($product); } } // Process checkout for Chariow product function process_chariow_checkout($order_id) { $order = wc_get_order($order_id); foreach ($order->get_items() as $item) { $chariow_product_id = get_post_meta($item->get_product_id(), '_chariow_product_id', true); if ($chariow_product_id) { $response = wp_remote_post('https://api.chariow.com/v1/checkout', [ 'headers' => [ 'Authorization' => 'Bearer ' . get_option('chariow_api_key'), 'Content-Type' => 'application/json' ], 'body' => json_encode([ 'product_id' => $chariow_product_id, 'email' => $order->get_billing_email(), 'first_name' => $order->get_billing_first_name(), 'last_name' => $order->get_billing_last_name(), 'phone' => [ 'number' => preg_replace('/[^0-9]/', '', $order->get_billing_phone()), 'country_code' => $order->get_billing_country() ] ]) ]); $result = json_decode(wp_remote_retrieve_body($response), true); update_post_meta($order_id, '_chariow_sale_id', $result['data']['purchase']['id']); } } } ``` -------------------------------- ### Success Response (200) for a Course Source: https://chariow.dev/api-reference/products/get-product This example shows a successful response when retrieving a course product. It includes all relevant product details. ```json { "message": "success", "data": { "id": "prd_abc123", "name": "Premium Web Development Course", "slug": "premium-web-dev-course", "description": "A comprehensive course covering advanced web development techniques and best practices.", "type": "course", "category": { "value": "education_and_learning", "label": "Education and Learning" }, "status": "published", "is_free": false, "pictures": { "thumbnail": "https://cdn.chariow.com/products/abc123/thumb.jpg", "cover": "https://cdn.chariow.com/products/abc123/cover.jpg" }, "pricing": { "type": "one_time", "current_price": { "value": 99.00, "formatted": "$99.00", "short": "99", "currency": "USD" }, "price": { "value": 149.00, "formatted": "$149.00", "short": "149", "currency": "USD" }, "sale_price": { "value": 99.00, "formatted": "$99.00", "short": "99", "currency": "USD" }, "min_price": { "value": 0, "formatted": "$0.00", "short": "0", "currency": "USD" }, "suggested_price": { "value": 0, "formatted": "$0.00", "short": "0", "currency": "USD" }, "price_off": "34%" }, "quantity": null, "settings": { "is_requires_shipping_address": false }, "rating": { "average": 4.8, "count": 245 }, "on_sale_until": "2025-02-28T23:59:59Z", "sales_count": 1250, "seo": null, "custom_cta_text": { "value": null, "label": null }, "fields": null, "bundle": null }, "errors": [] } ``` -------------------------------- ### List Customers with JavaScript Source: https://chariow.dev/api-reference/customers/list-customers Fetch a list of customers using JavaScript's `fetch` API. This example demonstrates how to set query parameters and the Authorization header for the request. ```javascript const response = await fetch('https://api.chariow.com/v1/customers?per_page=20&search=john', { headers: { 'Authorization': 'Bearer sk_live_your_api_key' } }); const { data } = await response.json(); ``` -------------------------------- ### Install Chariow Node via npm Source: https://chariow.dev/en/n8n/setup Use this command to install the Chariow node package in your n8n user directory. Restart n8n after installation. ```bash cd ~/.n8n && npm install @chariow/n8n-nodes-chariow ``` -------------------------------- ### List All Discounts Source: https://chariow.dev/en/guides/discounts Retrieve all discounts for your store. Requires authentication. ```bash curl -X GET "https://api.chariow.com/v1/discounts" \ -H "Authorization: Bearer sk_live_your_api_key" ``` ```javascript const response = await fetch('https://api.chariow.com/v1/discounts', { headers: { 'Authorization': 'Bearer sk_live_your_api_key' } }); const { data } = await response.json(); ``` ```python import requests response = requests.get( 'https://api.chariow.com/v1/discounts', headers={'Authorization': 'Bearer sk_live_your_api_key'} ) discounts = response.json()['data'] ``` -------------------------------- ### Example Customer Response Source: https://chariow.dev/en/guides/customers This is an example of the JSON response structure when retrieving customer data. ```json { "data": [ { "id": "cus_abc123xyz", "name": "John Doe", "first_name": "John", "last_name": "Doe", "email": "john@example.com", "avatar_url": "https://cdn.chariow.com/avatars/abc123.jpg", "phone": { "number": "+1 234 567 890", "country": { "name": "United States", "code": "US", "alpha_3_code": "USA", "dial_code": "+1", "currency": "USD", "flag": "🇺🇸" } }, "store": { "id": "str_xyz789", "name": "My Digital Store", "logo_url": "https://cdn.chariow.com/stores/xyz789/logo.png", "url": "https://mystore.chariow.link" }, "created_at": "2025-01-15T10:30:00+00:00", "updated_at": "2025-01-20T14:45:00+00:00" } ], "pagination": { "next_cursor": "eyJpZCI6NTB9", "prev_cursor": null, "has_more": true } } ``` -------------------------------- ### Get a Single Sale Source: https://chariow.dev/en/guides/sales Retrieve a specific sale by its public ID using a GET request. ```APIDOC ## GET /v1/sales/{sale_id} ### Description Retrieves a specific sale by its public ID. ### Method GET ### Endpoint `/v1/sales/{sale_id}` ### Parameters #### Path Parameters - **sale_id** (string) - Required - The public ID of the sale to retrieve. ### Request Example ```bash curl -X GET "https://api.chariow.com/v1/sales/sal_abc123" \ -H "Authorization: Bearer sk_live_your_api_key" ``` ### Response #### Success Response (200) - **id** (string) - The unique identifier for the sale. - **customer_id** (string) - The identifier for the customer who made the purchase. - **product_id** (string) - The identifier for the product purchased. - **amount** (number) - The total amount of the sale. - **currency** (string) - The currency of the sale (e.g., "USD"). - **status** (string) - The status of the sale (e.g., "completed", "pending"). - **created_at** (string) - The timestamp when the sale was created. - **fulfillment** (object) - Contains fulfillment details if applicable. #### Response Example ```json { "id": "sal_abc123", "customer_id": "cus_xyz789", "product_id": "prd_def456", "amount": 49.99, "currency": "USD", "status": "completed", "created_at": "2023-10-27T10:00:00+00:00", "fulfillment": { "files": [ { "id": "fil_abc123", "name": "course-materials.zip", "size": 15728640, "type": "application/zip", "download_url": "https://cdn.chariow.com/downloads/ப்புகளை...", "expires_at": "2025-01-20T10:30:00+00:00" } ], "licences": [ { "id": "lic_def456", "licence_key": "ABC-123-XYZ-789", "status": "active", "activations": 2, "max_activations": 5, "expires_at": null } ], "instructions": "Thank you for your purchase! Here's how to get started with your course materials..." } } ``` ``` ```APIDOC ## JavaScript Example ```javascript const response = await fetch('https://api.chariow.com/v1/sales/sal_abc123', { headers: { 'Authorization': 'Bearer sk_live_your_api_key' } }); const result = await response.json(); console.log(result); ``` ``` -------------------------------- ### Send Affiliate Invitations using Node.js Source: https://chariow.dev/api-reference/affiliates/send-invitations This Node.js example demonstrates how to send affiliate invitations using the fetch API. It includes setting the necessary headers and request body. ```javascript const response = await fetch('https://api.chariow.com/v1/affiliates/invitations', { method: 'POST', headers: { 'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json' }, body: JSON.stringify({ emails: ['john@example.com', 'jane@example.com'] }) }); const data = await response.json(); ``` -------------------------------- ### API Error Response Example Source: https://chariow.dev/en/introduction/overview An example of an API error response, detailing validation failures with specific field messages. ```json { "message": "Validation failed", "data": [], "errors": { "email": ["The email field is required."], "product_id": ["The selected product is invalid."] } } ``` -------------------------------- ### Electron App License Manager Implementation Source: https://chariow.dev/en/guides/saas-license-integration This guide outlines the structure for an Electron app's license system. It covers storing and validating licenses in the main process, exposing APIs via preload scripts, and managing the UI in the renderer. Device identification and offline handling are also key components. ```text Create a license system for an Electron desktop app: 1. Main process license manager: - Store license in electron-store (encrypted) - Validate on app launch - Re-validate every 24 hours - Send validation status to renderer via IPC 2. Preload script: - Expose safe license APIs to renderer - licenseAPI.validate(key) - licenseAPI.getStatus() - licenseAPI.activate() 3. Renderer license UI: - License entry screen on first launch - License status in settings - "Manage Activations" option 4. Device identifier: - Use machine-id package for consistent device ID - Pass to Chariow activation endpoint 5. Offline handling: - Cache validation for 7 days - Show "Offline Mode" indicator - Block app after cache expires ``` -------------------------------- ### Get Store Information (cURL) Source: https://chariow.dev/api-reference/store/get-store Use this cURL command to make a GET request to the store endpoint. Ensure you include your API key in the Authorization header. ```bash curl -X GET "https://api.chariow.com/v1/store" \ -H "Authorization: Bearer sk_live_abc123xyz..." ``` -------------------------------- ### Initiate Checkout Session Source: https://chariow.dev/en/guides/checkout Use this endpoint to create a new checkout session. Provide customer and product details to generate a checkout link. ```bash curl -X POST "https://api.chariow.com/v1/checkout" \ -H "Authorization: Bearer sk_live_your_api_key" \ -H "Content-Type: application/json" \ -d '{ "product_id": "prd_abc123", "email": "customer@example.com", "first_name": "John", "last_name": "Doe", "phone": { "number": "1234567890", "country_code": "US" }, "discount_code": "SAVE20" }' ``` ```javascript const response = await fetch('https://api.chariow.com/v1/checkout', { method: 'POST', headers: { 'Authorization': 'Bearer sk_live_your_api_key', 'Content-Type': 'application/json' }, body: JSON.stringify({ product_id: 'prd_abc123', email: 'customer@example.com', first_name: 'John', last_name: 'Doe', phone: { number: '1234567890', country_code: 'US' }, discount_code: 'SAVE20' }) }); const data = await response.json(); ``` ```python import requests response = requests.post( 'https://api.chariow.com/v1/checkout', headers={ 'Authorization': 'Bearer sk_live_your_api_key', 'Content-Type': 'application/json' }, json={ 'product_id': 'prd_abc123', 'email': 'customer@example.com', 'first_name': 'John', 'last_name': 'Doe', 'phone': { 'number': '1234567890', 'country_code': 'US' }, 'discount_code': 'SAVE20' } ) ``` -------------------------------- ### Get a Specific Pulse (cURL) Source: https://chariow.dev/api-reference/pulses/get-pulse Use this cURL command to make a GET request to retrieve a specific pulse by its ID. Ensure you replace YOUR_API_KEY with your actual API key. ```bash curl -X GET "https://api.chariow.com/v1/pulses/pulse_abc123xyz" \ -H "Authorization: Bearer YOUR_API_KEY" ``` -------------------------------- ### Success Response (200) for a Bundle Product Source: https://chariow.dev/api-reference/products/get-product This example demonstrates a successful response when retrieving a bundle product. It includes bundle-specific pricing and savings information. ```json { "message": "success", "data": { "id": "prd_bundle789", "name": "Complete Developer Bundle", "slug": "developer-bundle", "description": "Everything you need to become a professional developer.", "type": "bundle", "category": { "value": "technology", "label": "Technology" }, "status": "published", "is_free": false, "pictures": { "thumbnail": "https://cdn.chariow.com/products/bundle789/thumb.jpg", "cover": null }, "pricing": { "type": "one_time", "current_price": { "value": 199.00, "formatted": "$199.00", "short": "199", "currency": "USD" }, "price": { "value": 199.00, "formatted": "$199.00", "short": "199", "currency": "USD" }, "sale_price": null, "min_price": { "value": 0, "formatted": "$0.00", "short": "0", "currency": "USD" }, "suggested_price": { "value": 0, "formatted": "$0.00", "short": "0", "currency": "USD" }, "price_off": null }, "quantity": null, "settings": { "is_requires_shipping_address": false }, "rating": { "average": 4.9, "count": 89 }, "on_sale_until": null, "sales_count": 543, "seo": null, "custom_cta_text": { "value": null, "label": null }, "fields": null, "bundle": { "value": { "value": 297.00, "formatted": "$297.00", "short": "297", "currency": "USD" }, "savings": { "amount": { "value": 98.00, "formatted": "$98.00", "short": "98", "currency": "USD" }, "percentage": "33%" } } }, "errors": [] } ``` -------------------------------- ### Get License by License Key (cURL) Source: https://chariow.dev/api-reference/licenses/get-license Use this cURL command to make a GET request to retrieve license details. Replace YOUR_API_KEY with your actual API key and ABC-123-XYZ-789 with the target license key. ```bash curl -X GET "https://api.chariow.com/v1/licenses/ABC-123-XYZ-789" \ -H "Authorization: Bearer YOUR_API_KEY" ``` -------------------------------- ### Example API Response for Listing Pulses Source: https://chariow.dev/en/guides/pulses This is an example of the JSON response structure when listing Pulses. It includes details like Pulse ID, URL, status, source, triggers, associated products, store information, and timestamps. ```json { "data": [ { "id": "pls_abc123xyz", "url": "https://example.com/webhooks/chariow", "is_enabled": true, "source": { "value": "manual", "label": "Manual", "description": "Created manually" }, "triggers": [ { "value": "successful_sale", "label": "Successful Sale", "description": "Triggers when a sale is completed" } ], "products": [ { "id": "prd_def456", "name": "Premium Course", "type": "course", "pictures": { "thumbnail": "https://cdn.chariow.com/products/thumb.jpg", "cover": "https://cdn.chariow.com/products/cover.jpg" }, "category": { "value": "education_and_learning", "label": "Education and Learning" }, "pricing": { "type": "one_time", "price": { "value": 99, "formatted": "$99.00", "short": "99", "currency": "USD" }, "effective": { "value": 99, "formatted": "$99.00", "short": "99", "currency": "USD" } }, "bundle": null, "metadata": null } ], "store": { "id": "str_xyz789", "name": "My Digital Store", "logo_url": "https://cdn.chariow.com/stores/xyz789/logo.png", "url": "https://mystore.mychariow.com" }, "is_editable": true, "created_at": "2025-01-10T08:00:00+00:00", "updated_at": "2025-01-10T08:00:00+00:00" } ], "pagination": { "next_cursor": null, "prev_cursor": null, "has_more": false } } ``` -------------------------------- ### Fetch Store Information with Python Source: https://chariow.dev/en/introduction/quickstart Use this Python snippet to verify your API key by fetching your store information. Replace 'sk_live_your_api_key_here' with your actual API key. ```python import requests response = requests.get( 'https://api.chariow.com/v1/store', headers={'Authorization': 'Bearer sk_live_your_api_key_here'} ) print(response.json()) ``` -------------------------------- ### Get Affiliate Details (Node.js) Source: https://chariow.dev/api-reference/affiliates/get-affiliate This Node.js snippet demonstrates how to retrieve affiliate details using the Fetch API. It sends a GET request to the affiliates endpoint with the affiliate code and includes the API key in the Authorization header. The response data is then logged to the console. ```javascript const response = await fetch('https://api.chariow.com/v1/affiliates/CREATOR123', { headers: { 'Authorization': 'Bearer sk_live_your_api_key' } }); const { data } = await response.json(); console.log(data); ```