Batch Request - UPS, FedEx, USPS Rates

Carrier: Batch Request
Action: UPS, FedEx, USPS Rates
Description: Example implementation for Batch Request UPS, FedEx, USPS Rates
{
  "batch": [
    {
      "request_id": "UPS Rates",
      "request": {
        "carrier": "UPS",
        "action": "GetAllRates",
        "params": {
          "key": "YOUR_UPS_API_KEY",
          "account_number": "YOUR_ACCOUNT_NUMBER",
          "username": "YOUR_USERNAME",
          "password": "YOUR_PASSWORD",
          "packages": [
            {
              "weight": 5,
              "length": 5,
              "width": 5,
              "height": 5
            }
          ],
          "customs": [],
          "shipper": "RocketShipIt",
          "ship_addr1": "123 Main St",
          "ship_city": "Whitehall",
          "ship_state": "MT",
          "ship_code": "59759",
          "ship_country": "US",
          "to_country": "US",
          "to_code": "90210",
          "weight_unit": "LBS",
          "pickup_type": "01",
          "customer_classification": "01",
          "length_unit": "IN",
          "packaging_type": "02"
        }
      }
    },
    {
      "request_id": "USPS Rates",
      "request": {
        "carrier": "USPS",
        "action": "GetAllRates",
        "params": {
          "username": "YOUR_USERNAME",
          "packages": [
            {
              "weight": 6
            }
          ],
          "ship_code": "59759",
          "to_code": "90210"
        }
      }
    },
    {
      "request_id": "FedEx Rates",
      "request": {
        "carrier": "FedEx",
        "action": "GetAllRates",
        "params": {
          "account_number": "YOUR_ACCOUNT_NUMBER",
          "meter_number": "YOUR_METER_NUMBER",
          "key": "YOUR_KEY",
          "password": "YOUR_PASSWORD",
          "packages": [
            {
              "weight": 2
            }
          ],
          "customs": [],
          "shipper": "RocketShipIt",
          "ship_addr1": "123 Main St",
          "ship_city": "Whitehall",
          "ship_state": "MT",
          "ship_code": "59759",
          "ship_country": "US",
          "to_country": "US",
          "to_code": "90210",
          "weight_unit": "LB",
          "packaging_type": "YOUR_PACKAGING",
          "dropoff_type": "REGULAR_PICKUP",
          "test": true,
          "negotiated_rates": true
        }
      }
    }
  ]
}

<?php
$rs = new RocketShipIt;
$response = $rs->request(
array (
  'batch' => 
  array (
    0 => 
    array (
      'request_id' => 'UPS Rates',
      'request' => 
      array (
        'carrier' => 'UPS',
        'action' => 'GetAllRates',
        'params' => 
        array (
          'key' => 'YOUR_UPS_API_KEY',
          'account_number' => 'YOUR_ACCOUNT_NUMBER',
          'username' => 'YOUR_USERNAME',
          'password' => 'YOUR_PASSWORD',
          'packages' => 
          array (
            0 => 
            array (
              'weight' => 5,
              'length' => 5,
              'width' => 5,
              'height' => 5,
            ),
          ),
          'customs' => 
          array (
          ),
          'shipper' => 'RocketShipIt',
          'ship_addr1' => '123 Main St',
          'ship_city' => 'Whitehall',
          'ship_state' => 'MT',
          'ship_code' => '59759',
          'ship_country' => 'US',
          'to_country' => 'US',
          'to_code' => '90210',
          'weight_unit' => 'LBS',
          'pickup_type' => '01',
          'customer_classification' => '01',
          'length_unit' => 'IN',
          'packaging_type' => '02',
        ),
      ),
    ),
    1 => 
    array (
      'request_id' => 'USPS Rates',
      'request' => 
      array (
        'carrier' => 'USPS',
        'action' => 'GetAllRates',
        'params' => 
        array (
          'username' => 'YOUR_USERNAME',
          'packages' => 
          array (
            0 => 
            array (
              'weight' => 6,
            ),
          ),
          'ship_code' => '59759',
          'to_code' => '90210',
        ),
      ),
    ),
    2 => 
    array (
      'request_id' => 'FedEx Rates',
      'request' => 
      array (
        'carrier' => 'FedEx',
        'action' => 'GetAllRates',
        'params' => 
        array (
          'account_number' => 'YOUR_ACCOUNT_NUMBER',
          'meter_number' => 'YOUR_METER_NUMBER',
          'key' => 'YOUR_KEY',
          'password' => 'YOUR_PASSWORD',
          'packages' => 
          array (
            0 => 
            array (
              'weight' => 2,
            ),
          ),
          'customs' => 
          array (
          ),
          'shipper' => 'RocketShipIt',
          'ship_addr1' => '123 Main St',
          'ship_city' => 'Whitehall',
          'ship_state' => 'MT',
          'ship_code' => '59759',
          'ship_country' => 'US',
          'to_country' => 'US',
          'to_code' => '90210',
          'weight_unit' => 'LB',
          'packaging_type' => 'YOUR_PACKAGING',
          'dropoff_type' => 'REGULAR_PICKUP',
          'test' => true,
          'negotiated_rates' => true,
        ),
      ),
    ),
  ),
)
);

rs.request(
  {'batch': [{'request': {'action': 'GetAllRates',
                        'carrier': 'UPS',
                        'params': {'account_number': 'YOUR_ACCOUNT_NUMBER',
                                   'customer_classification': '01',
                                   'customs': [],
                                   'key': 'YOUR_UPS_API_KEY',
                                   'length_unit': 'IN',
                                   'packages': [{'height': 5,
                                                 'length': 5,
                                                 'weight': 5,
                                                 'width': 5}],
                                   'packaging_type': '02',
                                   'password': 'YOUR_PASSWORD',
                                   'pickup_type': '01',
                                   'ship_addr1': '123 Main St',
                                   'ship_city': 'Whitehall',
                                   'ship_code': '59759',
                                   'ship_country': 'US',
                                   'ship_state': 'MT',
                                   'shipper': 'RocketShipIt',
                                   'to_code': '90210',
                                   'to_country': 'US',
                                   'username': 'YOUR_USERNAME',
                                   'weight_unit': 'LBS'}},
            'request_id': 'UPS Rates'},
           {'request': {'action': 'GetAllRates',
                        'carrier': 'USPS',
                        'params': {'packages': [{'weight': 6}],
                                   'ship_code': '59759',
                                   'to_code': '90210',
                                   'username': 'YOUR_USERNAME'}},
            'request_id': 'USPS Rates'},
           {'request': {'action': 'GetAllRates',
                        'carrier': 'FedEx',
                        'params': {'account_number': 'YOUR_ACCOUNT_NUMBER',
                                   'customs': [],
                                   'dropoff_type': 'REGULAR_PICKUP',
                                   'key': 'YOUR_KEY',
                                   'meter_number': 'YOUR_METER_NUMBER',
                                   'negotiated_rates': True,
                                   'packages': [{'weight': 2}],
                                   'packaging_type': 'YOUR_PACKAGING',
                                   'password': 'YOUR_PASSWORD',
                                   'ship_addr1': '123 Main St',
                                   'ship_city': 'Whitehall',
                                   'ship_code': '59759',
                                   'ship_country': 'US',
                                   'ship_state': 'MT',
                                   'shipper': 'RocketShipIt',
                                   'test': True,
                                   'to_code': '90210',
                                   'to_country': 'US',
                                   'weight_unit': 'LB'}},
            'request_id': 'FedEx Rates'}]}

)

rs.request(
  {"batch"=>
  [{"request_id"=>"UPS Rates",
    "request"=>
     {"carrier"=>"UPS",
      "action"=>"GetAllRates",
      "params"=>
       {"key"=>"YOUR_UPS_API_KEY",
        "account_number"=>"YOUR_ACCOUNT_NUMBER",
        "username"=>"YOUR_USERNAME",
        "password"=>"YOUR_PASSWORD",
        "packages"=>[{"weight"=>5, "length"=>5, "width"=>5, "height"=>5}],
        "customs"=>[],
        "shipper"=>"RocketShipIt",
        "ship_addr1"=>"123 Main St",
        "ship_city"=>"Whitehall",
        "ship_state"=>"MT",
        "ship_code"=>"59759",
        "ship_country"=>"US",
        "to_country"=>"US",
        "to_code"=>"90210",
        "weight_unit"=>"LBS",
        "pickup_type"=>"01",
        "customer_classification"=>"01",
        "length_unit"=>"IN",
        "packaging_type"=>"02"}}},
   {"request_id"=>"USPS Rates",
    "request"=>
     {"carrier"=>"USPS",
      "action"=>"GetAllRates",
      "params"=>
       {"username"=>"YOUR_USERNAME",
        "packages"=>[{"weight"=>6}],
        "ship_code"=>"59759",
        "to_code"=>"90210"}}},
   {"request_id"=>"FedEx Rates",
    "request"=>
     {"carrier"=>"FedEx",
      "action"=>"GetAllRates",
      "params"=>
       {"account_number"=>"YOUR_ACCOUNT_NUMBER",
        "meter_number"=>"YOUR_METER_NUMBER",
        "key"=>"YOUR_KEY",
        "password"=>"YOUR_PASSWORD",
        "packages"=>[{"weight"=>2}],
        "customs"=>[],
        "shipper"=>"RocketShipIt",
        "ship_addr1"=>"123 Main St",
        "ship_city"=>"Whitehall",
        "ship_state"=>"MT",
        "ship_code"=>"59759",
        "ship_country"=>"US",
        "to_country"=>"US",
        "to_code"=>"90210",
        "weight_unit"=>"LB",
        "packaging_type"=>"YOUR_PACKAGING",
        "dropoff_type"=>"REGULAR_PICKUP",
        "test"=>true,
        "negotiated_rates"=>true}}}]}

)

rocketshipit.request(
  {
  "batch": [
    {
      "request_id": "UPS Rates",
      "request": {
        "carrier": "UPS",
        "action": "GetAllRates",
        "params": {
          "key": "YOUR_UPS_API_KEY",
          "account_number": "YOUR_ACCOUNT_NUMBER",
          "username": "YOUR_USERNAME",
          "password": "YOUR_PASSWORD",
          "packages": [
            {
              "weight": 5,
              "length": 5,
              "width": 5,
              "height": 5
            }
          ],
          "customs": [],
          "shipper": "RocketShipIt",
          "ship_addr1": "123 Main St",
          "ship_city": "Whitehall",
          "ship_state": "MT",
          "ship_code": "59759",
          "ship_country": "US",
          "to_country": "US",
          "to_code": "90210",
          "weight_unit": "LBS",
          "pickup_type": "01",
          "customer_classification": "01",
          "length_unit": "IN",
          "packaging_type": "02"
        }
      }
    },
    {
      "request_id": "USPS Rates",
      "request": {
        "carrier": "USPS",
        "action": "GetAllRates",
        "params": {
          "username": "YOUR_USERNAME",
          "packages": [
            {
              "weight": 6
            }
          ],
          "ship_code": "59759",
          "to_code": "90210"
        }
      }
    },
    {
      "request_id": "FedEx Rates",
      "request": {
        "carrier": "FedEx",
        "action": "GetAllRates",
        "params": {
          "account_number": "YOUR_ACCOUNT_NUMBER",
          "meter_number": "YOUR_METER_NUMBER",
          "key": "YOUR_KEY",
          "password": "YOUR_PASSWORD",
          "packages": [
            {
              "weight": 2
            }
          ],
          "customs": [],
          "shipper": "RocketShipIt",
          "ship_addr1": "123 Main St",
          "ship_city": "Whitehall",
          "ship_state": "MT",
          "ship_code": "59759",
          "ship_country": "US",
          "to_country": "US",
          "to_code": "90210",
          "weight_unit": "LB",
          "packaging_type": "YOUR_PACKAGING",
          "dropoff_type": "REGULAR_PICKUP",
          "test": true,
          "negotiated_rates": true
        }
      }
    }
  ]
}
)
← Back to All Examples