{"id":24559240,"url":"https://github.com/parcellab/shipping-ups","last_synced_at":"2025-03-16T19:41:41.109Z","repository":{"id":41942428,"uuid":"192072995","full_name":"parcelLab/shipping-ups","owner":"parcelLab","description":"Fork of UPS Node.js library used by tracking worker","archived":false,"fork":false,"pushed_at":"2022-11-22T21:24:31.000Z","size":203,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-01-23T06:15:58.460Z","etag":null,"topics":["team-backend"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/parcelLab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null}},"created_at":"2019-06-15T11:53:23.000Z","updated_at":"2024-11-26T15:18:05.000Z","dependencies_parsed_at":"2023-01-21T21:21:42.840Z","dependency_job_id":null,"html_url":"https://github.com/parcelLab/shipping-ups","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parcelLab%2Fshipping-ups","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parcelLab%2Fshipping-ups/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parcelLab%2Fshipping-ups/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parcelLab%2Fshipping-ups/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/parcelLab","download_url":"https://codeload.github.com/parcelLab/shipping-ups/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243922336,"owners_count":20369382,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["team-backend"],"created_at":"2025-01-23T06:16:01.252Z","updated_at":"2025-03-16T19:41:41.086Z","avatar_url":"https://github.com/parcelLab.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"#shipping-ups\n\n## Install\n\n`npm install shipping-ups`\n\n## Usage\n\n```js\n  var upsAPI = require('shipping-ups');\n\n  var ups = new upsAPI({\n    environment: 'sandbox', // or live\n    username: 'UPSUSERNAME',\n    password: 'UPSPASSWORD',\n    access_key: 'UPSACCESSTOKEN',\n    imperial: true // set to false for metric\n  });\n\n  var realWeight = ups.dimensionalWeight(weight, length, width, height);\n\n  ups.time_in_transit(..., function(err, res) {\n    ...\n  });\n\n  ups.address_validation(..., function(err, result) {\n    ...\n  });\n\n  ups.track(..., function(err, result) {\n    ...\n  });\n\n  ups.rates(..., function(err, result) {\n    ...\n  });\n\n  // Generate a Digest for a specific Rate\n  ups.confirm(..., function(err, result) {\n    ...\n  });\n\n  // Purchase the Label\n  ups.accept(..., function(err, result) {\n    ...\n  });\n\n  // Pickup Request\n  ups.pickup(..., function(err, result) {\n\n  });\n\n  // Pickup Rate Request\n  ups.pickup_rate(..., function(err, result) {\n\n  });\n\n  // Pickup Cancel Request\n  ups.cancel_pickup(..., function(err, result) {\n\n  });\n\n  // Void the Shipment\n  ups.void(..., function(err, result) {\n    ...\n  });\n```\n\n### Freight Methods\n\n```js\n  ups.freight_rate(..., function(err, res) {\n    ...\n  });\n\n  ups.freight_ship(..., function(err, res) {\n    ...\n  });\n\n  ups.freight_pickup(..., function(err, res) {\n    ...\n  });\n\n  ups.cancel_freight_pickup(..., function(err, res) {\n    ...\n  });\n```\n\n### new upsAPI(options)\n\nInitialize your API bindings\n\n```js\n  options = {\n    imperial: true, // for inches/lbs, false for metric cm/kgs\n    currency: 'USD',\n    environment: 'sandbox',\n    access_key: '',\n    username: '',\n    password: '',\n    pretty: false,\n    user_agent: 'uh-sem-blee, Co | typefoo',\n    debug: false\n  }\n```\n\n### dimensionalWeight(weight, length, width, height)\n\nReturns the real weight needing to be used for your package.\n\n`weight` The tare weight of your product\n\n`length` The longest side of your package\n\n`width` The width of your package\n\n`height` The height of your package\n\n### density(weight, length, width, height)\n\nGet the density of a package to be used for calculating freight class\n\n`weight` The tare weight of your product\n\n`length` The longest side of your package\n\n`width` The width of your package\n\n`height` The height of your package\n\n### Optional Options\n\nAll request below can have the following optional options passed in an object:\n\n`transaction_id` A reference number you can pass to the transaction. Is returned as TransactionReference.CustomerContext\n\n`extra_params` This object extends the request object that is passed to the XML parser. Use with caution, but can enable extended functionality not present in the current module.\n\n`use_ounces` This boolean option will allow you to substitute OZS instead of LBS or KGS in your request (Useful for rates that require less than a pound)\n\n### time_in_transit(data, [options,] callback)\n\nCalculate the time in transit for a shipment\n\n```js\n  data = {\n    from: {\n      city: 'Dover',\n      state_code: 'OH',\n      postal_code: '44622',\n      country_code: 'US'\n    },\n    to: {\n      city: 'Charlotte',\n      state_code: 'NC',\n      postal_code: '28205',\n      country_code: 'US'\n    },\n    weight: 10, // set imperial to false for KGS\n    pickup_date: 'YYYYMMDD',\n    total_packages: 1, // number of packages in shipment\n    value: 999999999.99, // Invoice value, set currency in options\n  }\n```\n\n### address_validation(data, [options,] callback)\n\nValidates an address\n\n```js\n  data = {\n    request_option: 3, // 1, 2, or 3 per UPS docs\n    // 1 - Address Validation\n    // 2 - Address Classification\n    // 3 - Address Validation and Address Classification.\n    name: 'Customer Name',\n    company: 'Company Name',\n    address_line_1: 'Address Line 1',\n    address_line_2: 'Address Line 2',\n    address_line_3: 'Address Line 3',\n    city: 'Dover',\n    state_code: 'OH',\n    postal_code: '44622',\n    country_code: 'US'\n  }\n```\n\n### track(tracking_number, [options,] callback)\n\nGet a shipment's tracking information with `tracking_number` as the ID\n\n```js\n  options = {\n    latest: true // default false, will get only the latest tracking info, otherwise retrieves history\n  }\n```\n\n### rates(data, [options,] callback)\n\nGet a list of shipping rates\n\n```js\n  data = {\n    pickup_type: 'daily_pickup', // optional, can be: 'daily_pickup', 'customer_counter', 'one_time_pickup', 'on_call_air', 'suggested_retail_rates', 'letter_center', 'air_service_center'\n    pickup_type_code: '02', // optional, overwrites pickup_type\n    customer_classification: '00', // optional, need more details about what this does\n    shipper: {\n      name: 'Type Foo',\n      shipper_number: 'SHIPPER_NUMBER', // optional, but recommended for accurate rating\n      phone_number: '', // optional\n      fax_number: '', // optional\n      email_address: '', // optional\n      tax_identification_number: '', // optional\n      address: {\n        address_line_1: '123 Fake Address',\n        city: 'Dover',\n        state_code: 'OH',\n        country_code: 'US',\n        postal_code: '44622'\n      }\n    },\n    ship_to: {\n      company_name: 'Company Name', // or person's name\n      attention_name: '', // optional\n      phone_number: '', // optional\n      fax_number: '', // optional\n      email_address: '', // optional\n      tax_identification_number: '', // optional\n      location_id: '', //optional, for specific locations\n      address: {\n        address_line_1: '3456 Fake Address', // optional\n        city: 'Charlotte', // optional\n        state_code: 'NC', // optional, required for negotiated rates\n        country_code: 'US',\n        postal_code: '28205',\n        residential: true // optional, can be useful for accurate rating\n      }\n    },\n    ship_from: { // optional, use if different from shipper address\n      company_name: 'Company Name', // or person's name\n      attention_name: 'Attention Name',\n      phone_number: '', // optional\n      tax_identification_number: '', // optional\n      address: {\n        address_line_1: '123 Fake Address',\n        city: 'Dover',\n        state_code: 'OH',\n        country_code: 'US',\n        postal_code: '44622'\n      }\n    },\n    sold_to: { // optional, The person or company who imports and pays any duties due on the current shipment, required if Invoice of NAFTA CO is requested\n      option: '01', // optional, applies to NAFTA CO form\n      company_name: 'Company Name', // or person's name\n      attention_name: 'Attention Name',\n      phone_number: '', // optional\n      tax_identification_number: '', // optional\n      address: {\n        address_line_1: '123 Fake Address',\n        city: 'Dover',\n        state_code: 'OH',\n        country_code: 'US',\n        postal_code: '44622'\n      }\n    },\n    service: '03' // optional, will rate this specific service.\n    services: [ // optional, you can specify which rates to look for -- performs multiple requests, so be careful not to do too many\n      '03'\n    ],\n    return_service: '9', // optional, will provide a UPS Return Service specification\n    packages: [\n      {\n        packaging_type: '02', // optional, packaging type code\n        weight: 10,\n        description: 'My Package', // optional\n        delivery_confirmation_type: 2, // optional, 1 or 2\n        insured_value: 1000.00, // optional, 2 decimals\n        dimensions: { // optional, integers: 0-108 for imperial, 0-270 for metric\n          length: 12,\n          width: 12,\n          height: 24\n        }\n      }\n    ]\n  }\n\n  options = {\n    negotiated_rates: true // Optional, but if truthy then the NegotiatedRatesIndicator will always be placed (even without state/province code). Useful for countries without provinces.\n  }\n```\n\n### confirm(data, [options,] callback)\n\nPick a shipping rate\n\n```js\n  data = {\n    service_code: '03', // required for selected rate\n    return_service: '9', // optional, will provide a UPS Return Service specification\n    saturday_delivery: true, // optional, will indicate Saturday Delivery\n    pickup_type: 'daily_pickup', // optional, can be: 'daily_pickup', 'customer_counter', 'one_time_pickup', 'on_call_air', 'suggested_retail_rates', 'letter_center', 'air_service_center'\n    pickup_type_code: '02', // optional, overwrites pickup_type\n    customer_classification: '00', // optional, need more details about what this does\n    label_type: 'EPL', // optional, will default to 'GIF'\n    shipper: {\n      name: 'Type Foo',\n      shipper_number: 'SHIPPER_NUMBER', // optional, but recommended for accurate rating\n      phone_number: '', // optional\n      fax_number: '', // optional\n      email_address: '', // optional\n      tax_identification_number: '', // optional\n      address: {\n        address_line_1: '123 Fake Address',\n        city: 'Dover',\n        state_code: 'OH',\n        country_code: 'US',\n        postal_code: '44622'\n      }\n    },\n    ship_to: {\n      company_name: 'Company Name', // or person's name\n      attention_name: '', // optional\n      phone_number: '', // optional\n      fax_number: '', // optional\n      email_address: '', // optional\n      tax_identification_number: '', // optional\n      location_id: '', //optional, for specific locations\n      address: {\n        address_line_1: '3456 Fake Address', // optional\n        city: 'Charlotte', // optional\n        state_code: 'NC', // optional, required for negotiated rates\n        country_code: 'US',\n        postal_code: '28205',\n        residential: true // optional, can be useful for accurate rating\n      }\n    },\n    ship_from: { // optional, use if different from shipper address\n      company_name: 'Company Name', // or person's name\n      attention_name: 'Attention Name',\n      phone_number: '', // optional\n      tax_identification_number: '', // optional\n      address: {\n        address_line_1: '123 Fake Address',\n        city: 'Dover',\n        state_code: 'OH',\n        country_code: 'US',\n        postal_code: '44622'\n      }\n    },\n    sold_to: { // optional, The person or company who imports and pays any duties due on the current shipment, required if Invoice of NAFTA CO is requested\n      option: '01', // optional, applies to NAFTA CO form\n      company_name: 'Company Name', // or person's name\n      attention_name: 'Attention Name',\n      phone_number: '', // optional\n      tax_identification_number: '', // optional\n      address: {\n        address_line_1: '123 Fake Address',\n        city: 'Dover',\n        state_code: 'OH',\n        country_code: 'US',\n        postal_code: '44622'\n      }\n    },\n    packages: [ // at least one package is required\n      {\n        packaging_type: '02', // optional, packaging type code\n        weight: 10,\n        description: 'My Package', // optional\n        delivery_confirmation_type: 2, // optional, 1 or 2\n        insured_value: 1000.00, // optional, 2 decimals\n        dimensions: { // optional, integers: 0-108 for imperial, 0-270 for metric\n          length: 12,\n          width: 12,\n          height: 24\n        },\n        reference_number: 'ABC123' // optional\n        reference_number: { // optional, object format code/value keypair\n          code: 'PM',\n          value: 'ABC123'\n        },\n        reference_number: [ // optional, array format, can be strings or objects in code/value keypair format\n          'ABC123',\n          'WWWABC123'\n        ]\n      }\n    ]\n  }\n\n  options = {\n    negotiated_rates: true // See rates options.\n  }\n```\n\n### accept(shipment_digest, [options,] callback)\n\nPurchase a shipping label and tracking number\n\n```js\n  shipment_digest = 'SHIPMENTDIGEST'; // big data string\n```\n\n### pickup(pickup_creation_data, callback)\n\n```js\n  ups.pickup({\n    rate_pickup_indicator: 'Y',\n    shipper_account: 'ABC123',\n    pickup_date: '20141223',\n    eariest_time_ready: '0800',\n    latest_time_ready: '1200',\n    pickup_address: {\n      company_name: 'Pat Stewart',\n      contact_name: 'Pat Stewart',\n      address_line_1: '2311 York Road',\n      city: 'Timonium',\n      state_code: 'MD',\n      postal_code: '21093',\n      country_code: 'US',\n      phone_number: '5555555555'\n    },\n    weight: 5.5,\n    pickup_piece: [\n      {\n        service_code: '003',\n        quantity: 1,\n        container_code: '01'\n      }\n    ],\n    payment_method: '01'\n  }, function(err, res) {\n    if(err) {\n      return console.log(util.inspect(err, {depth: null}));\n    }\n\n    console.log(util.inspect(res, {depth: null}));\n  });\n```\n\n### pickup_rate(pickup_rate_data, callback)\n\nTBD\n\n### cancel_pickup(pickup_cancel_data, callback)\n\nTBD\n\n### void(data, [options,] callback)\n\n```js\n  data = '1ZTRACKINGNUMBER';\n```\n\nOR\n\n```js\n  data = {\n    shipment_identification_number: '1ZSHIPMENTIDNUMBER',\n    tracking_numbers: ['1ZTRACKINGNUMBER', '1ZTRACKINGNUMBER'] // optional\n  }\n```\n\nVoid a previously created order\n\n### freight_rate(data, [options,] callback)\n\nCall the Freight Rating API\n\nThese are example fields which cover the basic required fields. More should be added to cover all the features of the api.\n\n```js\n  ups.freight_rate({\n    ship_from: {\n      name: 'Test My Company',\n      address: {\n        address_line_1: '1234 Test Name Rd',\n        city: 'Charlotte',\n        state_code: 'NC',\n        postal_code: '28262',\n        country_code: 'US'\n      }\n    },\n    ship_to: {\n      name: 'John Doe',\n      address: {\n        address_line_1: '4567 Another Road Ct',\n        city: 'Dover',\n        state_code: 'OH',\n        postal_code: '44622',\n        country_code: 'US'\n      }\n    },\n    payer: {\n      name: 'Ron Rosef',\n      address: {\n        address_line_1: '867 Five Three Oh Nine',\n        city: 'Charlotte',\n        state_code: 'NC',\n        postal_code: '28262',\n        country_code: 'US'\n      },\n      shipper_number: 'ABC123'\n    },\n    billing_option: '10',\n    service_code: '308',\n    handling_unit_one: {\n      quantity: '20',\n      code: 'PLT'\n    },\n    commodity: {\n      description: 'A huge bag of something',\n      weight: '750',\n      number_of_pieces: '45',\n      packaging_type: 'BAG',\n      freight_class: '60'\n    }\n  }, function(err, res) {\n    if(err) {\n      return console.log(err);\n    }\n\n    console.log(util.inspect(res, {depth: null}));\n  });\n```\n\n### freight_ship(data, [options,] callback)\n\n```js\n  ups.freight_ship({\n    request_option: 1, // optional, 1 for ground, 2 for air\n    customer_context: 'Add description', // optional\n    shipment_shipper_number: '222006',\n    ship_from: {\n      name: 'Pat Stewart',\n      address: {\n        address_line_1: '2311 York Road',\n        city: 'Timonium',\n        state_code: 'MD',\n        postal_code: '21093',\n        country_code: 'US'\n      },\n      attention_name: 'String',\n      phone_number: '5555555555',\n      tax_identification_number: '1234567890'\n    },\n    ship_to: {\n      name: 'Consignee Test 1',\n      address: {\n        address_line_1: '2010 Warsaw Road',\n        city: 'Roswell',\n        state_code: 'GA',\n        postal_code: '30076',\n        country_code: 'US'\n      },\n      attention_name: 'String',\n      phone_number: '5555554444',\n      email_address: 'test2@test.com'\n    },\n    payer: {\n      name: 'Superman',\n      address: {\n        address_line_1: '2010 Warsaw Road',\n        city: 'Roswell',\n        state_code: 'GA',\n        postal_code: '30076',\n        country_code: 'US'\n      },\n      shipper_number: '00613270'\n    },\n    billing_option: '10',\n    service_code: '308',\n    handling_unit_one: {\n      quantity: '16',\n      code: 'PLT'\n    },\n    commodity: {\n      id: '22',\n      description: 'BUGS',\n      weight: '511.25',\n      number_of_pieces: '1',\n      packaging_type: 'PLT',\n      freight_class: '60',\n      nmfc_commodity_code: '566',\n      dimensions: {\n        length: 1.25,\n        width: 1.2,\n        height: 5\n      }\n      //nmfc_prime_code: '116030',\n      //nmfc_sub_code: '1'\n    }\n  }, function(err, res) {\n    if(err) {\n      return console.log(util.inspect(err, {depth: null}));\n    }\n\n    console.log(util.inspect(res, {depth: null}));\n  });\n```\n\n### freight_pickup(data, [options,] callback)\n\nTBD\n\n### cancel_freight_pickup(data, [options,] callback)\n\nTBD\n\nSee `example/index.js` for a working sample.\n\n## License\n\n(The MIT License)\n\nCopyright 2017 uh-sem-blee, Co. All rights reserved.\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparcellab%2Fshipping-ups","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fparcellab%2Fshipping-ups","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparcellab%2Fshipping-ups/lists"}