# Products v1

{% hint style="warning" %} <mark style="background-color:orange;">Products v1 endpoints</mark> are <mark style="background-color:red;">depreciated</mark> but do still work, it is <mark style="color:red;">**HIGHLY**</mark> recommended to update your applications to the <mark style="background-color:blue;">v2 endpoints</mark>
{% endhint %}

{% hint style="danger" %}
Products v1 support will be depreciated from the wrapper at some point.
{% endhint %}

### Supported Endpoints

* `getAllProducts()`: Returns a list of all the listings created.
* `getProduct(id)`: Retrieves a listing by the entered ID.
* `createProduct(fields)`: Creates a listing and returns the created listing.
* `updateProduct(id, fields)`: Updates a listing by the entered ID.
* `deleteProduct(id)`: Deletes a listing by the entered ID.

***

## Products v1&#x20;

{% hint style="warning" %} <mark style="background-color:orange;">Products v1 endpoints</mark> are <mark style="background-color:red;">depreciated</mark> but do still work, it is <mark style="color:red;">**HIGHLY**</mark> recommended to update your applications to the <mark style="background-color:blue;">v2 endpoints</mark>
{% endhint %}

{% hint style="danger" %}
Products v1 support will be depreciated from the wrapper at some point.
{% endhint %}

### `getAllProducts()`

<details>

<summary>Usage</summary>

```javascript
const Sellapp = require("sellapp-node");
const API = new Sellapp.API("YOUR_API_KEY");

API.productsv1.getAllProducts().then((res) => {
    console.log(res)
});
```

</details>

***

### `getProduct()`

<table><thead><tr><th></th><th>Type</th><th width="40">Required</th><th>Description</th></tr></thead><tbody><tr><td><code>id</code></td><td>string</td><td>✔️</td><td>ID of a Product</td></tr></tbody></table>

<details>

<summary>Usage</summary>

```javascript
const Sellapp = require("sellapp-node");
const API = new Sellapp.API("YOUR_API_KEY");

API.productsv1.getProduct("6666").then((res) => {
    console.log(res)
})
```

</details>

***

### `createProduct()`

{% tabs %}
{% tab title="Parameters" %}

|  Parameters  |  Type  | Required |   Description   |
| :----------: | :----: | :------: | :-------------: |
|   `fields`   | object |    ✔️    | Product's field |
| {% endtab %} |        |          |                 |

{% tab title="Fields' Value" %}

|        Fields' Values       |       Type      | Required |                                                                    Description                                                                    |
| :-------------------------: | :-------------: | :------: | :-----------------------------------------------------------------------------------------------------------------------------------------------: |
|           `title`           |      string     |    ✔️    |                                                                The product's title.                                                               |
|        `description`        |      string     |    ✔️    |                                                             The product's description.                                                            |
|           `image`           |   object/null   |     ❌    |                                       An image binary which will be visible when someone views your product.                                      |
|           `order`           |     int/null    |     ❌    |                                           The product's order in which it is sorted on your storefront.                                           |
|         `visibility`        |      string     |    ✔️    |                        Either "PUBLIC", "HIDDEN", or "PRIVATE" - depending on whether you want this product to be visible.                        |
|        `deliverable`        |      object     |    ✔️    | The product's deliverable which will be sent to the customer. Consists of three pieces of nested data, being "delivery\_text", "type", and "data" |
|           `price`           |      object     |    ✔️    |                         The product's price in nested format. Consists of two variables "PRICE" (in cents) and "CURRENCY".                        |
|           `humble`          |     boolean     |     ❌    |                              Whether you want to allow the customer to pay more than the product's price. ( ͡° ͜ʖ ͡°)                             |
|      `payment_methods`      | array of string |    ✔️    |                         Items Enum: "COINBASE" "PAYDASH" "PAYPAL" "STRIPE". The product's payment methods in array format.                        |
|   `additional_information`  |      array      |     ❌    |                                Additional info that can be requested from the customer during the checkout process.                               |
|       `bulk_discount`       |      array      |     ❌    |                                  An array of discounts when a customer purchases more than a specified quantity.                                  |
| `minimum_purchase_quantity` |       int       |    ✔️    |                                                 The minimum amount a customer is able to purchase.                                                |
| `maximum_purchase_quantity` |     int/null    |     ❌    |                                                 The maximum amount a customer is able to purchase.                                                |
|          `webhook`          |   string/null   |     ❌    |                                          A webhook URL that will receive updates when orders are placed.                                          |
|          `warranty`         |   object/null   |     ❌    |                                         The warranty time in which a customer is able to request a refund.                                        |
|           `locked`          |     boolean     |     ❌    |                                            Whether this product is locked by the admins or moderators.                                            |
|          `section`          |     int/null    |     ❌    |                              The ID of a section to associate with this product. Use null to disassociate a section.                              |
|         {% endtab %}        |                 |          |                                                                                                                                                   |
|        {% endtabs %}        |                 |          |                                                                                                                                                   |

<details>

<summary>Usage</summary>

```javascript
const Sellapp = require("sellapp-node");
const API = new Sellapp.API("YOUR_API_KEY");

API.productsv1.createProduct({
	"title": "Millions of gold pieces",
	"description": "Get rich, buy this.",
	"deliverable": {
		"delivery_text": "Meet me in world 5",
		"type": "MANUAL",
		"data": {
			"stock": 666,
			"comment": "Thanks"
		}
	},
	"price": {
		"price": 50,
		"currency": "USD"
	},
	"payment_methods": ["PAYPAL"],
	"minimum_purchase_quantity": 1,
	"visibility": "HIDDEN"
}).then((res) => {
    console.log(res);
}).catch((err) => {
    console.log(err);
});
```

</details>

***

### `updateProduct()`

{% tabs %}
{% tab title="Parameters" %}

|  Parameters  |  Type  | Required |              Description             |
| :----------: | :----: | :------: | :----------------------------------: |
|     `id`     | string |    ✔️    | ID of the product you want to update |
|   `fields`   | object |    ✔️    |            Product's field           |
| {% endtab %} |        |          |                                      |

{% tab title="Fields' Value" %}

|        Fields' Values       |       Type      | Required |                                                                    Description                                                                    |
| :-------------------------: | :-------------: | :------: | :-----------------------------------------------------------------------------------------------------------------------------------------------: |
|           `title`           |      string     |    ✔️    |                                                                The product's title.                                                               |
|        `description`        |      string     |    ✔️    |                                                             The product's description.                                                            |
|           `image`           |   object/null   |     ❌    |                                       An image binary which will be visible when someone views your product.                                      |
|           `order`           |     int/null    |     ❌    |                                           The product's order in which it is sorted on your storefront.                                           |
|         `visibility`        |      string     |    ✔️    |                        Either "PUBLIC", "HIDDEN", or "PRIVATE" - depending on whether you want this product to be visible.                        |
|        `deliverable`        |      object     |    ✔️    | The product's deliverable which will be sent to the customer. Consists of three pieces of nested data, being "delivery\_text", "type", and "data" |
|           `price`           |      object     |    ✔️    |                         The product's price in nested format. Consists of two variables "PRICE" (in cents) and "CURRENCY".                        |
|           `humble`          |     boolean     |     ❌    |                              Whether you want to allow the customer to pay more than the product's price. ( ͡° ͜ʖ ͡°)                             |
|      `payment_methods`      | array of string |    ✔️    |                         Items Enum: "COINBASE" "PAYDASH" "PAYPAL" "STRIPE". The product's payment methods in array format.                        |
|   `additional_information`  |      array      |     ❌    |                                Additional info that can be requested from the customer during the checkout process.                               |
|       `bulk_discount`       |      array      |     ❌    |                                  An array of discounts when a customer purchases more than a specified quantity.                                  |
| `minimum_purchase_quantity` |       int       |    ✔️    |                                                 The minimum amount a customer is able to purchase.                                                |
| `maximum_purchase_quantity` |     int/null    |     ❌    |                                                 The maximum amount a customer is able to purchase.                                                |
|          `webhook`          |   string/null   |     ❌    |                                          A webhook URL that will receive updates when orders are placed.                                          |
|          `warranty`         |   object/null   |     ❌    |                                         The warranty time in which a customer is able to request a refund.                                        |
|           `locked`          |     boolean     |     ❌    |                                            Whether this product is locked by the admins or moderators.                                            |
|          `section`          |     int/null    |     ❌    |                              The ID of a section to associate with this product. Use null to disassociate a section.                              |
|         {% endtab %}        |                 |          |                                                                                                                                                   |
|        {% endtabs %}        |                 |          |                                                                                                                                                   |

<details>

<summary>Usage</summary>

```javascript
const Sellapp = require("sellapp-node");
const API = new Sellapp.API("YOUR_API_KEY");

API.productsv1.updateProduct("6666, {
	"title": "Millions of gold pieces EXTRA",
	"slug": "millions-of-gold-pieces",
	"description": "Get rich, buy this.",
	"visibility": "PUBLIC",
	"deliverable": {
		"delivery_text": "Meet me in world 1000!!",
		"type": "MANUAL",
		"data": {
			"stock": 666,
			"comment": "Thanks broski (scammed, real)"
		}
	},
	"price": {
		"price": 1000, // ( ͡° ͜ʖ ͡°)
		"currency": "USD"
	},
	"humble": true,
	"payment_methods": ["PAYPAL"],
	"minimum_purchase_quantity": 1,
	"maximum_purchase_quantity": 20
}).then((res) => {
    console.log(res); 
}).catch((err) => {
    console.log(err);
});
```

</details>

***

### `deleteProduct()`

| Parameters |  Type  | Required |   Description   |
| :--------: | :----: | :------: | :-------------: |
|    `id`    | string |    ✔️    | ID of a Product |

<details>

<summary>Usage</summary>

```javascript
const Sellapp = require("sellapp-node");
const API = new Sellapp.API("YOUR_API_KEY");

API.productsv1.deleteProduct("6666").then((res) => {
    console.log(res)
})
```

</details>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://friizologyy.gitbook.io/sell.app-api-wrapper/endpoints/products/products-v1.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
