---
description: >-
  This page includes all endpoints available for the products module of Logiciel
  Actif.
---

# Products

## List all products

<mark style="color:blue;">`GET`</mark> `https://app.gem-books.com/api/products`

This endpoint allows you to get the list of your products. \
The products are returned sorted by creation date, with the most recent product appearing first.

#### Query Parameters

| Name      | Type    | Description                                                                      |
| --------- | ------- | -------------------------------------------------------------------------------- |
| page      | integer | The number of the page you wish to see. Default is 1.                            |
| per\_page | integer | The number of the desired result per page. Default is 20. Maximum values is 100. |

#### Headers

| Name           | Type   | Description                  |
| -------------- | ------ | ---------------------------- |
| Authentication | string | Bearer token                 |
| Accept         | string | Should be `application/json` |

{% tabs %}
{% tab title="200 " %}
```javascript
{
    "data": [
        {
            "id": 1,
            ...
        }
    ],
    "meta": {
        "current_page": 1,
        "last_page": 1,
        "per_page": 25,
        "total": 4
    }
}
```
{% endtab %}
{% endtabs %}

## Retrieve a product

<mark style="color:blue;">`GET`</mark> `https://app.gem-books.com/api/products/:id`

This endpoint allows you to get the details of the product.

#### Path Parameters

| Name | Type    | Description                        |
| ---- | ------- | ---------------------------------- |
| id   | integer | The ID of the product to retrieve. |

#### Headers

| Name           | Type   | Description                   |
| -------------- | ------ | ----------------------------- |
| Authentication | string | Bearer token.                 |
| Accept         | string | Should be `application/json`. |

{% tabs %}
{% tab title="200 " %}
```javascript
{
    "data": {
        "id": 1,
        ...
    }
}
```
{% endtab %}
{% endtabs %}



## Create a product

<mark style="color:green;">`POST`</mark> `https://app.gem-books.com/api/products`

This endpoint allows you to create a product. \
Returns the created product.

#### Headers

| Name           | Type   | Description                   |
| -------------- | ------ | ----------------------------- |
| Authentication | string | Bearer token.                 |
| Content-Type   | string | Should be `application/json`. |
| Accept         | string | Should be `application/json`. |

#### Request Body

| Name         | Type    | Description           |
| ------------ | ------- | --------------------- |
| code         | string  | Product code.         |
| category\_id | integer | Product categorie id. |
| name\_fr     | string  | Product french name.  |
| name\_en     | string  | Product english name. |

{% tabs %}
{% tab title="200 " %}
```javascript
{
    "data": {
        "id": 1,
        ...
    }
}
```
{% endtab %}
{% endtabs %}

#### Body example

```javascript
{
    "code": "demo",
    "category_id": 1,
    "name_fr": "Produit démo",
    "name_en": "Demo Prodcut"
}
```

## Update a product

<mark style="color:orange;">`PUT`</mark> `https://app.gem-books.com/api/products/:id`

This endpoint allows you to update a specific product. \
Returns the updated product.

#### Path Parameters

| Name | Type    | Description          |
| ---- | ------- | -------------------- |
| id   | integer | Product id to update |

#### Headers

| Name           | Type   | Description                   |
| -------------- | ------ | ----------------------------- |
| Authentication | string | Bearer token.                 |
| Content-Type   | string | Should be `application/json`. |
| Accept         | string | Should be `application/json`. |

{% tabs %}
{% tab title="200 " %}
```javascript
{
    "data": {
        "id": 1,
        ...
    }
}
```
{% endtab %}
{% endtabs %}

#### Body example

```javascript
{
    "name_fr": "Nouveau Produit démo",
    "name_en": "New Demo Prodcut"
}
```

