A client for connecting to the ShipGenius OMS API and running API requests.

Constructors

  • Parameters

    • api_key: string

      The API Key used to authenticate with the ShipGenius OMS server.

      You can create one through the Connected Apps portal.

    • server: ServerConnectionSpecification

      The server to connect to.

      Specify the environment key with a ServerEnvironment value to connect to a standard ShipGenius server

      Options are:

      • PRODUCTION = Actual server to purchase real labels
      • SANDBOX = Simple testing server with mock responses
      • DEVELOPMENT = More complex testing environment with semi-persistent data, but still no real money or labels

      Example

      { environment: ServerEnvironment.SANDBOX }
      

      Specify the url key with a URL to connect to a server at a custom URL.

      Useful if you need to connect indirectly, or to a staging server.

      Note

      URL should not contain a trailing slash or version number.

      URL should contain a protocol (i.e. http:// or https://).

      Example

      { url: "http://localhost:8000" }
      
    • Optionaloptions: ShipGeniusOmsClientConstructorOptions

      Optional extra options

      Additional options for the connection, such as the api version.

      None of these arguments are required.

      • Optionalversion?: `v${number}_${number}` | "latest"

        The version of the API to use.

        "latest"
        

    Returns ShipGeniusOmsClient

    import ShipGeniusOmsClient, { ServerEnvironment } from "@shipgenius/oms/client";

    const client = new ShipGeniusOmsClient(
    "f7f4d30c26ac2537e1db50da3dbd990a0261617f857c093d3a261b6b2d27685e",
    { environment: ServerEnvironment.SANDBOX },
    { version: "latest" }, // not necessary since "latest" is the default
    );

Properties

_url: string

The base URL requests are being sent to

_version: string

The version of the API to use

api_key: string

The user's App API Token

Accessors

Methods

  • Rate and ship packages in a single API call.

    Specify the services to consider for shipping and rules for how to select a service. The best service according to those rules will be selected for each shipment.

    Type Parameters

    Parameters

    • request: GraphqlList<DomesticRateAndShipInput>

      The shipment or shipments to purchase shipping labels for

    • service_spec: DomesticRateAndShipServiceSpecs

      The services to rate and rules for selecting the best

    • Optionaloptions: {
          as_data_url?: boolean;
          format?: Format;
          payment_id?: null | string;
          weight_unit?: WeightUnit;
      }

      Additional options for controlling the purchase and response

      • Optionalas_data_url?: boolean

        Whether to return the image as a base64 data: uri (true), or a base64 encoded bytes string (false)

        false
        
      • Optionalformat?: Format

        The format to return label images in.

        Only one format can be specified, as converting image formats is a larger-than-typical workload.

        If you need the image in multiple formats, you can run a custom query via runGraphql.

      • Optionalpayment_id?: null | string

        The id of the payment method to use for this batch.

        Set to null to use your default payment method.

        null
        
      • Optionalweight_unit?: WeightUnit

        The unit of measure to return weights in

        LBS

    Returns Promise<BulkDomesticLabelResponse<Format>>

    Information about the batch of purchased labels

  • Recover a lost label using the transaction if provided when the label was initially created.

    Note

    This mutation is designed for rare scenarios, such as a lost connection or unexpected crash during the label creation process.

    For further assistance, contact us at info@shipgeni.us

    • Recovery should only be used if there was a failure to receive a label calling from createLabel or rateAndShip
    • This recovery process is only valid within 24 hours of generating the label.

    Type Parameters

    Parameters

    • transaction_id: string

      The LabelCreationInput.transaction_id or DomesticRateAndShipInput.transaction_id used when creating the label you want to recover

    • Optionaloptions: {
          as_data_url?: boolean;
          format?: Format;
          payment_id?: null | string;
          weight_unit?: WeightUnit;
      }

      Additional options for configuring the recovery and the returned label

      • Optionalas_data_url?: boolean

        Whether to return the image as a base64 data: uri (true), or a base64 encoded bytes string (false)

        false
        
      • Optionalformat?: Format

        The format to return label images in.

        Only one format can be specified, as converting image formats is a larger-than-typical workload.

        If you need the image in multiple formats, you can run a custom query via runGraphql.

      • Optionalpayment_id?: null | string

        The payment ID to use to pay for the label if payment was not successful initially.

        The payment method will not be charged if the label was already paid for.

        If something goes wrong and you get double-charged for a label, contact info@shipgeni.us as soon as possible to resolve the issue.

      • Optionalweight_unit?: WeightUnit

        The unit of measure to return weights in

        LBS

    Returns Promise<DomesticLabel<Format>>

    the recovered label