shipstation_sdk¶
ShipStation API SDK.
Submodules¶
Classes¶
A class wrapping ShipStation API v2 interaction. |
Package Contents¶
- class shipstation_sdk.ShipStationClient(api_key: str, base_url: str = 'https://api.shipstation.com', timeout: float = 60.0)[source]¶
A class wrapping ShipStation API v2 interaction.
- make_request(method: str, path: str, params: dict[str, Any] | None = None, json: dict[str, Any] | None = None) niquests.Response[source]¶
Make a request to ShipStation, retrying when rate-limited.
Retries up to
RETRY_ATTEMPTStotal attempts on HTTP 429, sleeping the response’sRetry-After(DEFAULT_RETRY_AFTER_SECONDSwhen absent).
- list_shipments(parameters: shipstation_sdk.parameters.ShipmentListParameters | None = None) shipstation_sdk.models.ShipmentsList[source]¶
Get a page of shipments.
- iter_shipments(parameters: shipstation_sdk.parameters.ShipmentListParameters | None = None) collections.abc.Iterator[shipstation_sdk.models.Shipment][source]¶
Iterate over every shipment matching the parameters, following pagination.
- get_shipment(shipment_id: str) shipstation_sdk.models.Shipment[source]¶
Get a specific shipment.
- get_shipment_by_external_id(external_shipment_id: str) shipstation_sdk.models.Shipment[source]¶
Get a specific shipment by the external shipment ID it was created with.
External shipment IDs are caller-defined and may contain URL metacharacters (e.g. marketplace IDs like
gid://...), so the path segment is escaped.
- list_carriers() shipstation_sdk.models.CarriersList[source]¶
Get the connected carrier accounts.
- list_tags() shipstation_sdk.models.TagsList[source]¶
Get the tags defined on the account.
- create_shipments(shipments: list[shipstation_sdk.models.ShipmentRequest]) shipstation_sdk.models.CreateShipmentsResponse[source]¶
Create shipments; each comes back with its id, or with the errors that stopped it.
A shipment ShipStation refuses does not fail the call: check
has_errorsand each shipment’serrors.
- update_shipment(shipment_id: str, shipment: shipstation_sdk.models.ShipmentRequest) shipstation_sdk.models.Shipment[source]¶
Update a shipment that has no label yet; fields left
Noneare left as they are.
- list_labels(parameters: shipstation_sdk.parameters.LabelListParameters | None = None) shipstation_sdk.models.LabelsList[source]¶
Get a page of labels.
- iter_labels(parameters: shipstation_sdk.parameters.LabelListParameters | None = None) collections.abc.Iterator[shipstation_sdk.models.Label][source]¶
Iterate over every label matching the parameters, following pagination.
- iter_labels_at(resource_url: str) collections.abc.Iterator[shipstation_sdk.models.Label][source]¶
Iterate over the labels a
label_created_v2webhook’sresource_urlnames.The URL is
https://api.shipstation.com/v2/labels?batch_id=.... Its query becomes list parameters, so the request goes to this client’s own host with its own key: a URL naming any other host or path is refused rather than sent the key.- Raises:
ValueError – If the URL is not a labels list on ShipStation’s API host.
- list_webhooks() list[shipstation_sdk.models.Webhook][source]¶
Get the account’s webhook subscriptions.
- create_webhook(*, name: str, event: str, url: str, headers: list[shipstation_sdk.models.WebhookHeader] | None = None, store_id: str | None = None) shipstation_sdk.models.Webhook[source]¶
Subscribe
urltoevent(such aslabel_created_v2).headersare sent with every call, which is how a listener tells ShipStation’s calls from anyone else’s.
- start_tracking(carrier_code: str, tracking_number: str, *, carrier_id: str | None = None) None[source]¶
Subscribe to a package’s tracking updates, which then arrive through
trackwebhooks.carrier_idnames which of the account’s connections to the carrier to track with.