---
metadata:
  - name: generator
    content: Diplodoc Platform v5.50.6
alternate:
  - https://yandex.com/dev/market/partner-api/doc/en/step-by-step/quick-start-js.md
  - https://yandex.com/dev/market/partner-api/doc/ru/step-by-step/quick-start-js.md
  - https://yandex.com/dev/market/partner-api/doc/zh/step-by-step/quick-start-js.md
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.com/dev/market/partner-api/doc/en/llms.txt

# Launching integration in JavaScript

This guide will help you set up the simplest test integration in JavaScript from scratch for store requests to the Market. You will be able to request a list of stores and receive a response.

{% note info "You will need a Node.js and Java version 11 or higher" %}

Set them up in advance.

[How to install Node.js](https://nodejs.org/en)

[How to install Java](https://www.java.com/ru/download/help/download_options.html)

{% endnote %}

## Download OpenAPI-specification {#download}

{% list tabs %}

- Via git

  1. Open the folder where you want to save the specification. In this manual, it will be referred to as `<project_directory>`.
  2. Run the command prompt in it.
  3. Write a command:

        ```no-highlight translate=no
        git clone https://github.com/yandex-market/yandex-market-partner-api.git
        ```

- Just a browser

  1. Download [the Market specification with GitHub](https://github.com/yandex-market/yandex-market-partner-api/archive/refs/heads/main.zip).
  2. Unzip the archive to the folder where you want to save the specification. In this manual, it will be referred to as `<project_directory>`.

{% endlist %}

## Generate a client {#generate}

1. Open the folder `yandex-market-partner-api`, which appeared in the previous step.
2. Run the command prompt in it.
3. Write a command:

```text translate=no
npx @openapitools/openapi-generator-cli generate -i <path_to_openapi.yaml> -g javascript -o <output_path>
```

As a **output path** specify the folder where your project will be located.

If **openapitools** is not installed yet, please accept the installation. In the folder **output path** the client's files will appear.

> **Example**
>
> Let's say you downloaded an archive and unpacked it. The specification is in the folder `<project_directory>/yandex-market-partner-api`.
>
> Do you want to place the project in a folder `<project_directory>/market-integration`.
>
> &#49;. Open the folder `<project_directory>/yandex-market-partner-api`.
>
> &#50;. Run the command prompt in it.
>
> &#51;. In the console that opens, write:
>
>    ```text translate=no
>    npx @openapitools/openapi-generator-cli generate -i openapi/openapi.yaml -g javascript -o ../market-integration
>    ```
>
> &#52;. If you are prompted to install the generator, enter **Y** and click **Enter**.


## Create a project {#create-project}

1. Open the folder where the client's files are located. In the example above, this is `<project_directory>/market-integration`.
2. Run the command prompt in it.
3. Write a command:

    ```text translate=no
    npm install
    npm run build
    ```

## Prepare the data for access {#token}

Get an authorization token by [Instructions](https://yandex.com/dev/market/partner-api/doc/en/concepts/api-key.md).

## Make a request {#code}

To perform [GET v2/campaigns](https://yandex.com/dev/market/partner-api/doc/en/reference/campaigns/getCampaigns.md):

1. Open the created project in the IDE.
2. Create in the root of the project (folder `<project_directory>/market-integration`) file `index.js`.
3. Create an instance `CampaignsApi` and refer to the method `getCampaigns`. To do this, write to `index.js` here is the code:

    ```javascript translate=no
    const { CampaignsApi } = require('./dist');

    const campaignsApi = new CampaignsApi();
    campaignsApi.apiClient.authentications['ApiKey'].apiKey = '<token>';

    campaignsApi.getCampaigns(undefined, function (error, data) {
        console.log(JSON.stringify(data, null, 4));
    });
    ```

    As a `<token>` use the token you received in the previous step.

4. Write to the console `node index.js`.

The console will display the result of the query: the names of all stores, placement models, IDs, and more:

```json translate=no
{
    "campaigns": [
        {
            "domain": "Shop 1",
            "id": 12345678,
            "clientId": 87654321,
            "business": {
                "id": 123456,
                "name": "My shop"
            },
            "placementType": "FBS"
        },
        {
            "domain": "Shop 2",
            "id": 23456789,
            "clientId": 98765432,
            "business": {
                "id": 123456,
                "name": "My shop"
            },
            "placementType": "DBS"
        },
        {
            "domain": "GoodShop",
            "id": 34567891,
            "clientId": 19876543,
            "business": {
                "id": 123456,
                "name": "My shop"
            },
            "placementType": "FBY"
        },
    ],
    "pager": {
        "total": 3,
        "from": 1,
        "to": 3,
        "currentPage": 1,
        "pagesCount": 1,
        "pageSize": 3
    }
}
```
