repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
Mirrored from https://github.com/ProjectOpenSea/opensea-skill
stars
latest
clone command
git clone gitlawb://did:key:z6MkqRzA...RfoM/ProjectOpenSea-...git clone gitlawb://did:key:z6MkqRzA.../ProjectOpenSea-...fef93001Release v2.14.012h ago| #1 | #!/usr/bin/env bash |
| #2 | set -euo pipefail |
| #3 | |
| #4 | if [ "$#" -lt 1 ]; then |
| #5 | echo "Usage: opensea-stream-collection.sh <collection_slug|*>" >&2 |
| #6 | exit 1 |
| #7 | fi |
| #8 | |
| #9 | slug="$1" |
| #10 | |
| #11 | if [[ ! "$slug" =~ ^[a-zA-Z0-9*-]+$ ]]; then |
| #12 | echo "opensea-stream-collection.sh: slug must contain only alphanumeric characters, hyphens, and asterisk" >&2 |
| #13 | exit 1 |
| #14 | fi |
| #15 | |
| #16 | key="${OPENSEA_API_KEY:-}" |
| #17 | |
| #18 | if [ -z "$key" ]; then |
| #19 | echo "OPENSEA_API_KEY is required" >&2 |
| #20 | exit 1 |
| #21 | fi |
| #22 | |
| #23 | url="wss://stream-api.opensea.io/socket/websocket?token=${key}" |
| #24 | join="{\"topic\":\"collection:${slug}\",\"event\":\"phx_join\",\"payload\":{},\"ref\":1}" |
| #25 | heartbeat="{\"topic\":\"phoenix\",\"event\":\"heartbeat\",\"payload\":{},\"ref\":0}" |
| #26 | |
| #27 | if command -v websocat >/dev/null 2>&1; then |
| #28 | { |
| #29 | printf '%s\n' "$join" |
| #30 | while sleep 30; do |
| #31 | printf '%s\n' "$heartbeat" |
| #32 | done |
| #33 | } | websocat -t "$url" |
| #34 | exit 0 |
| #35 | fi |
| #36 | |
| #37 | if command -v wscat >/dev/null 2>&1; then |
| #38 | cat <<INFO |
| #39 | wscat is installed, but it does not auto-send join/heartbeat. |
| #40 | Run: wscat -c "$url" |
| #41 | Then send: |
| #42 | $join |
| #43 | And every ~30s: |
| #44 | $heartbeat |
| #45 | INFO |
| #46 | exit 0 |
| #47 | fi |
| #48 | |
| #49 | echo "Install websocat (preferred) or wscat to use the Stream API." >&2 |
| #50 | exit 1 |
| #51 |