### Install @dudadev/partner-api Source: https://github.com/dudadev/partner-api/blob/main/README.md Install the package using npm or yarn. ```bash npm install @dudadev/partner-api --save # or yarn add @dudadev/partner-api ``` -------------------------------- ### Install with npm Source: https://github.com/dudadev/partner-api/blob/main/_autodocs/getting-started.md Install the partner-api library using npm. This is the standard package manager for Node.js. ```bash npm install @dudadev/partner-api --save ``` -------------------------------- ### Install with yarn Source: https://github.com/dudadev/partner-api/blob/main/_autodocs/getting-started.md Install the partner-api library using yarn. This is an alternative package manager for Node.js. ```bash yarn add @dudadev/partner-api ``` -------------------------------- ### Get Settings Source: https://github.com/dudadev/partner-api/blob/main/README.md Retrieves the e-commerce settings for a given site. ```APIDOC ## GET /api-sandbox.duda.co/api/integrationhub/application/site/{site_name}/ecommerce ### Description Retrieves the e-commerce settings for a given site. ### Method GET ### Endpoint /api-sandbox.duda.co/api/integrationhub/application/site/{site_name}/ecommerce ### Parameters #### Path Parameters - **site_name** (string) - Required - The name of the site. ``` -------------------------------- ### authentication.getWelcomeLink() Source: https://github.com/dudadev/partner-api/blob/main/_autodocs/api-reference/accounts.md Generates a welcome link for a new account, facilitating the initial setup and onboarding process for new users. ```APIDOC ## authentication.getWelcomeLink() ### Description Generate a welcome link for a new account. ### Method POST ### Endpoint /accounts/authentication/welcome-link ### Parameters #### Request Body - **account_name** (string) - Required - Account to generate welcome for ### Request Example ```json { "account_name": "jane-smith" } ``` ### Response #### Success Response (200) - **url** (string) - One-time welcome/setup URL #### Response Example ```json { "url": "https://welcome.example.com/ghi789rst" } ``` ``` -------------------------------- ### get() Source: https://github.com/dudadev/partner-api/blob/main/_autodocs/api-reference/accounts.md Retrieve account information. ```APIDOC ## get() ### Description Retrieve account information. ### Method Not specified (SDK method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **account_name** (string) - yes - Name of the account ### Request Example ```typescript const account = await duda.accounts.get({ account_name: "john-doe" }); console.log(`Account: ${account.first_name} ${account.last_name}`); ``` ### Response #### Success Response - **account_name** (string) - **first_name** (string) - **last_name** (string) - **email** (string) - **phone_number** (string) #### Response Example ```json { "account_name": "john-doe", "first_name": "John", "last_name": "Doe", "email": "john.doe@example.com", "phone_number": "+1-555-1234" } ``` ``` -------------------------------- ### Get Welcome Link Source: https://github.com/dudadev/partner-api/blob/main/_autodocs/endpoints.md Generates a welcome link for a specified account. ```APIDOC ## POST /api/accounts/welcome/{account_name} ### Description Generates a welcome link for a specified account. ### Method POST ### Endpoint /api/accounts/welcome/{account_name} ### Parameters #### Path Parameters - **account_name** (string) - Required - Account name ### Response #### Success Response (200 OK) - **url** (string) - The welcome link ``` -------------------------------- ### get() Source: https://github.com/dudadev/partner-api/blob/main/_autodocs/api-reference/ecomm-products.md Retrieves detailed information for a specific product using its ID. ```APIDOC ## get() ### Description Retrieve details for a specific product. ### Method GET ### Endpoint /ecomm/products/{product_id} ### Parameters #### Path Parameters - **product_id** (string) - Required - ID of the product to retrieve #### Query Parameters - **site_name** (string) - Required - Name of the site ### Response #### Success Response (200) - **id** (string) - Unique identifier for the product - **name** (string) - Name of the product - **description** (string) - Description of the product - **sku** (string) - Stock Keeping Unit - **external_id** (string) - External identifier for the product - **status** (string) - Product status ('ACTIVE' or 'HIDDEN') - **stock_status** (string) - Stock status ('IN_STOCK' or 'OUT_OF_STOCK') - **quantity** (number) - Current stock quantity - **managed_inventory** (boolean) - Whether inventory is managed - **requires_shipping** (boolean) - Whether the product requires shipping - **type** (string) - Product type ('PHYSICAL', 'DIGITAL', 'SERVICE', 'DONATION') - **images** (Array<{ url: string, alt: string }>) - Array of product images - **prices** (Array<{ price: string, compare_at_price: string, currency: string }>) - Array of product prices - **categories** (Array<{ id: string, title: string, order: number }>) - Array of product categories - **options** (Array) - Product variations options - **variations** (Array) - Product variations - **seo** (object) - SEO information for the product - **custom_fields** (Array<{ id: string, value: string }>) - Custom fields for the product #### Response Example ```json { "id": "prod-12345", "name": "Example Product Details", "description": "Detailed description of the example product.", "sku": "EX-PROD-001-DETAIL", "external_id": "ext-123-detail", "status": "ACTIVE", "stock_status": "IN_STOCK", "quantity": 45, "managed_inventory": true, "requires_shipping": true, "type": "PHYSICAL", "images": [ { "url": "http://example.com/detail-image.jpg", "alt": "Product Detail Image" } ], "prices": [ { "price": "21.99", "compare_at_price": "31.99", "currency": "USD" } ], "categories": [ { "id": "cat-001", "title": "Electronics", "order": 1 } ], "options": [], "variations": [], "seo": { "title": "Example Product Details - My Store", "description": "Get detailed info on the example product.", "product_url": "/products/example-product-details" }, "custom_fields": [] } ``` ``` -------------------------------- ### Get Site Plan Source: https://github.com/dudadev/partner-api/blob/main/README.md Retrieves the current site plan for a given site. ```APIDOC ## GET /api/sites/multiscreen/{site_name}/plan ### Description Retrieves the current site plan for a given site. ### Method GET ### Endpoint /api/sites/multiscreen/{site_name}/plan ### Parameters #### Path Parameters - **site_name** (string) - Required - The name of the site. ### Request Example ```typescript duda.plans.get({ site_name: site_name }); ``` ``` -------------------------------- ### Get Pages Source: https://github.com/dudadev/partner-api/blob/main/README.md Retrieves a list of all appstore pages for a given site. ```APIDOC ## GET /api/integrationhub/application/site/{site_name}/v2/pages ### Description Retrieves a list of all appstore pages for a given site. ### Method GET ### Endpoint /api/integrationhub/application/site/{site_name}/v2/pages ### Parameters #### Path Parameters - **site_name** (string) - Required - The name of the site. ### Response #### Success Response (200) - **pages** (array) - A list of page objects. - **page_uuid** (string) - The unique identifier for the page. - **title** (string) - The title of the page. - **published** (boolean) - Indicates if the page is published. ``` -------------------------------- ### Get Categories Source: https://github.com/dudadev/partner-api/blob/main/README.md Retrieves a list of all product categories for a given site. ```APIDOC ## GET /api/sites/multiscreen/{site_name}/ecommerce/categories ### Description Retrieves a list of all product categories for a given site. ### Method GET ### Endpoint /api/sites/multiscreen/{site_name}/ecommerce/categories ### Parameters #### Path Parameters - **site_name** (string) - Required - The name of the site. ### Request Example ```typescript duda.ecomm.categories.list({ site_name: site_name }); ``` ``` -------------------------------- ### Get Product Source: https://github.com/dudadev/partner-api/blob/main/_autodocs/endpoints.md Retrieves details for a specific product by its ID on a given site. ```APIDOC ## GET /api/sites/multiscreen/{site_name}/ecommerce/products/{product_id} ### Description Retrieves details for a specific product by its ID on a given site. ### Method GET ### Endpoint /api/sites/multiscreen/{site_name}/ecommerce/products/{product_id} ### Parameters #### Path Parameters - **site_name** (string) - Required - Site name - **product_id** (string) - Required - Product ID ### Response #### Success Response (200 OK) - **ProductResponse** ``` -------------------------------- ### Get Store Source: https://github.com/dudadev/partner-api/blob/main/README.md Retrieves the e-commerce store details for a specific site. This endpoint provides information about the store setup. ```APIDOC ## GET /api/sites/multiscreen/{site_name}/ecommerce/store ### Description Retrieves the e-commerce store details for a specific site. ### Method GET ### Endpoint /api/sites/multiscreen/{site_name}/ecommerce/store ### Parameters #### Path Parameters - **site_name** (string) - Required - The name of the site. ``` -------------------------------- ### get() Source: https://github.com/dudadev/partner-api/blob/main/_autodocs/api-reference/sites.md Retrieves detailed information for a specific site using its name. ```APIDOC ## get() ### Description Retrieves detailed information for a specific site using its name. ### Method `get` ### Parameters #### Payload Parameters - **payload.site_name** (string) - Required - Name of the site to retrieve ### Response #### Success Response - **site_name** (string) - **site_default_domain** (string) - **preview_site_url** (string) - **editor_site_url** (string) - **overview_site_url** (string) - **last_published_date** (string) - **first_published_date** (string) - **modification_date** (string) - **creation_date** (string) - **publish_status** ('PUBLISHED' | 'UNPUBLISHED' | 'NOT_PUBLISHED_YET') - **certificate_status** ('COMPLETE' | 'IN_PROGRESS' | 'FAILED') - **store_status** ('NONE' | 'ACTIVE' | 'SUSPENDED') - **store_type** ('NATIVE' | 'THIRDPARTY') - **force_https** (boolean) - **lang** (string) - **thumbnail_url** (string) - **canonical_url** (string) - **cookie_notification** (string) - **fav_icon** (string) - **labels** (SiteLabel[]) - **account_name** (string) - **external_uid** (string) - **site_domain** (string) - **site_business_info** (object) - **site_alternate_domains** (object) - **site_seo** (object) ### Request Example ```typescript const site = await duda.sites.get({ site_name: "example-site" }); console.log(`Site: ${site.site_name}`); console.log(`Status: ${site.publish_status}`); console.log(`Domain: ${site.site_default_domain}`); ``` ``` -------------------------------- ### Get Site Created Report Source: https://github.com/dudadev/partner-api/blob/main/README.md Retrieves a report of all sites created. No specific setup is required beyond initializing the Duda client. ```typescript duda.reporting.sites.created(); ``` -------------------------------- ### Get Site Information with Host Override Source: https://github.com/dudadev/partner-api/blob/main/_autodocs/getting-started.md Retrieves information about a specific Duda site, allowing for an override of the default API host. This is useful when an app is installed on multiple Duda instances. ```APIDOC ## GET /sites ### Description Retrieves information about a specific Duda site, allowing for an override of the default API host. This is useful when an app is installed on multiple Duda instances. ### Method GET ### Endpoint `/sites` ### Parameters #### Path Parameters - **site_name** (string) - Required - The name of the site to retrieve. - **token** (string) - Required - The authorization token for accessing the API. #### Query Parameters - **host** (string) - Optional - The custom API endpoint host to use for the request. ### Request Example ```json { "site_name": "site-name", "token": "auth.authorization_code" } ``` ### Request Options ```json { "host": "api_endpoint" } ``` ### Response #### Success Response (200) - **site_data** (object) - Contains detailed information about the site. #### Response Example ```json { "site_data": { ... } } ``` ``` -------------------------------- ### Create a New Site Source: https://github.com/dudadev/partner-api/blob/main/_autodocs/api-reference/sites.md Use the `create` method to provision a new site. Specify a template alias or ID, and optionally provide a domain prefix, external UID, language, labels, and initial site data. ```typescript const newSite = await duda.sites.create({ template_alias: "blank", default_domain_prefix: "my-new-business", external_uid: "customer-456", lang: "en", labels: [{ name: "Premium" }] }); console.log(`Site created: ${newSite.site_name}`); ``` -------------------------------- ### Get Product Option Source: https://github.com/dudadev/partner-api/blob/main/README.md Fetch details for a specific product option using its ID and the site name. ```typescript duda.ecomm.options.get({ site_name: site_name, option_id: option_id }); ``` -------------------------------- ### create() Source: https://github.com/dudadev/partner-api/blob/main/_autodocs/api-reference/sites.md Creates a new site using a specified template and optional configurations. ```APIDOC ## create() ### Description Create a new site. ### Method POST (inferred from create operation) ### Endpoint /sites (inferred from context) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **payload.template_alias** (string) - yes - Template alias or ID to use - **payload.template_id** (string | number) - no - Template ID (alternative to alias) - **payload.default_domain_prefix** (string) - no - Subdomain prefix for default domain - **payload.external_uid** (string) - no - External reference ID for the site - **payload.url** (string) - no - Custom domain URL - **payload.lang** (string) - no - Site language code - **payload.labels** (SiteLabel[]) - no - Labels to assign to site - **payload.site_data** (Site) - no - Initial site content and configuration ### Request Example ```typescript const newSite = await duda.sites.create({ template_alias: "blank", default_domain_prefix: "my-new-business", external_uid: "customer-456", lang: "en", labels: [{ name: "Premium" }] }); console.log(`Site created: ${newSite.site_name}`); ``` ### Response #### Success Response (200) - **site_name** (string) - Generated site name ``` -------------------------------- ### Handle Different API Endpoints for Sites Source: https://github.com/dudadev/partner-api/blob/main/README.md This function demonstrates how to dynamically set the API endpoint for a specific site's request using the request override feature. It retrieves site installation details and makes a GET request to the sites endpoint. ```typescript function getSite(site: string) { const { site_name, auth, api_endpoint } = getInstallFromDB(site); return duda.appstore.sites.get( { site_name: site_name, token: auth.authorization_code, }, { host: api_endpoint, }, ); } getSite("a-site-name") .then((site) => console.log(site)) .catch((err) => console.log(err.status, err.error)); ``` -------------------------------- ### Get all products for a store Source: https://github.com/dudadev/partner-api/blob/main/_autodocs/api-reference/ecomm-overview.md Retrieves a list of all products available in a specific store. Allows for pagination with a limit parameter. ```APIDOC ## Get all products for a store ### Description Retrieves a list of all products available in a specific store. Allows for pagination with a limit parameter. ### Method Not specified (SDK method) ### Endpoint Not specified (SDK method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **site_name** (string) - Required - The name of the store. - **limit** (number) - Optional - The maximum number of products to return. ``` -------------------------------- ### Generate Welcome Link for New Account Source: https://github.com/dudadev/partner-api/blob/main/_autodocs/api-reference/accounts.md Use this method to generate a welcome or setup link for a new account. This one-time URL is intended for new users. ```typescript const welcomeLink = await duda.accounts.authentication.getWelcomeLink({ account_name: "jane-smith" }); console.log(`Welcome Link: ${welcomeLink.url}`); // Send to new user ``` -------------------------------- ### get() Source: https://github.com/dudadev/partner-api/blob/main/_autodocs/api-reference/content.md Retrieve the content library for a site. This method fetches all content associated with a given site name. ```APIDOC ## get() ### Description Retrieve the content library for a site. ### Method get ### Parameters #### Path Parameters - **site_name** (string) - yes - Name of the site ### Request Example ```typescript const content = await duda.content.get({ site_name: "my-site" }); console.log(`Business: ${content.business_name}`); console.log(`Email: ${content.email}`); ``` ### Response #### Success Response (200) - **ContentLibrary** (object) - An object containing all site content. ``` -------------------------------- ### create() Source: https://github.com/dudadev/partner-api/blob/main/_autodocs/api-reference/accounts.md Create a new partner account. ```APIDOC ## create() ### Description Create a new partner account. ### Method Not specified (SDK method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **account_name** (string) - yes - Unique account identifier - **first_name** (string) - no - Account holder first name - **last_name** (string) - no - Account holder last name - **email** (string) - no - Account email address - **phone_number** (string) - no - Phone number ### Request Example ```typescript const newAccount = await duda.accounts.create({ account_name: "jane-smith", first_name: "Jane", last_name: "Smith", email: "jane@example.com", phone_number: "+1-555-0456" }); console.log(`Account created: ${newAccount.account_name}`); ``` ### Response Returns the created account information. #### Success Response - **account_name** (string) - **first_name** (string) - **last_name** (string) - **email** (string) - **phone_number** (string) #### Response Example ```json { "account_name": "jane-smith", "first_name": "Jane", "last_name": "Smith", "email": "jane@example.com", "phone_number": "+1-555-0456" } ``` ``` -------------------------------- ### Get Injected Content Source: https://github.com/dudadev/partner-api/blob/main/README.md Retrieves injected content for a site. Use this to get content that has been injected. ```typescript duda.content.injectedContent.get({ site_name: site_name }); ``` -------------------------------- ### GET /api/sites/multiscreen/templates Source: https://github.com/dudadev/partner-api/blob/main/README.md Lists all available site templates. Supports filtering by page count. ```APIDOC ## GET /api/sites/multiscreen/templates ### Description Lists all available site templates. Supports filtering by page count. ### Method GET ### Endpoint https://api.duda.co/api/sites/multiscreen/templates ### Parameters #### Query Parameters - **page_count.gte** (number) - Optional - Minimum page count for templates. ### Request Example ```typescript duda.templates.list({ 'page_count.gte': 1 }); ``` ``` -------------------------------- ### Get Refund Source: https://github.com/dudadev/partner-api/blob/main/README.md Retrieve the details of a specific refund for a given order. This is the current method for getting refund information. ```typescript duda.appstore.ecomm.orders.refunds.get({ site_name: site_name, order_id: order_id, refund_id: refund_id, }); ``` -------------------------------- ### Set up shipping Source: https://github.com/dudadev/partner-api/blob/main/_autodocs/api-reference/ecomm-overview.md Sets up shipping for the store by providing a URL for live shipping rates. ```APIDOC ## Set up shipping ### Description Sets up shipping for the store by providing a URL for live shipping rates. ### Method Not specified (SDK method) ### Endpoint Not specified (SDK method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **site_name** (string) - Required - The name of the store. - **live_shipping_rates_url** (string) - Required - The URL where live shipping rates can be found. ``` -------------------------------- ### Initialize Duda API Client Source: https://github.com/dudadev/partner-api/blob/main/_autodocs/getting-started.md Basic setup for the Duda API client using environment variables for credentials. Ensure DUDA_API_USER and DUDA_API_PASS are set. ```typescript const { Duda } = require("@dudadev/partner-api"); const duda = new Duda({ user: process.env.DUDA_API_USER, pass: process.env.DUDA_API_PASS, env: Duda.Envs.direct, }); ``` -------------------------------- ### Get Cart Source: https://github.com/dudadev/partner-api/blob/main/README.md Retrieves a specific e-commerce cart by its ID for a given site. Use this to get details of a single cart. ```APIDOC ## GET /api/sites/multiscreen/{site_name}/ecommerce/carts/{cart_id} ### Description Retrieves a specific e-commerce cart by its ID for a given site. ### Method GET ### Endpoint /api/sites/multiscreen/{site_name}/ecommerce/carts/{cart_id} ### Parameters #### Path Parameters - **site_name** (string) - Required - The name of the site. - **cart_id** (string) - Required - The ID of the cart. ``` -------------------------------- ### Get Tax Zone Source: https://github.com/dudadev/partner-api/blob/main/README.md Retrieves a specific tax zone by its ID. Use this to get detailed information about a single tax zone. ```typescript duda.ecomm.zones.get({ site_name: site_name, zone_id: zone_id }); ``` -------------------------------- ### Create a Product Source: https://github.com/dudadev/partner-api/blob/main/_autodocs/INDEX.md Add a new product to a site's e-commerce store. Requires the site_name, product name, and pricing information. ```typescript const product = await duda.ecomm.products.create({ site_name: "my-site", name: "Widget", prices: [{ price: "9.99", currency: "USD" }] }); ``` -------------------------------- ### create() Source: https://github.com/dudadev/partner-api/blob/main/_autodocs/api-reference/ecomm-products.md Creates a new product in the store. It allows for detailed product information including pricing, images, options, and SEO. ```APIDOC ## POST /ecomm/products ### Description Create a new product in the store. ### Method POST ### Endpoint /ecomm/products ### Parameters #### Request Body - **payload.site_name** (string) - yes - Name of the site - **payload.name** (string) - yes - Product name - **payload.description** (string) - no - Product description - **payload.sku** (string) - no - Stock keeping unit - **payload.external_id** (string) - no - External reference ID - **payload.status** (string) - no - 'ACTIVE' or 'HIDDEN' (default: 'ACTIVE') - **payload.type** (string) - no - Product type: 'PHYSICAL', 'DIGITAL', 'SERVICE', or 'DONATION' - **payload.quantity** (number) - no - Quantity in stock - **payload.managed_inventory** (boolean) - no - Enable inventory management - **payload.requires_shipping** (boolean) - no - Whether product requires shipping - **payload.stock_status** (string) - no - 'IN_STOCK' or 'OUT_OF_STOCK' - **payload.images** (Image[]) - no - Array of product images - **payload.prices** (Price[]) - no - Array of prices (currencies) - **payload.options** (ProductOption[]) - no - Product options/variants - **payload.seo** (ProductSEO) - no - SEO configuration - **payload.custom_fields** (CustomField[]) - no - Custom field values ### Response #### Success Response (200) Returns the created product with ID assigned. ### Request Example ```typescript const newProduct = await duda.ecomm.products.create({ site_name: "my-store", name: "Blue T-Shirt", description: "Cotton t-shirt available in multiple sizes", sku: "TSHIRT-BLUE-001", external_id: "sku-123456", type: "PHYSICAL", status: "ACTIVE", quantity: 100, managed_inventory: true, requires_shipping: true, prices: [ { price: "19.99", compare_at_price: "29.99", currency: "USD" } ], images: [ { url: "https://example.com/blue-tshirt.jpg", alt: "Blue T-Shirt Front" } ], options: [ { id: "size-option", name: "Size", type: "TEXT", choices: [ { id: "xs", value: "XS" }, { id: "s", value: "S" }, { id: "m", value: "M" }, { id: "l", value: "L" } ] } ] }); console.log(`Product created with ID: ${newProduct.id}`); ``` ``` -------------------------------- ### Get Tax Group Source: https://github.com/dudadev/partner-api/blob/main/README.md Retrieves a specific tax group by its ID. Use this to get detailed information about a single tax group. ```typescript duda.ecomm.groups.get({ site_name: site_name, group_id: group_id }); ``` -------------------------------- ### Get a Specific Site Plan Source: https://github.com/dudadev/partner-api/blob/main/README.md Fetches details for a specific site's plan. Requires the site name. ```typescript duda.plans.get({ site_name: site_name }); ``` -------------------------------- ### List Product Options Source: https://github.com/dudadev/partner-api/blob/main/README.md Retrieve a list of all available product options for a given site. Requires the site name. ```typescript duda.ecomm.options.list({ site_name: site_name }); ``` -------------------------------- ### Example 404 Not Found Response Source: https://github.com/dudadev/partner-api/blob/main/_autodocs/errors.md An example JSON response for a 404 Not Found error, indicating that a specific site could not be located. ```json { "status": 404, "error": { "message": "Site 'nonexistent' not found" } } ``` -------------------------------- ### Get Payment Gateway Source: https://github.com/dudadev/partner-api/blob/main/README.md Retrieves the details of a specific payment gateway for a given site. Use this to get information about a particular gateway's configuration. ```APIDOC ## GET /api/sites/multiscreen/{site_name}/ecommerce/payment-gateways/{gateway_id} ### Description Retrieves the details of a specific payment gateway for a given site. ### Method GET ### Endpoint /api/sites/multiscreen/{site_name}/ecommerce/payment-gateways/{gateway_id} ### Parameters #### Path Parameters - **site_name** (string) - Required - The name of the site. - **gateway_id** (string) - Required - The ID of the payment gateway. ### Response #### Success Response (200) - **gateway_details** (object) - An object containing the details of the payment gateway. ### Request Example ```typescript duda.ecomm.gateways.get({ site_name: site_name, gateway_id: gateway_id }); ``` ``` -------------------------------- ### Create Site Source: https://github.com/dudadev/partner-api/blob/main/README.md Creates a new site using a specified template. ```APIDOC ## Create Site ### Description Creates a new site using a specified template. ### Method POST ### Endpoint https://api.duda.co/api/sites/multiscreen/create ### Parameters #### Request Body - **template_id** (string) - Required - The ID of the template to use for the new site. ### Request Example ```typescript duda.sites.create({ template_id: template_id }); ``` ``` -------------------------------- ### Get Site Activities Source: https://github.com/dudadev/partner-api/blob/main/README.md Retrieves a list of activities for a given site. The site name must be provided. ```typescript duda.reporting.activities.get({ site_name: site_name }); ``` -------------------------------- ### Get all products for a store Source: https://github.com/dudadev/partner-api/blob/main/_autodocs/api-reference/ecomm-overview.md Retrieves a list of products for a given store. Use the 'limit' parameter to control the number of results. ```typescript const products = await duda.ecomm.products.list({ site_name: "my-store", limit: 100 }); console.log(`Found ${products.total_responses} products`); ``` -------------------------------- ### Example 422 Unprocessable Entity Response Source: https://github.com/dudadev/partner-api/blob/main/_autodocs/errors.md An example JSON response for a 422 Unprocessable Entity error, detailing specific field validation errors. ```json { "status": 422, "error": { "message": "Validation failed", "errors": [ { "field": "name", "message": "Product name is required" }, { "field": "prices[0].price", "message": "Price must be a valid decimal" } ] } } ``` -------------------------------- ### Create New Site Source: https://github.com/dudadev/partner-api/blob/main/_autodocs/getting-started.md Create a new site using a specified template alias and a desired default domain prefix. This is the starting point for setting up new web presences. ```typescript const newSite = await duda.sites.create({ template_alias: "blank", default_domain_prefix: "my-new-site" }); ``` -------------------------------- ### Fetch Site Data with Async/Await Source: https://github.com/dudadev/partner-api/blob/main/_autodocs/getting-started.md Example of fetching site data using async/await syntax. Includes basic error handling for API requests. ```typescript (async function () { try { const site = await duda.sites.get({ site_name: "example-site" }); console.log(site); } catch (error) { console.log(error.status, error.error); } })(); ``` -------------------------------- ### Get Tax Zone Rate Source: https://github.com/dudadev/partner-api/blob/main/README.md Retrieves a specific tax zone rate by its ID. Use this to get detailed information about a single tax rate within a zone. ```typescript duda.ecomm.zones.getRate({ site_name: site_name, zone_id: zone_id, rate_id: rate_id }); ``` -------------------------------- ### Example 400 Bad Request Response Source: https://github.com/dudadev/partner-api/blob/main/_autodocs/errors.md An example JSON response for a 400 Bad Request error, detailing the specific issue like a missing required parameter. ```json { "status": 400, "error": { "message": "Required parameter 'template_id' is missing", "field": "template_id" } } ``` -------------------------------- ### Create a new site Source: https://github.com/dudadev/partner-api/blob/main/_autodocs/INDEX.md Creates a new site with a specified template and default domain prefix. ```APIDOC ## Create a new site ### Description Creates a new site with a specified template and default domain prefix. ### Method POST ### Endpoint /sites ### Parameters #### Request Body - **template_alias** (string) - Required - The alias of the template to use for the new site. - **default_domain_prefix** (string) - Required - The prefix for the default domain of the new site. ### Request Example ```javascript const newSite = await duda.sites.create({ template_alias: "blank", default_domain_prefix: "my-site" }); ``` ### Response #### Success Response (201) - **site_name** (string) - The name of the newly created site. - **default_domain** (string) - The default domain of the newly created site. ``` -------------------------------- ### Listen to Duda SDK Events Source: https://github.com/dudadev/partner-api/blob/main/_autodocs/api-reference/duda-class.md Example of how to listen for SDK events, specifically the 'refresh' event for handling token refreshes. ```typescript duda.events.on("refresh", (auth) => { // Handle token refresh saveAuthToDatabase(auth); }); ``` -------------------------------- ### List Product Options Source: https://github.com/dudadev/partner-api/blob/main/README.md Retrieves a list of all product options for a given site. ```APIDOC ## GET /api/sites/multiscreen/{site_name}/ecommerce/options ### Description Retrieves a list of all product options for a given site. ### Method GET ### Endpoint /api/sites/multiscreen/{site_name}/ecommerce/options ### Parameters #### Path Parameters - **site_name** (string) - Required - The name of the site. ### Response #### Success Response (200) - **options** (array) - A list of product options. ``` -------------------------------- ### Get Specific Product Source: https://github.com/dudadev/partner-api/blob/main/README.md Retrieve details for a specific product using its ID. Requires both the site name and the product ID. ```typescript duda.ecomm.products.get({ site_name: site_name, product_id: product_id }); ``` -------------------------------- ### Create Welcome Link Source: https://github.com/dudadev/partner-api/blob/main/README.md Generates a welcome link for a specified account. ```APIDOC ## POST /api/accounts/reset-password/{account_name} ### Description Generates a welcome link for an account. ### Method POST ### Endpoint /api/accounts/reset-password/{account_name} ### Parameters #### Path Parameters - **account_name** (string) - Required - The name of the account for which to generate the welcome link. ``` -------------------------------- ### Get Section Source: https://github.com/dudadev/partner-api/blob/main/README.md Retrieves a specific section by its UUID. ```APIDOC ## Get Section ### Description Retrieves a specific section by its UUID. ### Method GET ### Endpoint https://api.duda.co/api/sections/{section_uuid} ### Parameters #### Path Parameters - **section_uuid** (string) - Required - The UUID of the section to retrieve. ### Request Example ```typescript duda.sections.get({ section_uuid: section_uuid }); ``` ``` -------------------------------- ### POST /api/sites/multiscreen/templates/fromsite Source: https://github.com/dudadev/partner-api/blob/main/README.md Creates a new site template from an existing site. ```APIDOC ## POST /api/sites/multiscreen/templates/fromsite ### Description Creates a new site template from an existing site. ### Method POST ### Endpoint https://api.duda.co/api/sites/multiscreen/templates/fromsite ### Parameters #### Request Body - **site_name** (string) - Required - The name of the site to create the template from. ### Request Example ```typescript duda.templates.createFromSite({ site_name: site_name }); ``` ``` -------------------------------- ### Create Product Source: https://github.com/dudadev/partner-api/blob/main/README.md Creates a new e-commerce product for a given site. ```APIDOC ## POST /api-sandbox.duda.co/api/integrationhub/application/site/{site_name}/ecommerce/products ### Description Creates a new e-commerce product for a given site. ### Method POST ### Endpoint /api-sandbox.duda.co/api/integrationhub/application/site/{site_name}/ecommerce/products ### Parameters #### Path Parameters - **site_name** (string) - Required - The name of the site. #### Request Body - **product_data** (object) - Required - An object containing the data for the new product. ``` -------------------------------- ### Get Category Source: https://github.com/dudadev/partner-api/blob/main/README.md Retrieves details of a specific product category. ```APIDOC ## GET /api/sites/multiscreen/{site_name}/ecommerce/categories/{category_id} ### Description Retrieves details of a specific product category. ### Method GET ### Endpoint /api/sites/multiscreen/{site_name}/ecommerce/categories/{category_id} ### Parameters #### Path Parameters - **site_name** (string) - Required - The name of the site. - **category_id** (string) - Required - The ID of the category. ### Request Example ```typescript duda.ecomm.categories.get({ site_name: site_name, category_id: category_id }); ``` ``` -------------------------------- ### Get Order Source: https://github.com/dudadev/partner-api/blob/main/README.md Retrieves a specific e-commerce order by its ID. ```APIDOC ## GET /api/sites/multiscreen/{site_name}/ecommerce/orders/{order_id} ### Description Retrieves a specific e-commerce order by its ID. ### Method GET ### Endpoint /api/sites/multiscreen/{site_name}/ecommerce/orders/{order_id} ### Parameters #### Path Parameters - **site_name** (string) - Required - The name of the site. - **order_id** (string) - Required - The ID of the order. ### Request Example ```typescript duda.ecomm.orders.get({ site_name: site_name, order_id: order_id }); ``` ``` -------------------------------- ### Create a product with variants Source: https://github.com/dudadev/partner-api/blob/main/_autodocs/api-reference/ecomm-overview.md Creates a new product with specified pricing and options. Options can include variations like size, color, etc. ```typescript const product = await duda.ecomm.products.create({ site_name: "my-store", name: "T-Shirt", type: "PHYSICAL", prices: [{ price: "19.99", currency: "USD" }], options: [ { name: "Size", type: "TEXT", choices: [ { id: "s", value: "Small" }, { id: "m", value: "Medium" }, { id: "l", value: "Large" } ] } ] }); ``` -------------------------------- ### Get Account Source: https://github.com/dudadev/partner-api/blob/main/_autodocs/endpoints.md Retrieves details for a specific account by its name. ```APIDOC ## GET /api/accounts/{account_name} ### Description Retrieves details for a specific account by its name. ### Method GET ### Endpoint /api/accounts/{account_name} ### Parameters #### Path Parameters - **account_name** (string) - Required - Account name ### Response #### Success Response (200 OK) - Account object ``` -------------------------------- ### Bulk Create Products Source: https://github.com/dudadev/partner-api/blob/main/README.md Create multiple products simultaneously. Requires the site name. This is useful for importing a large number of products. ```typescript duda.ecomm.products.bulkCreate({ site_name: site_name }); ``` -------------------------------- ### Create a New Product Source: https://github.com/dudadev/partner-api/blob/main/_autodocs/api-reference/ecomm-products.md Use this method to add a new product to your store. It accepts detailed product information including pricing, images, and options. ```typescript const newProduct = await duda.ecomm.products.create({ site_name: "my-store", name: "Blue T-Shirt", description: "Cotton t-shirt available in multiple sizes", sku: "TSHIRT-BLUE-001", external_id: "sku-123456", type: "PHYSICAL", status: "ACTIVE", quantity: 100, managed_inventory: true, requires_shipping: true, prices: [ { price: "19.99", compare_at_price: "29.99", currency: "USD" } ], images: [ { url: "https://example.com/blue-tshirt.jpg", alt: "Blue T-Shirt Front" } ], options: [ { id: "size-option", name: "Size", type: "TEXT", choices: [ { id: "xs", value: "XS" }, { id: "s", value: "S" }, { id: "m", value: "M" }, { id: "l", value: "L" } ] } ] }); console.log(`Product created with ID: ${newProduct.id}`); ``` -------------------------------- ### Get Manifest Source: https://github.com/dudadev/partner-api/blob/main/README.md Retrieves the manifest for a specific application using its UUID. ```APIDOC ## GET /api/integrationhub/application/{app_uuid} ### Description Retrieves the manifest for a specific application. ### Method GET ### Endpoint /api/integrationhub/application/{app_uuid} ### Parameters #### Path Parameters - **app_uuid** (string) - Required - The unique identifier of the application. ### Response #### Success Response (200) - The manifest details for the application. ``` -------------------------------- ### Set up shipping provider Source: https://github.com/dudadev/partner-api/blob/main/_autodocs/api-reference/ecomm-overview.md Sets up a shipping provider for the store. Requires a URL to fetch live shipping rates. ```typescript const provider = await duda.ecomm.shipping.create({ site_name: "my-store", live_shipping_rates_url: "https://myapp.com/shipping/rates" }); ``` -------------------------------- ### Get Cart Source: https://github.com/dudadev/partner-api/blob/main/README.md Retrieves a specific cart by its ID for a given site. ```APIDOC ## GET /api/integrationhub/application/site/{site_name}/ecommerce/carts/{cart_id} ### Description Retrieves a specific cart by its ID for a given site. ### Method GET ### Endpoint /api/integrationhub/application/site/{site_name}/ecommerce/carts/{cart_id} ### Parameters #### Path Parameters - **site_name** (string) - Required - The name of the site. - **cart_id** (string) - Required - The ID of the cart. ### Response #### Success Response (200) - **[Response fields not specified in source]** #### Response Example { "example": "[Response body not specified in source]" } ``` -------------------------------- ### Create Product Source: https://github.com/dudadev/partner-api/blob/main/_autodocs/endpoints.md Creates a new product for a given site. Requires product details in the request body. ```APIDOC ## POST /api/sites/multiscreen/{site_name}/ecommerce/products ### Description Creates a new product for a given site. Requires product details in the request body. ### Method POST ### Endpoint /api/sites/multiscreen/{site_name}/ecommerce/products ### Parameters #### Path Parameters - **site_name** (string) - Required - Site name #### Request Body - **CreateProductPayload** ### Response #### Success Response (201 Created) - **ProductResponse** ``` -------------------------------- ### Get Client Settings Source: https://github.com/dudadev/partner-api/blob/main/README.md Retrieves client settings for stats email. ```APIDOC ## GET /api/accounts/{account_name}/sites/{site_name}/stats-email ### Description Retrieves client settings for stats email. ### Method GET ### Endpoint /api/accounts/{account_name}/sites/{site_name}/stats-email ### Parameters #### Path Parameters - **account_name** (string) - Required - The name of the account. - **site_name** (string) - Required - The name of the site. ### Request Example None ### Response #### Success Response (200) - **settings** (object) - Client settings for stats email. ``` -------------------------------- ### Duda Constructor Source: https://github.com/dudadev/partner-api/blob/main/_autodocs/api-reference/duda-class.md Initializes a new Duda instance with the provided configuration and optional app store settings. This is the main entry point for all API interactions. ```APIDOC ## Constructor Duda ### Description Initializes a new Duda instance with the provided configuration and optional app store settings. This is the main entry point for all API interactions. ### Method ```typescript constructor(opts: DudaConfig, appOpts?: DudaAppConfig): Duda ``` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None #### `opts` (DudaConfig) - Required Main configuration object. - **`opts.user`** (string) - Required - API username for authentication. - **`opts.pass`** (string) - Required - API password for authentication. - **`opts.env`** (string) - Optional - API host environment (use Duda.Envs for options). Defaults to 'api.duda.co'. - **`opts.timeout`** (number) - Optional - Request timeout in milliseconds. Defaults to 10000. - **`opts.maxNetworkRetries`** (number) - Optional - Number of automatic retries on network failure. Defaults to 0. - **`opts.logger`** (function) - Optional - Custom logger function. Defaults to console.log. - **`opts.logLevel`** (string) - Optional - Log level: 'error', 'warning', 'info', or 'debug'. #### `appOpts` (DudaAppConfig) - Optional App Store configuration with auth and UUID. - **`appOpts.auth`** (object) - Optional - Authorization object from app install webhook. - **`appOpts.uuid`** (string) - Optional - UUID of the Duda app. ### Returns A configured Duda instance with access to all API resources. ### Example ```typescript const { Duda } = require("@dudadev/partner-api"); const duda = new Duda({ user: process.env.API_USER, pass: process.env.API_PASS, env: Duda.Envs.direct, timeout: 15000, maxNetworkRetries: 2 }); // Access resources const sites = await duda.sites.list(); const products = await duda.ecomm.products.list({ site_name: "my-site" }); ``` ``` -------------------------------- ### Get Collection Source: https://github.com/dudadev/partner-api/blob/main/README.md Retrieves a specific collection by its name for a given site. ```APIDOC ## GET /api/sites/multiscreen/{site_name}/collection/{collection_name} ### Description Retrieves a specific collection by its name for a given site. ### Method GET ### Endpoint /api/sites/multiscreen/{site_name}/collection/{collection_name} ### Parameters #### Path Parameters - **site_name** (string) - Required - The name of the site. - **collection_name** (string) - Required - The name of the collection. ### Request Example ```typescript duda.collections.get({ site_name: site_name, collection_name: collection_name, }); ``` ``` -------------------------------- ### Create Product Option Source: https://github.com/dudadev/partner-api/blob/main/README.md Creates a new product option for a given site. ```APIDOC ## POST /api/sites/multiscreen/{site_name}/ecommerce/options ### Description Creates a new product option for a given site. ### Method POST ### Endpoint /api/sites/multiscreen/{site_name}/ecommerce/options ### Parameters #### Path Parameters - **site_name** (string) - Required - The name of the site. #### Request Body - **name** (string) - Required - The name of the product option. - **choices** (array) - Required - A list of choices for the product option. ### Request Example ```json { "name": "Color", "choices": [ {"value": "Red"}, {"value": "Blue"} ] } ``` ### Response #### Success Response (200) - **option** (object) - The created product option details. ``` -------------------------------- ### Duda API Client Constructor Options Source: https://github.com/dudadev/partner-api/blob/main/_autodocs/getting-started.md Demonstrates various options available when initializing the Duda API client, including credentials, environment, timeout, and network retries. ```typescript const duda = new Duda({ user: "api-user", // Required: API username pass: "api-pass", // Required: API password env: Duda.Envs.sandbox, // Optional: API environment (default: direct) timeout: 10000, // Optional: Request timeout in milliseconds (default: 10000) maxNetworkRetries: 2, // Optional: Number of automatic retries on network failure }); ``` -------------------------------- ### Get Snippet Source: https://github.com/dudadev/partner-api/blob/main/README.md Retrieves a specific snippet by its ID for a given site. ```APIDOC ## Get Snippet ### Description Retrieves a specific snippet by its ID for a given site. ### Method GET ### Endpoint `https://api.duda.co/api/sites/multiscreen/{site_name}/snippets/{id}` ### Parameters #### Path Parameters - **site_name** (string) - Required - The name of the site. - **id** (string) - Required - The ID of the snippet. ### Request Example ```typescript duda.snippets.get({ site_name: site_name, id: id }); ``` ```