### Example Bundle Link
Source: https://docs.subbly.dev/docs/installation/docs/guide
This HTML snippet demonstrates a link for a product bundle, using the URL structure `/checkout/buy/bundle/BUNDLE_ID`, which the Subbly widget captures.
```HTML
Buy a bundle
```
--------------------------------
### Example: Sign in with password
Source: https://docs.subbly.dev/docs/installation/reference/subbly-sdk
Example of using `subbly.auth.login` to authenticate a user with their email and password.
```JavaScript
await subbly.auth.login({
email: '[email protected]',
password: 'C5wrzJtK9HHg'
})
```
--------------------------------
### Get a List of Products with Subbly
Source: https://docs.subbly.dev/docs/installation/reference/subbly-sdk
This JavaScript example shows how to fetch a paginated list of products using `subbly.products.list`. It demonstrates how to specify page, items per page, and expand related data like variants and pricings.
```javascript
const { data, pagination } = await subbly.products.list({
page: 1,
perPage: 10,
expand: ['variants.parent', 'pricings.parent']
})
```
--------------------------------
### Example Product Link with URL Structure
Source: https://docs.subbly.dev/docs/installation/docs/guide
This HTML snippet demonstrates a product link using the URL structure `/checkout/buy/PRODUCT_ID`, which SubblyCart.js can intercept to open product configuration.
```HTML
Buy
```
--------------------------------
### Example: Register a new Subbly account
Source: https://docs.subbly.dev/docs/installation/reference/subbly-sdk
Example of using `subbly.auth.register` to create a new account with email, first name, and last name.
```JavaScript
await subbly.auth.register({
email: '[email protected]',
firstName: 'John',
lastName: 'Doe'
})
```
--------------------------------
### Example: Sign in with OTP
Source: https://docs.subbly.dev/docs/installation/reference/subbly-sdk
Example of using `subbly.auth.otpLogin` to authenticate a user with their email and OTP.
```JavaScript
await subbly.auth.otpLogin({
email: '[email protected]',
token: '123456'
})
```
--------------------------------
### Example: Load a bundle
Source: https://docs.subbly.dev/docs/installation/reference/subbly-sdk
Example of using `subbly.bundles.load` to fetch bundle information by ID, with optional expansion parameters.
```JavaScript
const bundle = await subbly.bundles.load(123, {
expand: ['plans.variants.parent', 'plans.pricings.parent']
})
```
--------------------------------
### Subbly.js SDK Installation Methods
Source: https://docs.subbly.dev/docs/installation/reference/subbly-sdk
Details the various ways to integrate the Subbly.js SDK into your application, including npm installation and CDN usage.
```APIDOC
Installation:
- From npm: Install the SDK as a package dependency.
- Using CDN: Include the SDK script directly via a Content Delivery Network.
```
--------------------------------
### Example: Get access token
Source: https://docs.subbly.dev/docs/installation/reference/subbly-sdk
Example of using `subbly.auth.getAccessToken` to retrieve the current user's access token.
```JavaScript
const accessToken = subbly.auth.getAccessToken()
```
--------------------------------
### Example: Request OTP
Source: https://docs.subbly.dev/docs/installation/reference/subbly-sdk
Example of using `subbly.auth.otp` to request an OTP for a given email.
```JavaScript
await subbly.auth.otp({
email: '[email protected]'
})
```
--------------------------------
### Example Survey Flow Link
Source: https://docs.subbly.dev/docs/installation/docs/guide
This HTML snippet shows a link for a survey flow, using the URL structure `/checkout/buy/survey/SURVEY_ID`, which the Subbly widget captures.
```HTML
Start a survey flow
```
--------------------------------
### Get a Bundle Quote with Subbly API (JavaScript)
Source: https://docs.subbly.dev/docs/installation/reference/subbly-sdk
Example of using `subbly.bundles.quote` to obtain a summary quote for a bundle, specifying product IDs and quantities.
```javascript
const quote = await subbly.subscriptions.quote(123, {
productId: 123,
quantity: 1,
items: [
{
productId: 234,
quantity: 1
}
]
})
```
--------------------------------
### JavaScript: Example of applyCoupon
Source: https://docs.subbly.dev/docs/installation/reference/cart
Example usage of the applyCoupon method to add a coupon to the cart.
```JavaScript
subblyCart.applyCoupon('COUPON_CODE')
```
--------------------------------
### Example Product Link with Data Attribute
Source: https://docs.subbly.dev/docs/installation/docs/guide
This HTML snippet shows a product link using the `data-subbly-product` attribute to specify the product ID, which SubblyCart.js can intercept for product configuration.
```HTML
Buy
```
--------------------------------
### Example: Sign in with social login
Source: https://docs.subbly.dev/docs/installation/reference/subbly-sdk
Example of using `subbly.auth.social` to authenticate a user via a social provider like Facebook using an access token.
```JavaScript
const { accessToken } = await subbly.auth.social({
token: 'eyJhbGciOiJIb....dQssw5c',
provider: 'facebook'
})
```
--------------------------------
### Get Setup Token for a Gateway using Subbly Wallet API
Source: https://docs.subbly.dev/docs/installation/reference/subbly-sdk
Obtains a payment setup token for a specified gateway. The token type varies by gateway (e.g., client token for Braintree, secret for Stripe, order ID for PayPal). This method returns a promise that resolves with a WalletSetupResponse.
```APIDOC
subbly.wallet.setup(payload): Promise
Parameters:
payload: WalletSetupPayload
Returns: Promise
```
```JavaScript
const { token } = await subbly.wallet.setup({
gatewayId: 111
})
```
--------------------------------
### Load a Parent Product with Variants and Pricings in Subbly
Source: https://docs.subbly.dev/docs/installation/reference/subbly-sdk
This JavaScript example demonstrates how to load detailed information for a parent product, including its variants and pricing options, using `subbly.products.load`.
```javascript
const product = await subbly.products.load(123, {
expand: [
'pricings.parent',
'variants.parent'
]
})
```
--------------------------------
### JavaScript: Example of applyGiftCard
Source: https://docs.subbly.dev/docs/installation/reference/cart
Example usage of the applyGiftCard method to add a gift card to the cart.
```JavaScript
subblyCart.applyGiftCard('ba445a44-e446-47da-b496-97d569f59ff5')
```
--------------------------------
### Basic SubblyCart.js Widget Installation
Source: https://docs.subbly.dev/docs/installation/reference/cart
This snippet demonstrates the standard method to include the SubblyCart.js widget on your webpage. It sets the 'apiKey' globally and loads the script asynchronously, recommended before the closing