Skip to content

Commit

Permalink
add some up-to-date info
Browse files Browse the repository at this point in the history
  • Loading branch information
illia-malachyn committed Jan 21, 2025
1 parent 935825a commit 28c11d5
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ data.
wss://api.flow.com/ws
```
- **Limits**:
- Each connection supports up to 50 concurrent subscriptions. Exceeding this limit will result in an error.
- TODO: list all limits here
- Each connection supports up to 10 concurrent subscriptions. Exceeding this limit will result in an error.
- Each subscription may provide up to 5 responses per second.
- After 1 minute of inactivity (no data is sent to/read from connection) connection is closed.
- **Supported Topics**:
- `blocks`
- `block_headers`
Expand Down Expand Up @@ -62,7 +63,7 @@ To receive data from a specific topic, send a subscription request in JSON forma

```json
{
"subscription_id": "some-uuid-42",
"subscription_id": "some-id-42",
"action": "subscribe",
"topic": "blocks",
"arguments": {
Expand All @@ -71,7 +72,7 @@ To receive data from a specific topic, send a subscription request in JSON forma
}
```

- **`subscription_id`**: A unique identifier for the subscription (UUID string). If omitted, the server generates one.
- **`subscription_id`**: A unique identifier for the subscription (string with max len constraint). If omitted, the server generates one.
- **`action`**: The action to perform. Supported actions include: `subscribe`, `unsubscribe`, `list_subscriptions`.
- **`topic`**: The topic to subscribe to. See the supported topics in the Overview.
- **`arguments`**: Additional arguments for subscriptions, such as `start_block_height`, `start_block_id`, and others.
Expand All @@ -80,7 +81,8 @@ To receive data from a specific topic, send a subscription request in JSON forma

```json
{
"subscription_id": "some-uuid-42"
"subscription_id": "some-id-42",
"action": "subscribe"
}
```

Expand All @@ -94,7 +96,7 @@ To stop receiving data from a specific topic, send an unsubscribe request.

```json
{
"subscription_id": "some-uuid-42",
"subscription_id": "some-id-42",
"action": "unsubscribe"
}
```
Expand All @@ -103,7 +105,8 @@ To stop receiving data from a specific topic, send an unsubscribe request.

```json
{
"subscription_id": "some-uuid-42"
"subscription_id": "some-id-42",
"action": "unsubscribe"
}
```

Expand All @@ -127,14 +130,14 @@ You can retrieve a list of all active subscriptions for the current WebSocket co
{
"subscriptions": [
{
"subscription_id": "uuid-1",
"subscription_id": "some-id-1",
"topic": "blocks",
"arguments": {
"start_block_height": "123456789"
}
},
{
"subscription_id": "uuid-2",
"subscription_id": "some-id-2",
"topic": "events",
"arguments": {}
}
Expand All @@ -152,7 +155,7 @@ If a request is invalid or cannot be processed, the server responds with an erro

```json
{
"subscription_id": "some-uuid-42",
"subscription_id": "some-id-42",
"payload": {
"id": "0x1234...",
"height:": "123456789",
Expand All @@ -165,7 +168,7 @@ If a request is invalid or cannot be processed, the server responds with an erro

```json
{
"subscription_id": "some-uuid-42",
"subscription_id": "some-id-42",
"error": {
"code": 500,
"message": "Access Node failed"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Subscribe requests must be sent as JSON in text frames, one request per frame.

```json
{
"subscription_id": "fa770c92-a1f1-4375-9a7b-e13d9aac0786",
"subscription_id": "some-id-1",
"action": "subscribe",
"topic": "block_digests",
"parameters": {
Expand All @@ -25,15 +25,16 @@ Subscribe requests must be sent as JSON in text frames, one request per frame.

```json
{
"subscription_id": "fa770c92-a1f1-4375-9a7b-e13d9aac0786"
"subscription_id": "some-id-1",
"action": "subscribe"
}
```

### Example of failed response

```json
{
"subscription_id": "fa770c92-a1f1-4375-9a7b-e13d9aac0786",
"subscription_id": "some-id-1",
"error": {
"code": 400,
"message": "invalid message"
Expand All @@ -45,7 +46,7 @@ Subscribe requests must be sent as JSON in text frames, one request per frame.

```json
{
"subscription_id": "fa770c92-a1f1-4375-9a7b-e13d9aac0786",
"subscription_id": "some-id-1",
"payload": {
"id": "0x1234...",
"height:": "123456789",
Expand All @@ -58,7 +59,7 @@ Subscribe requests must be sent as JSON in text frames, one request per frame.

```json
{
"subscription_id": "fa770c92-a1f1-4375-9a7b-e13d9aac0786",
"subscription_id": "some-id-1",
"error": {
"code": 500,
"message": "access node is not responsible"
Expand All @@ -68,12 +69,12 @@ Subscribe requests must be sent as JSON in text frames, one request per frame.

### Request fields:

| Name | Type | Mandatory | Description |
|-------------------|--------|-----------|--------------------------------------------------------------------------------------------|
| `subscription_id` | UUID | NO | Optional unique identifier for the subscription. Server will generate one if omitted |
| `action` | STRING | YES | Action to perform. Must be `subscribe` to initiate a subscription |
| `topic` | STRING | YES | The topic to subscribe to, such as `blocks`, `block_digests`, etc. |
| `parameters` | STRING | NO | Additional parameters for the subscription, such as `start_block_id`, `start_block_height` |
| Name | Type | Mandatory | Description |
|-------------------|--------|-----------|-----------------------------------------------------------------------------------------------------------------------------------|
| `subscription_id` | STRING | NO | Optional unique identifier for the subscription. Max length of ID generated by client is 20. Server will generate UUID if omitted |
| `action` | STRING | YES | Action to perform. Must be `subscribe` to initiate a subscription |
| `topic` | STRING | YES | The topic to subscribe to, such as `blocks`, `block_digests`, etc. |
| `arguments` | STRING | NO | Additional parameters for the subscription, such as `start_block_id`, `start_block_height` or other. |

You can use `subscription_id` as a client-generated identifier to track responses asynchronously.
If you don't provide `subscription_id`, the server will generate one and include it in the response.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Unsubscribe requests must be sent as JSON in text frames, one request per frame.

```json
{
"subscription_id": "fa770c92-a1f1-4375-9a7b-e13d9aac0786",
"subscription_id": "some-id-1",
"action": "unsubscribe"
}
```
Expand All @@ -21,7 +21,8 @@ Unsubscribe requests must be sent as JSON in text frames, one request per frame.

```json
{
"subscription_id": "fa770c92-a1f1-4375-9a7b-e13d9aac0786"
"subscription_id": "some-id-1",
"action": "unsubscribe"
}
```

Expand All @@ -40,5 +41,5 @@ Unsubscribe requests must be sent as JSON in text frames, one request per frame.

| Name | Type | Mandatory | Description |
|-------------------|--------|-----------|-----------------------------------------------------------------------|
| `subscription_id` | UUID | YES | Unique identifier of the subscription |
| `subscription_id` | STRING | YES | Unique identifier of the subscription |
| `action` | STRING | YES | Action to perform. Must be `unsubscribe` to initiate a unsubscription |

0 comments on commit 28c11d5

Please sign in to comment.