# /listenSubmission

This method can track submission judging almost in real-time.

#### Query parameters

<table><thead><tr><th width="135">Name</th><th>Description</th></tr></thead><tbody><tr><td><code>id</code></td><td>ID of submission you want to listen for.</td></tr><tr><td><code>token</code></td><td>Your access token.<br>Required here because WSS connections can't use headers.</td></tr><tr><td><code>language</code></td><td>Language required to get text verdict representation.<br>Required here because WSS connections can't use headers.</td></tr></tbody></table>

### Message stages

#### 1. Current submission object

This message contains submissions object in the same format as in [/submissions/get](https://docs.sort-me.org/submissions#get-submissions).

```javascript
{
    "id": 138888,
    "user": {
        "id": 1,
        "handle": "sadfun",
        "avatar": "https://pic.sort-me.org/bd62e50c-7cfa-40d8-9009-f4753d696289"
    },
    "task_id": 1,
    "worst_metrics": {
        "time": 0,
        "memory": 0
    },
    "submitted_at": 1672947158,
    "lang": {
        "name": "Python 3.11",
        "highlight": "python",
        "api": "python",
        "ext": "py"
    },
    "test": 0,
    "verdict": 0,
    "verdict_text": "Judging",
    "points": 0
}
```

Then there are two options:

1. If **`verdict`** is not **`0`** (judging), then judging is already done, so websocket connection closed, and you will receive no more messages.&#x20;
2. If **`verdict`** is **`0`** (judging), then proceed to next messages stage.

#### 2. Test number

In fact, the only useful information that can be changed during judging and before getting a final verdict is test number. Therefore (and also for optimization purposes) you will get only it, without unnecessary JSON abstractions.

When it comes to judging your submission, you will start receiving plaintext numbers:

<figure><img src="https://3795788107-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MZWD1JzrFbsm5DEMQSE%2Fuploads%2FZshnJvwEA95rn3Mo48TN%2FScreenshot%202022-11-13%20at%2013.53.07.png?alt=media&#x26;token=3f3e0e66-e28b-4323-8dc3-c339555bc821" alt=""><figcaption><p>Websocket connection in Chrome DevTools</p></figcaption></figure>

That's a test number on which submission is being judged right now. You can display it as live counter, just as in sort-me.org after submission.

<figure><img src="https://3795788107-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MZWD1JzrFbsm5DEMQSE%2Fuploads%2FiTfMaS7oQmw6L97RSu6k%2FScreenshot%202022-11-13%20at%2014.00.19.png?alt=media&#x26;token=db91fcaa-3949-4af0-810a-21fc997fa0a1" alt=""><figcaption></figcaption></figure>

If you receive number `0`, it means that compilation stage has just started.

#### 3. Judged submission object

When judging is finished, you receive a submission preview again, in the same format as in [stage 1](#1.-current-submission-object).

```json
{
    "id": 138888,
    "user": {
        "id": 1,
        "handle": "sadfun",
        "avatar": "https://pic.sort-me.org/bd62e50c-7cfa-40d8-9009-f4753d696289"
    },
    "task_id": 1,
    "worst_metrics": {
        "time": 896,
        "memory": 14
    },
    "submitted_at": 1672947158,
    "lang": {
        "name": "Python 3.11",
        "highlight": "python",
        "api": "python",
        "ext": "py"
    },
    "test": 0,
    "verdict": 1,
    "verdict_text": "Full solution",
    "points": 100
}
```
