---
metadata:
  - name: generator
    content: Diplodoc Platform v5.55.0
alternate:
  - https://yandex.com/dev/market/partner-api/doc/en/push-notifications/concepts/quick-start-notifications-node-express.md
  - https://yandex.com/dev/market/partner-api/doc/ru/push-notifications/concepts/quick-start-notifications-node-express.md
  - https://yandex.com/dev/market/partner-api/doc/zh/push-notifications/concepts/quick-start-notifications-node-express.md
  - href: en/push-notifications/concepts/quick-start-notifications-node-express.md
    type: text/markdown
    title: Markdown version
  - href: ../../llms.txt
    type: text/markdown
    title: llms.txt
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.com/dev/market/partner-api/doc/en/llms.txt

# Launching integration on Node.js Express

This guide will help you set up the simplest test integration in JavaScript from scratch to work with notifications. You can check if your server is processing the notification.

{% note info "You will need a Node.js and Java are at least version 11, as well as Curl for checking the server operation" %}

Set them up in advance. How to install:

* [Node.js](https://nodejs.org/en)

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

* [Curl](https://curl.se/download.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>`.
  1. Run the command prompt in it.
  1. Write a command:

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

- Just a browser

  1. Download [the specification of the Yandex.Market notification service with GitHub](https://github.com/yandex-market/yandex-market-notification-api/archive/refs/heads/main.zip).
  1. 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 server {#generate}

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

    ```text translate=no
    npx @openapitools/openapi-generator-cli generate -i <path_to_openapi.yaml> -g nodejs-express-server -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.

{% note info "Learn more about the nodejs-express-server generator" %}

Generator Documentation: [nodejs-express-server](https://openapi-generator.tech/docs/generators/nodejs-express-server)

{% endnote %}

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

## Implement notification processing {#code}

1. Open the directory with the generated code in the IDE.
1. In `services/NotificationService.js` the notification processing logic is located. Add a simple code to process the notification with the type `PING`:

    ```javascript translate=no
    const Service = require('./Service');
    const logger = require('../logger');

    const sendNotification = (sendNotificationRequest) => new Promise(
      async (resolve, reject) => {
        try {
          if (sendNotificationRequest.body.notificationType == 'PING') {
            logger.info("PING notification processed")
          }
          // Возвращаем обязательное тело ответа
          resolve(Service.successResponse({
            name: "shop",
            time: new Date().toISOString(),
            version: "1.0.0"
          }));
        } catch (e) {
          reject(Service.rejectResponse(
            e.message || 'Invalid input',
            e.status || 405,
          ));
        }
      },
    );

    module.exports = {
      sendNotification,
    };
    ```

1. Write to the console `node index.js`. The server will start.
1. In a separate terminal window, make a test request to your server:

    ```text translate=no
    curl -X POST -L 'http://localhost:8080/notification' -H 'Content-Type: application/json' -d '{"notificationType": "PING", "time": "2025-01-01T00:00:00.000Z"}'
    ```

1. In the response you will see `{"name":"shop","time":"2025-02-28T12:32:01.918Z","version":"1.0.0"}`, and in the server logs the message `PING notification processed`.
