{"id":20138282,"url":"https://github.com/pinax-network/substreams-sink-websockets","last_synced_at":"2025-04-09T18:08:48.165Z","repository":{"id":198498097,"uuid":"696421273","full_name":"pinax-network/substreams-sink-websockets","owner":"pinax-network","description":"Substreams Sink Websockets","archived":false,"fork":false,"pushed_at":"2024-02-13T22:20:03.000Z","size":295,"stargazers_count":2,"open_issues_count":2,"forks_count":1,"subscribers_count":5,"default_branch":"main","last_synced_at":"2024-10-29T21:04:05.433Z","etag":null,"topics":["substreams","thegraph"],"latest_commit_sha":null,"homepage":"https://substreams-sink-websockets-production.up.railway.app","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pinax-network.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-09-25T17:55:50.000Z","updated_at":"2024-06-27T09:31:43.000Z","dependencies_parsed_at":null,"dependency_job_id":"6b5c586b-e23b-4cfa-9f4f-fa97ee30a35c","html_url":"https://github.com/pinax-network/substreams-sink-websockets","commit_stats":null,"previous_names":["pinax-network/substreams-sink-websockets"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pinax-network%2Fsubstreams-sink-websockets","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pinax-network%2Fsubstreams-sink-websockets/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pinax-network%2Fsubstreams-sink-websockets/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pinax-network%2Fsubstreams-sink-websockets/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pinax-network","download_url":"https://codeload.github.com/pinax-network/substreams-sink-websockets/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247927402,"owners_count":21019526,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["substreams","thegraph"],"created_at":"2024-11-13T21:37:11.945Z","updated_at":"2025-04-09T18:08:48.141Z","avatar_url":"https://github.com/pinax-network.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [`Substreams`](https://substreams.streamingfast.io/) Sink WebSockets\n\n\u003e `substreams-sink-websockets` is a tool that allows developers to pipe data extracted from a blockchain to WebSockets.\n\n## WebSockets API\n\n| Method      | Params                | Description\n|-------------|-----------------------| ----------------------|\n| `ping`      |                       | Test connectivity to the WebSocket API.\n| `time`      |                       | Get the current server time to the WebSocket API.\n| `subscribe` | `{chain, moduleHash}` | Subscribe to a Substreams module hash by chain.\n\nSend Text Message with the following JSON payloads\n\n### `subscribe` Request\n\n```json\n{\n    \"method\": \"subscribe\",\n    \"params\": {\n        \"chain\": \"bsc\",\n        \"moduleHash\": \"0a363b2a63aadb76a525208f1973531d3616fbae\"\n    }\n}\n```\n### `ping` Request\n\n```json\n{\n    \"method\": \"ping\"\n}\n```\n\n## REST API\n\n| Pathname                  | Description           |\n|---------------------------|-----------------------|\n| GET `/health`             | Health check\n| GET `/metrics`            | Prometheus metrics\n| GET `/chain`              | Returns all available `chain`\n| GET `/traceId`            | Returns all `traceId` by `chain`\n| GET `/moduleHash`         | Returns all available `moduleHash`\n| GET `/moduleHashByChain`  | Returns all available `moduleHash` by `chain`\n| GET `/openapi`            | Returns api documentation in JSON format\n| GET `/messages`           | Returns the most recent messages\n| POST `/` {timestamp, signature, body}   | Webhook HTTP POST (Ed25519 signature)\n| POST `/` {\"message\": \"PING\"}            | Webhook HTTP POST Ping\n\n## Parameters\n### /messages\n| Parameter       | Type   | Description                              |\n|-----------------|--------|------------------------------------------|\n| `chain`         | string | Filter results by chain name, cannot be used with distinct\n| `moduleHash`    | string | Filter results by module hash\n| `limit`         | int    | Limit number of results shown with a maximum value of 50\n| `sort`          | string | Sort by asc (ascending) or desc (descending)\n| `distinct`      | bool   | If set to true, will return list of results distinct by chain.\n\n### Example Request\n```\n/messages?chain=value1\u0026moduleHash=value2\u0026limit=value3\u0026sort=value4\n```\n## WebSockets examples\n\n- [`Bun`](/examples/bun) - https://bun.sh/\n- [React Native](/examples/react-native) - https://expo.dev/\n- [HTML](/examples/html)\n- [HTTP POST requests](/examples/post-http)\n\n## Requirements\n\n- [Substreams Sink Webhook](https://github.com/pinax-network/substreams-sink-webhook)\n\n## Quickstart\n\n```bash\n$ bun install\n$ bun dev\n```\n\n## [`Bun` Binary Releases](https://github.com/pinax-network/substreams-sink-websockets/releases)\n\n\u003e Linux Only\n\n```\n$ wget https://github.com/pinax-network/substreams-sink-websockets/releases/download/v0.1.7/substreams-sink-websockets\n$ chmod +x ./substreams-sink-websockets\n```\n\n## `.env` Environment variables\n\n```env\n# required\nPUBLIC_KEY=\"\u003cEd25519 public key\u003e\"\n\n# optional\nPORT=3000\nSQLITE_FILENAME=db.sqlite\nHOSTNAME=0.0.0.0\nVERBOSE=true\n```\n\n## Help\n\n```bash\n$ substreams-sink-websockets --help\n\nUsage: substreams-sink-websockets [options]\n\nSubstreams Sink Websockets\n\nOptions:\n  --public-key \u003cstring\u003e          (required) Ed25519 public key (comma-separated for multiple public keys) (env: PUBLIC_KEY)\n  --port \u003cint\u003e                   Server listen on HTTP port (default: 3000, env: PORT)\n  --hostname \u003cstring\u003e            Server listen on HTTP hostname (default: \"0.0.0.0\", env: HOSTNAME)\n  --sqlite-filename \u003cstring\u003e     SQLite database filename (default: \"db.sqlite\", env: SQLITE_FILENAME)\n  --verbose \u003cboolean\u003e            Enable verbose logging (default: false, env: VERBOSE)\n  --recent-messages-limit \u003cint\u003e  Limit recent messages (default: 50, env: RECENT_MESSAGES_LIMIT)\n  -V, --version                  output the version number\n  -h, --help                     display help for command\n```\n\n## Docker environment\n\nPull from GitHub Container registry\n```bash\ndocker pull ghcr.io/pinax-network/substreams-sink-websockets:latest\n```\n\nBuild from source\n```bash\ndocker build -t substreams-sink-websockets .\n```\n\nRun with `.env` file\n```bash\ndocker run -it --rm --env-file .env ghcr.io/pinax-network/substreams-sink-websockets\n```\n\n## 📖 References\n\n- [**Substreams** documentation](https://substreams.streamingfast.io/)\n- [Bun WebSockets](https://bun.sh/docs/api/websockets)\n\n  Bun's latest v1.0 release includes WebSocket support (written in Zig)\n  https://bun.sh/docs/api/websockets\n\n  Under the hood, it uses uWebSockets\n  https://github.com/uNetworking/uWebSockets","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpinax-network%2Fsubstreams-sink-websockets","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpinax-network%2Fsubstreams-sink-websockets","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpinax-network%2Fsubstreams-sink-websockets/lists"}