Skip to content

Commit

Permalink
improve some explanations
Browse files Browse the repository at this point in the history
  • Loading branch information
k1nder10 committed Jan 22, 2025
1 parent 28c11d5 commit 3bb8e24
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ If there are no active subscriptions, `subscriptions` array will be empty.

### Request fields

| Name | Type | Mandatory | Description |
|----------|--------|-----------|-----------------------------------------------------------------------------------------|
| `action` | STRING | YES | Action to perform. Must be `list_subscriptions` to initiate a list subscription request |
| Name | Type | Required | Description |
|----------|--------|----------|-----------------------------------------------------------------------------------------|
| `action` | STRING | YES | Action to perform. Must be `list_subscriptions` to initiate a list subscription request |
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ data.

- **Endpoint**: The WebSocket server is available at:
```
wss://api.flow.com/ws
wss://rest-mainnet.onflow.org/ws
```
- **Limits**:
- 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.
- Each connection supports up to 20 concurrent subscriptions. Exceeding this limit will result in an error.
- Each subscription may provide up to 20 responses per second.
- After 1 minute of inactivity (no data is sent to/read from connection) connection is closed.
- **Supported Topics**:
- `blocks`
Expand All @@ -38,7 +38,7 @@ data.
Use any WebSocket client library to connect to the endpoint. Below is an example using JavaScript:

```javascript
const ws = new WebSocket('wss://api.flow.com/ws');
const ws = new WebSocket('wss://rest-mainnet.onflow.org/ws');

ws.onopen = () => {
console.log('Connected to WebSocket server');
Expand Down Expand Up @@ -184,7 +184,8 @@ If a request is invalid or cannot be processed, the server responds with an erro

### Asynchronous environments

If you're working in an asynchronous environment, our Stream API ensures **in-order message delivery**.
If you're working in an asynchronous environment, the Streaming API ensures **first-in first-out** message processing,
so responses will be returned in the same order the requests were received over the connection.
You can leverage this feature to simplify your code and maintain consistency.

Additionally, you can use the `subscription_id` as a message identifier to manage subscriptions effectively.
Additionally, you can specify your own `subscription_id` in the subscribe request to easily identify the correct response.
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,19 @@ Subscribe requests must be sent as JSON in text frames, one request per frame.
"subscription_id": "some-id-1",
"error": {
"code": 500,
"message": "access node is not responsible"
"message": "internal error"
}
}
```

### Request fields:

| 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. |
| Name | Type | Required | 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 topic specific 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.

The order of params is not significant.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Unsubscribe requests must be sent as JSON in text frames, one request per frame.

### Request fields

| Name | Type | Mandatory | Description |
|-------------------|--------|-----------|-----------------------------------------------------------------------|
| `subscription_id` | STRING | YES | Unique identifier of the subscription |
| `action` | STRING | YES | Action to perform. Must be `unsubscribe` to initiate a unsubscription |
| Name | Type | Required | Description |
|-------------------|--------|----------|-----------------------------------------------------------------------|
| `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 3bb8e24

Please sign in to comment.