API Architecture

<table>
  <tr>
    <td style={{ border: "1px solid white", textAlign: "center" }}>
      <Image title="rest.png" alt={265} align="center" width="auto" src="https://files.readme.io/4fb5549-rest.png" />
    </td>
    <td style={{ width: "80%", border: "1px solid white", padding: 0 }}>
      Quable PIM's API is organized on <a href="https://en.wikipedia.org/wiki/Representational_state_transfer">REST (Representational State Transfer)</a> principles. REST is an architectural style that describes how distributed software systems can expose consistent interfaces to their resources.
    </td>
  </tr>
</table>

## Data Format

REST APIs only support [JSON](https://www.json.org/json-en.html) format. All data created, updated, or retrieved via the Quable PIM API must be in JSON encoded with UTF-8.

## API Versions

In our ongoing efforts to provide the most reliable and stable environment, Quable PIM currently has two API versions:

* **API v4** -This is Quable PIM's most complete API version. It manages all Quable PIM data. It's used primarily for creation and modifications. There are no plans to deprecate this version, however [endpoint deprecations](ref:api-endpoint-deprecation#api_1-v4) are periodically scheduled.

* **API v5** - This is Quable PIM's newest API version. It's used primarily to retrieve *most* of the Quable PIM data. While this version is continuing to grow, it is stable. There are no plans to deprecate this version, however [endpoint deprecations](ref:api-endpoint-deprecation#api-v5) are periodically scheduled.

> 👍
>
> Both APIs can be used in the same scripts.

### Characteristics

<Table align={["left", "left", "left"]}>
  <thead>
    <tr>
      <th>Specifications</th>
      <th>API v4</th>
      <th>API v5</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Endpoint - Domain</td>
      <td>`https://{{YOUR-PIM}}.quable.com`</td>
      <td>`https://{{YOUR-PIM}}.quable.com`</td>
    </tr>
    <tr>
      <td>Endpoint - Prefix</td>
      <td><code>/api_1.php</code></td>
      <td><code>/api/</code></td>
    </tr>
    <tr>
      <td>Endpoint Deprecations</td>
      <td>[API v4 Endpoint Deprecations](ref:api-endpoint-deprecation#api_1-v4)</td>
      <td>[API v5 Endpoint Deprecations](ref:api-endpoint-deprecation#api-v5)</td>
    </tr>
    <tr>
      <td>Data format accepted in input / output</td>
      <td>
        <ul>
          <li><a href="https://www.json.org/json-en.html">JSON</a></li>
        </ul>
      </td>
      <td>
        <ul>
          <li><a href="https://www.json.org/json-en.html">JSON</a></li>
          <li><a href="https://json-ld.org/">JSON+LD</a></li>
          <li><a href="https://stateless.group/hal_specification.html">HAL+JSON</a></li>
        </ul>
      </td>
    </tr>
    <tr>
      <td>Autorisation - Type of token</td>
      <td>Bearer Token</td>
      <td>Bearer Token</td>
    </tr>
    <tr>
      <td>Request a token via script</td>
      <td>Yes</td>
      <td>Yes</td>
    </tr>
    <tr>
      <td>Use a predefined global token</td>
      <td>Yes (with customer service assistance)</td>
      <td>Yes (with customer service assistance)</td>
    </tr>
    <tr>
      <td>Multilingual interface contract</td>
      <td>No</td>
      <td>Yes</td>
    </tr>
  </tbody>
</Table>

## HTTP Headers & Verbs/Methods

Quable PIM's REST API endpoints are resource-centric and use the HTTP protocol to access and act upon them.

<Table align={["left", "left", "left"]}>
  <thead>
    <tr>
      <th></th>
      <th>API v4</th>
      <th>API v5</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td></td>
      <td></td>
      <td></td>
    </tr>
    <tr>
      <td>**HTTP Headers**</td>
      <td>
        <ul>
          <li><code>'Content-Type': 'application/json'</code></li>
        </ul>
      </td>
      <td>
        <ul>
          <li><code>'Content-Type': application/json</code></li>
          <li><code>'Content-Type': application/ld+json</code></li>
          <li><code>'Content-Type': application/hal+json</code></li>
        </ul>
      </td>
    </tr>
    <tr>
      <td>**HTTP Verbs/Methods**</td>
      <td>
        <ul>
          <li><code>GET</code> - Retrieve the representation of a single resource or a list of resources.</li>
          <li><code>POST</code> - Create an instance of a resource.</li>
          <li><code>PUT</code> - Partially update an existing resource.</li>
          <li><code>DELETE</code> - Delete an instance of a resource.</li>
        </ul>
      </td>
      <td>
        <ul>
          <li><code>GET</code> - Retrieve the representation of a single resource or a list of resources. </li>
        </ul>
      </td>
    </tr>
  </tbody>
</Table>

## Postman Collection

Postman Collections are a good way to group your requests together so you can save, reuse, and share them with others for testing your API calls. You can find the Quable Postman collection [here](https://documenter.getpostman.com/view/237314/TW6wJUEC).

> 🚧
>
> Depending on your contract and the volume of API calls, you may receive responses with the <a href="https://docs.quable.com/reference/error-codes#4xx-codes">HTTP response code <code>429</code></a>. In this case, your applications **must** reduce the number of calls or wait a few seconds before resuming calls.