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.011h ago| #1 | #!/usr/bin/env bash |
| #2 | set -euo pipefail |
| #3 | |
| #4 | # shellcheck source=_response-markers.sh disable=SC1091 |
| #5 | source "$(dirname "$0")/_response-markers.sh" |
| #6 | |
| #7 | if [ "$#" -lt 2 ]; then |
| #8 | echo "Usage: opensea-post.sh <path> <json_body>" >&2 |
| #9 | echo "Example: opensea-post.sh /api/v2/listings/fulfillment_data '{\"listing\":{...}}'" >&2 |
| #10 | exit 1 |
| #11 | fi |
| #12 | |
| #13 | path="$1" |
| #14 | body="$2" |
| #15 | |
| #16 | if [[ "$path" != /* ]]; then |
| #17 | echo "opensea-post.sh: path must start with /" >&2 |
| #18 | exit 1 |
| #19 | fi |
| #20 | base="${OPENSEA_BASE_URL:-https://api.opensea.io}" |
| #21 | key="${OPENSEA_API_KEY:-}" |
| #22 | |
| #23 | if [ -z "$key" ]; then |
| #24 | echo "OPENSEA_API_KEY is required" >&2 |
| #25 | exit 1 |
| #26 | fi |
| #27 | |
| #28 | url="$base$path" |
| #29 | |
| #30 | tmp_body=$(mktemp) |
| #31 | trap 'rm -f "$tmp_body"' EXIT |
| #32 | |
| #33 | http_code=$(curl -sS --connect-timeout 10 --max-time 30 -X POST \ |
| #34 | -H "x-api-key: $key" \ |
| #35 | -H "User-Agent: opensea-skill/1.0" \ |
| #36 | -H "Content-Type: application/json" \ |
| #37 | -d "$body" \ |
| #38 | -w '%{http_code}' \ |
| #39 | -o "$tmp_body" \ |
| #40 | "$url") || { |
| #41 | echo "opensea-post.sh: curl transport error (exit $?)" >&2 |
| #42 | exit 1 |
| #43 | } |
| #44 | |
| #45 | if [[ "$http_code" =~ ^2 ]]; then |
| #46 | emit_response "$tmp_body" |
| #47 | exit 0 |
| #48 | fi |
| #49 | |
| #50 | echo "opensea-post.sh: HTTP $http_code error" >&2 |
| #51 | emit_response "$tmp_body" >&2 |
| #52 | exit 1 |
| #53 |