360 Secure SkillHub
360 安全技能中心

Crossly API setup

说明 Crossly 卖家与买家两套 API 的选型、凭证形态与作用域、OAuth 授权码流程、分页、错误封套、幂等键与限流处理,并给出 TypeScript、Python 与 curl 的调用示例。

分类:开发
crossly
热度 9.13
最近更新 2026-11-30 11:06:05

安装

发给 Agent
帮我安装这个技能:npx secure-skills-cli add crossly/crossly-api-setup
兼容性
通用兼容
联网要求
需要联网
数据出网
必须出网
Metadata
name
crossly-api-setup
description
Set up a Crossly (crossly.net) API integration. Pick the seller API or the buyer API, the matching client (@crossly/sdk, @crossly/buyer-sdk, Python crossly, plain HTTP) and the right credential (crossly_pat_ personal access token, OAuth access token, crossly_pk_ publishable key), then handle base URLs, scopes, pagination, the error envelope, idempotency and rate limits. Use when starting any code that calls the Crossly API, or when a Crossly call returns 401, 403 or 429.

Integrate the Crossly API

Crossly has two APIs on one host with two different principals. Decide which one before writing any code:

Seller API Buyer API
Acts on a seller's store: inventory, listings, crossposting, orders, sales, webhooks, automations a shopper's own cart, orders, wishlists, offers, cashback
Paths /v1/* (e.g. GET /v1/listings) /v1/buyer/* (e.g. GET /v1/buyer/orders)
Spec https://crossly.net/openapi/seller.json https://crossly.net/openapi/buyer.json
Credential a personal access token, or an OAuth access token with seller scopes (<domain>:<read|write>) an OAuth access token with buyer:* scopes only. There is no buyer PAT
TypeScript @crossly/sdk @crossly/buyer-sdk
Python crossly (seller) crossly-buyer

The Python clients are generated from the specs and live at https://github.com/crossly-dev/crossly-python. They are not on PyPI yet: install from GitHub with pip install "git+https://github.com/crossly-dev/crossly-python#subdirectory=seller" (buyer: subdirectory=buyer); switch to pip install crossly / crossly-buyer once those names resolve.

A seller token is refused by every buyer endpoint and the reverse, even for the same Crossly account. A 401 on a call that looks right usually means the other API's token.

Setup

  1. Create a free Crossly account: https://crossly.net/register
  2. Create a personal access token at https://crossly.net/settings/api/tokens/new (guide: https://crossly.net/guides/personal-access-tokens). Use a crossly_pat_test_ token against the sandbox while building.
  3. Export it as CROSSLY_PAT and send it as Authorization: Bearer $CROSSLY_PAT to https://crossly.net/api/v1/*. Full docs: https://crossly.net/docs

Base URLs and environments

  • Production: https://crossly.net/api + the spec path, e.g. https://crossly.net/api/v1/me.
  • Sandbox: https://sandbox.crossly.net/api (a separate account, seeded data, Stripe test mode).
  • The environment word in a credential is enforced: crossly_pat_live_… works only on crossly.net and crossly_pat_test_… only in the sandbox. The wrong one is 401 credential_environment_mismatch. Every response names its environment in the Crossly-Environment header.

Credentials

From https://crossly.net/docs/api-authentication:

Credential Shape Where it may be used
Personal access token (PAT) crossly_pat_<live|test>_<8 hex prefix>_<32 char secret> Server-side only: your scripts, CI, agents. Acts as the user who minted it, with the scopes ticked. Never in a browser bundle
OAuth access token a JWT (eyJ…) from https://crossly.net/atlas/oauth2/token, aud = https://crossly.net/api/v1, lives 8 h, refreshable A third-party app acting for a seller (seller scopes) or a shopper (buyer:* scopes). Stored server-side
Publishable key crossly_pk_<live|test>_<hex> Public web pages only (@crossly/embed). Reads one storefront's active listings and starts a checkout, nothing else
Experience key crossly_ek_<live|test>_… Creator back-ends only (worlds, items, game packages), from the key's IP allowlist
Webhook signing secret 64 hex characters, shown once Verifying deliveries. Never sent back to Crossly

The PAT's 8-hex prefix segment is safe to log; the secret segment never is. Read tokens from the environment (CROSSLY_PAT), never commit them, and never put a PAT or an OAuth token in frontend code: a browser only ever gets a crossly_pk_… key.

OAuth token shapes. OAuth access tokens from Atlas are JWTs (eyJ…). @crossly/sdk 0.3.0 accepts crossly_pat_…, a JWT access token, a legacy crossly_oat_… or a cbx_… token in the pat option; @crossly/buyer-sdk 0.2.0 accepts a JWT or a legacy crossly_oat_… and refuses crossly_pat_… on purpose. Upgrade older SDK versions: 0.2.0 / 0.1.0 refused JWTs in the constructor.

First call

Seller, TypeScript (npm install @crossly/sdk):

import { createClient, CrosslyAPIError } from '@crossly/sdk';

const crossly = createClient({ pat: process.env.CROSSLY_PAT! }); // crossly_pat_… or an OAuth JWT
const me = await crossly.profile.me();      // GET /v1/me: who you are, the PAT's scopes, account state
const page = await crossly.listings.list({ page: 1, limit: 100, status: 'active' });

The SDK picks the base URL from the token (_test_ → https://sandbox.crossly.net/api); override with baseUrl. On a multi-store account pass storefrontId to createClient (or per request) to send X-Storefront-Id; without it calls act on the default store (see crossly-team-stores).

Seller, Python (installed as above):

import os
import crossly
from crossly.api import listings_api

config = crossly.Configuration(access_token=os.environ["CROSSLY_TOKEN"])  # crossly_pat_…
with crossly.ApiClient(config) as client:
    page = listings_api.ListingsApi(client).list_listings(page=1, limit=25)
    for item in page.data:
        print(item.id, item.title, item.status)

Plain HTTP:

curl -sS https://crossly.net/api/v1/me -H "Authorization: Bearer $CROSSLY_PAT"

Buyer, TypeScript (npm install @crossly/buyer-sdk): createBuyerClient({ token }), then crossly.cart.get(), crossly.orders.list(), crossly.offers.make(…). It refuses a crossly_pat_ token at construction on purpose. Buyer money is always integer cents (amountCents, totalCents), and paying normally happens on Crossly with the shopper present. The one exception is buyer:checkout:write, which completes a purchase with a saved card only up to a spending limit the shopper sets on that key and only if they switch it on (see crossly-buyer-api).

Scopes

Scopes are checked per endpoint. Use least privilege:

  • a crossposter: inventory:read + listings:write
  • fulfilment or shipping: orders:read + fulfillment:write (orders:write also refunds and cancels)
  • reporting: sales:read, analytics:read
  • webhooks: webhooks:read, webhooks:write

* is only for your own whole-store agent. Third-party apps can never request *, billing:write, team:read, team:manage, payouts:write, funding:write, funding:approve, apps:read, apps:write or the per-game key scopes, and the world*/session:handoff first-party scopes are reserved for Crossly's own apps. inbox:* covers messages and offers; messages:* covers messages only. The full list is at https://crossly.net/docs/api-scopes and GET /v1/pat/scopes.

OAuth apps (third-party integrations)

Issuer https://crossly.net/atlas; discovery at https://crossly.net/atlas/.well-known/openid-configuration. Authorization code flow, PKCE S256 required.

  1. Send the user to https://crossly.net/atlas/oauth2/authorize with response_type=code, client_id, redirect_uri, resource=https://crossly.net/api/v1, a scope that includes openid (add offline_access for a refresh token), state, code_challenge, code_challenge_method=S256.
  2. Exchange the code at POST https://crossly.net/atlas/oauth2/token with grant_type=authorization_code, code, code_verifier, redirect_uri, resource. A confidential app authenticates with HTTP Basic; a public app sends only client_id.
  3. Refresh with grant_type=refresh_token. Refresh tokens rotate: always store the new one, and never refresh the same token from two processes.
  4. Revoke at https://crossly.net/atlas/oauth2/revoke.

Register apps under Settings → API & webhooks → OAuth apps. Registration, consent, review, per-app webhooks and app-managed listings are in the crossly-oauth-apps skill.

Responses you must handle

The full rules (both paging styles, every common error code, idempotency details, quotas, deprecation headers) are in crossly-api-conventions. The short version:

  • Lists return { data: [...], pagination: { page, limit, total?, totalPages? } }. page is 1-based; limit defaults to 25, max 100. Many lists omit total: stop when data.length < limit. Newer lists page by cursor (pagination.nextCursor, null on the last page).
  • Errors: every 4xx and 5xx is { "error": { "code", "message", "details"? }, "correlationId"? }. Branch on error.code (stable), show message, and log correlationId (quote it to Crossly support). The SDK throws CrosslyAPIError with .status, .code and .details.
  • 401 vs 403: 401 (missing_authorization, invalid_token, credential_environment_mismatch) means fix the credential. 403 insufficient_scope carries error.required and error.have: get a token with the missing scope instead of retrying. 503 atlas_unavailable is not a verdict on the token: retry after a short wait.
  • 429 (rate_limited or retry_storm): wait at least Retry-After seconds (the SDK error has retryAfterSeconds). Every response carries X-Quota-Limit, X-Quota-Remaining and X-Quota-Reset. Writes per minute per token depend on the plan (Free 15, Starter 60, Pro 240, Business 1,000, Scale 2,000); reads are 1,200 a minute. The SDK does not retry for you.
  • 402 (plan_limit_reached, overage_consent_required): nothing was written; tell the seller.
  • Idempotency: send Idempotency-Key: <key> on every POST or PATCH you might retry (SDK: { idempotencyKey } as the last argument). The first response is replayed for 24 h with Idempotent-Replayed: true; the same key with a different body is 422 idempotency_key_reused. Endpoints that spend money refuse a request without one (400 idempotency_key_required).

Money

Read the field name. Fields named …Cents are integer cents, and the buyer API is all cents. The seller listing price and the order and sale fields salePrice, platformFee and netProfit are dollars (decimal strings or JSON numbers depending on the endpoint), and POST /v1/listings takes data.price in dollars. Don't do arithmetic on money in floats: convert to integer cents at the edge.

Before you finish

  • The credential matches the API (seller or buyer) and lives only server-side; only crossly_pk_… appears in client code.
  • List calls page to the end, 429s honour Retry-After, and retried writes carry an Idempotency-Key.
  • Errors log error.code and correlationId.

Docs: https://crossly.net/docs · Scopes: https://crossly.net/docs/api-scopes · Errors: https://crossly.net/docs/api-errors · Rate limits: https://crossly.net/docs/api-rate-limits