最新消息:觉得本站不错的话 记得收藏哦 博客内某些功能仅供测试 讨论群:135931704 快养不起小站了 各位有闲钱就打赏下把 My Email weicots#gmail.com Please replace # with @

Usps 快递API文档 最新版

未分类 ajiang-tuzi 10685浏览

Introduction to Web Tools

This document contains a Reference Guide to the USPS Tracking/Delivery Confirmation Label APIs. See the Developer’s Guide to learn the administrative process for gaining access to the Web Tools APIs as well as the basic mechanism for calling the APIs and processing the results. The Developer’s Guide also contains information on testing and trouble-shooting.

 

Note: The Request Parameter sections present the XML input tags for generating live requests along with the restrictions on the values allowed. An error message will be returned if an incorrect value is entered.? Also, be aware of the maximum character amounts allowed for some tags.? If the user enters more than those amounts, an error will not be generated. The Web Tool will simply pass in the characters up to the maximum amount allowed and disregard the rest.? This is important since the resulting value could prevent a correct response.

 

When building the XML request, pay particular attention to the order and case for tags. An error message will be returned if an incorrect value is entered.? Remember that all data and attribute values in this document are for illustration purposes and are to be replaced by your actual values. For instance, a line of sample code may be:

 

<TrackID> EJ123456780US </TrackID>

 

In this instance, you will replace “EJ123456780US” with the tracking ID for the package.

Before you get started:

For information on registering and getting started with Web Tools, please refer to the Step-By-Step guide found on the Technical Documentation section of the Web Tools page on usps.com/webtools.

Access to the USPS Tracking API is granted upon registration but the remaining APIs in this guide required additional access. Contact the Internet Customer Care Center at uspstechnicalsupport@mailps.custhelp.com to request access. Indicate “Specialty Tracking API Access” in the subject line and explain in the body of the email.

USPS Tracking API

Overview

The Track/Confirm Web Tool lets customers determine the delivery status of their Priority Mail, Express Mail, and Package Services (Standard Post, Bound Printed Matter, Library Mail, and Media Mail) packages with Delivery Confirmation.? It will also provide tracking data right from your web site, without making your customer go to the USPS web site.? Additionally, the Track/Confirm Web Tool can be appended to your Intranet, allowing, for example, a customer service representative to answer customer queries about the status of their shipments.? The Web Tool Server returns tracking and/or delivery confirmation information for packages requested by the client.? The Track/Confirm Web Tool limits the data requested to ten (10) packages per transaction.

Note: The data returned by the Track/Confirm Web Tool is intended for display only.? The content or sequence of the string data returned by the Web Tool may change.? Consequently, if you desire to apply any kind of logic against the tracking data, then you will need to use the Track/Confirm Fields Web Tool.

 

API Signature

Scheme Host Path API XML
http:// stg-production.shippingapis.com /ShippingAPI.dll ?API=TrackV2 &XML=(see below)
http:// production.shippingapis.com /ShippingAPI.dll ?API=TrackV2 &XML=(see below)

 

Note: The “stg-production.shippingapis.com” signature host is for testing purposes. If you experience any issues connecting to this test server, please contact our helpdesk at uspstechnicalsupport@mailps.custhelp.com.

Request Description

Tag Name Occurs Description Type
TrackRequest required (group)
TrackRequest / @USERID required This attribute specifies your Web Tools ID. See the Developer’s Guide for information on obtaining your USERID.

For Example:

<TrackRequest USERID=”yourID”>

string
TrackRequest / TrackID required Must be alphanumeric characters.

For example:

<TrackID ID=”EJ123456780US”>

</TrackID>

string

 

Sample Request and Response

Test XML Request:http://production.shippingapis.com/ShippingAPI.dll?API=TrackV2&XML=<?xml version=”1.0″ encoding=”UTF-8″ ?>

<TrackRequest USERID=”xxxxxxxx”>

<TrackID ID=”EJ123456780US”></TrackID>

<TrackID ID=”EJ123456781US”></TrackID>

<TrackID ID=”12345″></TrackID>

</TrackRequest>

?

Test XML Response:

<TrackResponse>

<TrackInfo ID=”E123456780US”>

<TrackSummary> Your item was delivered at 6:50 am on February 6 in BARTOW FL 33830.</TrackSummary>

<TrackDetail>February 6 6:49 am NOTICE LEFT BARTOW FL 33830</TrackDetail>

<TrackDetail>February 6 6:48 am ARRIVAL AT UNIT BARTOW FL 33830</TrackDetail>

<TrackDetail>February 6 3:49 am ARRIVAL AT UNIT LAKELAND FL 33805</TrackDetail>

<TrackDetail>February 5 7:28 pm ENROUTE 33699</TrackDetail>

<TrackDetail>February 5 7:18 pm ACCEPT OR PICKUP 33699</TrackDetail>

</TrackInfo>

<TrackInfo ID=”E123456781US”>

<TrackSummary There is no record of that mail item. If it was mailed recently, It may not yet be tracked. Please try again later. </TrackSummary>

</TrackInfo>

<TrackInfo ID=”12345″>

<TrackSummary> That’s not a valid number. Please check to make sure you entered it correctly.</TrackSummary>

</TrackInfo>

</TrackResponse>

?

Track/Confirm Fields API

The Track/Confirm Fields request is identical to the Track/Confirm request except for the request name and the return information.? Data returned still contains the detail and summary information, but this information is broken down into fields instead of having only one line of text.? Up to 10 tracking IDs may be contained in each request input to the Web Tool server.

API Signature

Scheme Host Path API XML
http:// stg-production.shippingapis.com /ShippingAPI.dll ?API=TrackV2 &XML=(see below)
http:// production.shippingapis.com /ShippingAPI.dll ?API=TrackV2 &XML=(see below)

 

Note: The “stg-production.shippingapis.com” signature host is for testing purposes. If you experience any issues connecting to this test server, please contact our helpdesk at uspstechnicalsupport@mailps.custhelp.com

Request Description

Tag Name Occurs Description Type
TrackFieldRequest required once (group)
TrackFieldRequest / @USERID required This attribute specifies your Web Tools ID. See the Developer’s Guide for information on obtaining your USERID.

For Example:

<TrackFieldRequest USERID=”yourID”>

string
TrackFieldRequest / Revision required This is for versioning of the API’s and for triggering response tags for future versions. In this API use a value of 1 to trigger new functionality.

For example:

<Revision>1</Revision>

integer
TrackFieldRequest / ClientIp optional User IP address. Required when TrackFieldRequest[Revision=’1′].

For Example:

<ClientIp>127.0.0.1</ClientIp>

string
TrackFieldRequest / SourceId optional Internal User Identification.? Required when TrackFieldRequest[Revision=’1′].

For Example:

<SourceId>XYZ Corp</SourceId>

String
TrackFieldRequest / TrackID required Package Tracking ID.? Must be alphanumeric characters.

For example:

<TrackID ID=”EJ123456780US”>

</TrackID>

string
TrackFieldRequest /TrackID /? DestinationZipCode optional 5 digit destination zip code.

For Example:

<DestinationZipCode>12345</DestinationZipCode>

string
TrackFieldRequest /TrackID /

MailingDate

optional Mailing date of package.? Format: YYYY-MM-DD

For Example:

<MailingDate>2010-01-01</MailingDate>

string

?

Sample Requests

Test XML Request:

<TrackFieldRequest USERID=” xxxxxxxx”><TrackID ID=”01805213907042762274″>

<DestinationZipCode>12345</DestinationZipCode>

<MailingDate>2010-01-01</MailingDate>

</TrackID>

</TrackFieldRequest>

 

Test XML Request(Revision = 1):

http://production.shippingapis.com/ShippingAPI.dll?API=TrackV2&XML=<?xml version=”1.0″ encoding=”UTF-8″ ?>

<TrackFieldRequest USERID=”xxxxxxxx”>

<Revision>1</Revision>

<ClientIp>127.0.0.1</ClientIp>

<SourceId>John Doe</SourceId>

<TrackID ID=”010850921250125054″>

<DestinationZipCode>12345</DestinationZipCode>

<MailingDate>2010-01-01</MailingDate>

</TrackID>

</TrackFieldRequest>

Response Description

Tag Name Occurs Description Type
TrackResponse required once (group)
TrackResponse / TrackInfo required (group)
TrackResponse / TrackInfo / @ID=”#######” required Package Tracking ID number. string
TrackResponse / TrackInfo / GuaranteedDeliveryDate optional Guaranteed Delivery Date – Global Express Mail only:? certain countries provide a guarantee delivery. string
TrackResponse / TrackInfo / TrackSummary required once Tracking Summary Information. (group)
TrackResponse / TrackInfo / TrackSummary / EventTime required The time of the event. string
TrackResponse / TrackInfo / TrackSummary /? EventDate required The date of the event. string
TrackResponse / TrackInfo / TrackSummary / Event required The event type (e.g., Enroute). string
TrackResponse / TrackInfo / TrackSummary / EventCity required The city where the event occurred. string
TrackResponse / TrackInfo / TrackSummary / EventState required The state where the event occurred. string
TrackResponse / TrackInfo / TrackSummary /? EventZIPCode required The ZIP Code of the event. string
TrackResponse / TrackInfo / TrackSummary / EventCountry optional The country where the event occurred. string
TrackResponse / TrackInfo / TrackSummary / FirmName optional The company name if delivered to a company. string
TrackResponse / TrackInfo / TrackSummary / Name optional The name of the persons signing for delivery (if available). string
TrackResponse / TrackInfo / TrackSummary /? AuthorizedAgent optional True/False field indicating the person signing as an Authorized Agent. string
TrackResponse / TrackInfo / TrackDetail required once Tracking Detail Information.? This group is repeatable. (group)
TrackResponse / TrackInfo / TrackDetail / EventTime required The time of the event. string
TrackResponse / TrackInfo / TrackDetail /? EventDate required The date of the event. string
TrackResponse / TrackInfo / TrackDetail / Event required The event type (e.g., Enroute). string
TrackResponse / TrackInfo /? TrackDetail / EventCity required The city where the event occurred. string
TrackResponse / TrackInfo / TrackDetail / EventState required The state where the event occurred. string
TrackResponse / TrackInfo / TrackDetail /? EventZIPCode required The ZIP Code of the event string
TrackResponse / TrackInfo / TrackDetail / EventCountry optional The country where the event occurred. string
TrackResponse / TrackInfo / TrackDetail / FirmName optional The company name if delivered to a company. string
TrackResponse / TrackInfo / TrackDetail / Name optional The name of the persons signing for delivery (if available). string
TrackResponse / TrackInfo / TrackDetail /? AuthorizedAgent optional True/False field indicating the person signing as an Authorized Agent. string

 

Response Description (Revision = 1)

Tag Name Occurs Description Type
TrackResponse required once (group)
TrackResponse / TrackInfo ID=”#######” required Package Tracking ID number. string
TrackResponse / TrackInfo /?AdditionalInfo optional Additional package information string
TrackResponse / TrackInfo /? ARCHDATA optional Internal data availability boolean
TrackResponse / TrackInfo /?ArchiveRestoreInfo optional Information regarding availability of Restore service function string
TrackResponse / TrackInfo /?AssociatedLabel optional Associated label String
TrackResponse / TrackInfo / CarrierRelease optional Indicates whether or not the mailer has authorized carrier release (T or F) string
TrackResponse / TrackInfo /? Class optional The class of mail. Example: Priority Mail 1-Day string
TrackResponse / TrackInfo /?ClassOfMailCode optional Class of mail code? Examples: PM, PME, PMEI string
TrackResponse / TrackInfo /?DeliveryNotificationDate optional Scheduled delivery date string
TrackResponse / TrackInfo /?DestinationCity optional The destination city string
TrackResponse / TrackInfo /?DestinationCountryCode optional The destination country code string
TrackResponse / TrackInfo /?DestinationState optional The destination state string
TrackResponse / TrackInfo /?DestinationZip optional The destination zip code string
TrackResponse / TrackInfo /?EditedLabelID Optional, only included in response for specific?SourceIDs Identifies edited or full barcode information to support numeric only input string
TrackResponse / TrackInfo /?EmailEnabled optional Signifies if Track and Confirm by Email service is enabled string
TrackResponse / TrackInfo /?ExpectedDeliveryDate optional Expected delivery date string
TrackResponse / TrackInfo /?ExpectedDeliveryTime optional Expected delivery time. Example: 2:00 PM string
TrackResponse / TrackInfo /?GuaranteedDeliveryDate optional Guaranteed Delivery Date – Global Express Mail only:? certain countries provide a guarantee delivery. Example: 04 June 2013, 3 Business Days string
TrackResponse / TrackInfo /?GuaranteedDeliveryTime optional Guaranteed Delivery Time – Global Express Mail only:? certain countries provide a guarantee delivery string
TrackResponse / TrackInfo /?GuaranteedDetails optional Messaging to identify Guarantee limits (e.g. Loss Only Guarantee” string
TrackResponse / TrackInfo /?KahalaIndicator optional Indicates if the shipment string
TrackResponse / TrackInfo /?MailTypeCode optional The mail type code string
TrackResponse / TrackInfo /?? MPDATE optional Internal date stamp in yyyy-mm-dd hh:mm:ss.xxxx format string
TrackResponse / TrackInfo /? MPSUFFIX optional Internal suffix integer
TrackResponse / TrackInfo /? OriginCity optional The origin city string
TrackResponse / TrackInfo /?OriginCountryCode optional The origin country code string
TrackResponse / TrackInfo /? OriginState optional The origin state string
TrackResponse / TrackInfo /? OriginZip optional The origin zip code string
TrackResponse / TrackInfo /? PodEnabled optional Signifies if Proof of Delivery service is enabled boolean
TrackResponse / TrackInfo /?PredictedDeliveryDate optional The predicted delivery date string
TrackResponse / TrackInfo /?PredictedDeliveryTime optional Predicted Delivery TimeExample: 3:00 PM (Or blank) string
TrackResponse / TrackInfo /? PDWStart optional Predicted Delivery Window start time in military format.Example: 1300 string
TrackResponse / TrackInfo /? PDWEnd optional Predicted Delivery Window end time in military format.Example: 1500 string
TrackResponse / TrackInfo /?RelatedRRID optional Related Return Receipt ID string
TrackResponse / TrackInfo /?RestoreEnabled optional Signifies if Restore tracking information service is enabled boolean
TrackResponse / TrackInfo /?RRAMenabled optional Signifies if RRAM service is enabled boolean
TrackResponse / TrackInfo /? RreEnabled optional Signifies if Return Receipt Electronic service is enabled boolean
TrackResponse / TrackInfo /? Service optional, repeating up to unbounded times Additional services purchased string
TrackResponse / TrackInfo /?ServiceTypeCode optional Service Type Code string
TrackResponse / TrackInfo /? Status optional Delivery status string
TrackResponse / TrackInfo /?StatusCategory optional Delivery status category string
TrackResponse / TrackInfo /?StatusSummary optional Detailed status summary string
TrackResponse / TrackInfo /? TABLECODE optional Internal table code string
TrackResponse / TrackInfo /?ValueofArticle Optional, only returned for specific?SourceIDs Declared value of the package contents. Example: $20.00 string
TrackResponse / TrackInfo /?TrackSummary optional Tracking Summary Information. (group)
TrackResponse / TrackInfo /?TrackSummary / EventTime optional The time of the event. string
TrackResponse / TrackInfo /?TrackSummary /? EventDate optional The date of the event. string
TrackResponse / TrackInfo /?TrackSummary / Event optional The event type (e.g., Enroute). string
TrackResponse / TrackInfo /?TrackSummary / EventCity optional The city where the event occurred. string
TrackResponse / TrackInfo /?TrackSummary / EventState optional The state where the event occurred. string
TrackResponse / TrackInfo /?TrackSummary /? EventZIPCode optional The ZIP Code of the event. string
TrackResponse / TrackInfo /?TrackSummary / EventCountry optional The country where the event occurred. string
TrackResponse / TrackInfo /?TrackSummary / FirmName optional The company name if delivered to a company. string
TrackResponse / TrackInfo /?TrackSummary / Name optional The name of the persons signing for delivery (if available). string
TrackResponse / TrackInfo /?TrackSummary /? AuthorizedAgent optional True/False field indicating the person signing as an Authorized Agent. boolean
TrackResponse / TrackInfo /?TrackSummary /? EventCode optional Event Code string
TrackResponse / TrackInfo /?TrackSummary /? ActionCode optional Action Code string
TrackResponse / TrackInfo /?TrackSummary /? ReasonCode optional Reason Code string
TrackResponse / TrackInfo /? TrackDetail optional Tracking Detail Information.? This group is repeatable. (group)
TrackResponse / TrackInfo /? TrackDetail / EventTime optional The time of the event. string
TrackResponse / TrackInfo /? TrackDetail /? EventDate optional The date of the event. string
TrackResponse / TrackInfo /? TrackDetail / Event optional The event type (e.g., Enroute). string
TrackResponse / TrackInfo /? TrackDetail / EventCity optional The city where the event occurred. string
TrackResponse / TrackInfo /? TrackDetail / EventState optional The state where the event occurred. string
TrackResponse / TrackInfo /? TrackDetail /? EventZIPCode optional The ZIP Code of the event string
TrackResponse / TrackInfo /? TrackDetail / EventCountry optional The country where the event occurred. string
TrackResponse / TrackInfo /? TrackDetail / FirmName optional The company name if delivered to a company. string
TrackResponse / TrackInfo /? TrackDetail / Name optional The name of the persons signing for delivery (if available). string
TrackResponse / TrackInfo /? TrackDetail /? AuthorizedAgent optional True/False field indicating the person signing as an Authorized Agent. boolean
TrackResponse / TrackInfo /? TrackDetail /? EventCode optional Event Code string
TrackResponse / TrackInfo /? TrackDetail /? ActionCode optional Action Code string
TrackResponse / TrackInfo /? TrackDetail /? ReasonCode optional Reason Code string

 

Sample Response

Test XML Response:<TrackResponse>

<TrackInfo ID=”01805213907042762274″>

<TrackSummary>

<EventTime>12:12 pm</EventTime>

<EventDate>May 21, 2001</EventDate>

<Event>DELIVERED</Event>

<EventCity>NEWTON</EventCity>

<EventState>IA</EventState>

<EventZIPCode>50208</EventZIPCode>

<EventCountry/>

<FirmName></FirmName>

<Name></Name>

<AuthorizedAgent></AuthorizedAgent>

</TrackSummary>

<TrackDetail>

<EventTime>9:24 pm</EventTime>

<EventDate>March 28, 2001</EventDate>

<Event>ENROUTE</Event>

<EventCity>DES MOINES</EventCity>

<EventState>IA</EventState>

<EventZIPCode>50395</EventZIPCode>

<EventCountry/>

<FirmName/>

<Name/>

<AuthorizedAgent/>

</TrackDetail>

<TrackDetail>

<EventTime>10:00 pm</EventTime>

<EventDate>March 27, 2001</EventDate>

<Event>ACCEPTANCE</Event>

<EventCity>BLAINE</EventCity>

<EventState>WA</EventState>

<EventZIPCode>98231</EventZIPCode>

<EventCountry/>

<FirmName/>

<Name/>

<AuthorizedAgent/>

</TrackDetail>

</TrackInfo>

</TrackResponse>

?

?

Test XML Response(Revision = 1):

<TrackResponse>

<TrackInfo ID=”9102969010383081813033″>

<Class>Package Services</Class>

<ClassOfMailCode>BP</ClassOfMailCode>

<DestinationCity>BEVERLY HILLS</DestinationCity>

<DestinationState>CA</DestinationState>

<DestinationZip>90210</DestinationZip>

<EmailEnabled>true</EmailEnabled>

<ExpectedDeliveryDate>March 9, 2012</ExpectedDeliveryDate>

<KahalaIndicator>false</KahalaIndicator>

<MailTypeCode>DM</MailTypeCode>

<MPDATE>2012-03-06 03:23:03.300056</MPDATE>

<MPSUFFIX>9006</MPSUFFIX>

<OriginCity>LAS VEGAS</OriginCity>

<OriginState>NV</OriginState>

<OriginZip>89121</OriginZip>

<PodEnabled>false</PodEnabled>

<RestoreEnabled>false</RestoreEnabled>

<RreEnabled>false</RreEnabled>

<Service>Delivery Confirmation<SUP>&#153;</SUP></Service>

<ServiceTypeCode>02</ServiceTypeCode>

<Status>Delivered</Status>

<StatusCategory>Delivered</StatusCategory>

<StatusSummary>Your item was delivered at 9:58 am on March 08, 2012 in BEVERLY HILLS, CA 90210.</StatusSummary>

<TABLECODE>T</TABLECODE>

<TrackSummary>

<EventTime>9:58 am</EventTime>

<EventDate>March 08, 2012</EventDate>

<Event>Delivered</Event>

<EventCity>BEVERLY HILLS</EventCity>

<EventState>CA</EventState>

<EventZIPCode>90210</EventZIPCode>

<EventCountry />

<FirmName />

<Name />

<AuthorizedAgent />

<EventCode>01</EventCode>

</TrackSummary>

<TrackDetail>

<EventTime>9:25 am</EventTime>

<EventDate>March 08, 2012</EventDate>

<Event>Out for Delivery</Event>

<EventCity>BEVERLY HILLS</EventCity>

<EventState>CA</EventState>

<EventZIPCode>90210</EventZIPCode>

<EventCountry />

<FirmName />

<Name />

<AuthorizedAgent />

<EventCode>OF</EventCode>

</TrackDetail>

<TrackDetail>

<EventTime>9:15 am</EventTime>

<EventDate>March 08, 2012</EventDate>

<Event>Sorting Complete</Event>

<EventCity>BEVERLY HILLS</EventCity>

<EventState>CA</EventState>

<EventZIPCode>90210</EventZIPCode>

<EventCountry />

<FirmName />

<Name />

<AuthorizedAgent />

<EventCode>PC</EventCode>

</TrackDetail>

<TrackDetail>

<EventTime>4:47 am</EventTime>

<EventDate>March 08, 2012</EventDate>

<Event>Arrival at Post Office</Event>

<EventCity>BEVERLY HILLS</EventCity>

<EventState>CA</EventState>

<EventZIPCode>90210</EventZIPCode>

<EventCountry />

<FirmName />

<Name />

<AuthorizedAgent />

<EventCode>07</EventCode>

</TrackDetail>

<TrackDetail>

<EventTime />

<EventDate>March 07, 2012</EventDate>

<Event>Depart USPS Sort Facility</Event>

<EventCity>BELL GARDENS</EventCity>

<EventState>CA</EventState>

<EventZIPCode>90201</EventZIPCode>

<EventCountry />

<FirmName />

<Name />

<AuthorizedAgent />

<EventCode>EF</EventCode>

</TrackDetail>

<TrackDetail>

<EventTime>3:17 am</EventTime>

<EventDate>March 07, 2012</EventDate>

<Event>Processed through USPS Sort Facility</Event>

<EventCity>BELL GARDENS</EventCity>

<EventState>CA</EventState>

<EventZIPCode>90201</EventZIPCode>

<EventCountry />

<FirmName />

<Name />

<AuthorizedAgent />

<EventCode>10</EventCode>

</TrackDetail>

<TrackDetail>

<EventTime>4:55 pm</EventTime>

<EventDate>March 06, 2012</EventDate>

<Event>Dispatched to Sort Facility</Event>

<EventCity>LAS VEGAS</EventCity>

<EventState>NV</EventState>

<EventZIPCode>89121</EventZIPCode>

<EventCountry />

<FirmName />

<Name />

<AuthorizedAgent />

<EventCode>SF</EventCode>

</TrackDetail>

<TrackDetail>

<EventTime>3:28 pm</EventTime>

<EventDate>March 06, 2012</EventDate>

<Event>Acceptance</Event>

<EventCity>LAS VEGAS</EventCity>

<EventState>NV</EventState>

<EventZIPCode>89121</EventZIPCode>

<EventCountry />

<FirmName />

<Name />

<AuthorizedAgent />

<EventCode>03</EventCode>

</TrackDetail>

<TrackDetail>

<EventTime />

<EventDate>March 06, 2012</EventDate>

<Event>Electronic Shipping Info Received</Event>

<EventCity />

<EventState />

<EventZIPCode />

<EventCountry />

<FirmName />

<Name />

<AuthorizedAgent />

<EventCode>MA</EventCode>

</TrackDetail>

</TrackInfo>

</TrackResponse>

?

?

Tracking Service APIs

Four service APIs are offered in conjunction with “Revision = 1” of the Track/Confirm Fields Web Tool: Track and Confirm by Email, Proof of Delivery, Return Receipt Electronic and Restore for tracking information.? The response data from Track/Confirm Fields request determines which services are available for a tracking ID.? Each request input to the Web Tool server for the tracking service APIs is limited to 1 tracking ID.

These APIs are restricted to USPS internal use only.

Track and Confirm by Email API

The Track and Confirm by Email API allows the customer to submit their email address to be notified of current or future tracking activity.

The table below presents the XML input tags for generating Live requests and the restrictions on the values allowed.? An error message will be returned if an incorrect value is entered.? Also, be aware of the maximum character amounts allowed for some tags.? If the user enters more than those amounts, an error will not be generated.? The Web Tool will simply pass in the characters up to the maximum amount allowed and disregard the rest.? This is important since the resulting value could prevent a correct response.

When building the XML request, pay particular attention to the order and case for tags.? An error message will be returned if an incorrect value is entered.? Remember that all data and attribute values in this document are for illustration purposes and are to be replaced by your actual values.? For instance, a line of sample code may be:

<TrackID> EJ123456780US </TrackID>

In this instance, you will replace “EJ123456780US” with the tracking ID for the package.

 

API Signature

Scheme Host Path API XML
http:// stg-production.shippingapis.com /ShippingAPI.dll ?API=PTSEmail &XML=(see below)
http:// production.shippingapis.com /ShippingAPI.dll ?API=PTSEmail &XML=(see below)

 

Note: The “stg-production.shippingapis.com” signature host is for testing purposes. If you experience any issues connecting to this test server, please contact our helpdesk at uspstechnicalsupport@mailps.custhelp.com

Request Description

Tag Name Occurs Description Type
PTSEmailRequest required once (group)
PTSEmailRequest / @USERID required This attribute specifies your Web Tools ID. See the Developer’s Guide for information on obtaining your USERID. string
PTSEmailRequest / TrackId required Must be alphanumeric characters.For example:

<TrackId>EJ123456780US</TrackId>

string
PTSEmailRequest / ClientIp optional User IP address.

For Example:

<ClientIp>127.0.0.1</ClientIp>

string
PTSEmailRequest / SourceId optional Internal User Identification.

For Example:

<SourceId>XYZ Corp</SourceId>

string
PTSEmailRequest / MpSuffix required MPSUFFIX value located in Track/Confirm Fields API response data. Unique to each TrackID.For Example: <MpSuffix>9402</MpSuffix> integer
PTSEmailRequest / MpDate required MPDATE value located in Track/Confirm Fields API response data. Unique to each TrackId.For Example:

<MpDate>2009-07-02 00:42:23.35744</MpDate>

string
PTSEmailRequest / RequestType required Enter a notification request type from the choices available.

“EC” – (Email Current) Email all activity to-date

“EN” – (Email New) Email all future tracking activity

“EB” – (Email Both) Email both activity to-date and future tracking activity

For Example:

<RequestType>EC</RequestType>

string
PTSEmailRequest / FirstName optional Recipient First Name.

For example: <FirstName>John</FirstName>

string
PTSEmailRequest / LastName optional Recipient Last Name.

For example: <LastName>Doe</LastName>

string
PTSEmailRequest / Email1 required once Complete valid e-mail address is required if tag is used.

For example: <Email1>cpapple@email.com</Email1>

string
PTSEmailRequest / Email2 optional Complete valid e-mail address is required if tag is used. string
PTSEmailRequest / Email3 optional Complete valid e-mail address is required if tag is used. string

Sample Request and Response

Test XML Request:

<PTSEmailRequest USERID=”xxx”><TrackId>01128882300763290532</TrackId >

<ClientIp>127.0.0.1</ClientIp>

<SourceId>XYZ Corp</SourceId>

<MpSuffix >9402</MpSuffix>

<MpDate >2009-07-02 00:42:23.35744</MpDate>

<RequestType >EN</RequestType>

<FirstName >John</FirstName>

<LastName >Doe</LastName>

<Email1> cpapple@email.com </Email1>

<Email2></Email2>

<Email3></Email3>

</PTSEmailRequest>

?

Test XML Response:

<PTSEMAILRESULT>

<ResultText>Your request for all activity to-date will be processed within four hours. Any future activity?? will be processed whenever there is new delivery related event activity.</ResultText>

<ReturnCode>0</ReturnCode>

</PTSEMAILRESULT>

 

?

Proof of Delivery API

Proof of Delivery is a letter that includes the recipient’s name and a copy of their signature.? The Proof of Delivery API allows the customer to request proof of delivery notification via email.

Proof of Delivery Request

The table below presents the XML input tags for generating Live requests and the restrictions on the values allowed.? An error message will be returned if an incorrect value is entered.? Also, be aware of the maximum character amounts allowed for some tags.? If the user enters more than those amounts, an error will not be generated.? The Web Tool will simply pass in the characters up to the maximum amount allowed and disregard the rest.? This is important since the resulting value could prevent a correct response.

When building the XML request, pay particular attention to the order and case for tags.? An error message will be returned if an incorrect value is entered.? Remember that all data and attribute values in this document are for illustration purposes and are to be replaced by your actual values.? For instance, a line of sample code may be:

 

<TrackID> EJ123456780US </TrackID>

In this instance, you will replace “EJ123456780US” with the tracking ID for the package.

API Signature

Scheme Host Path API XML
http:// stg-production.shippingapis.com /ShippingAPI.dll ?API=PTSPod &XML=(see below)
http:// production.shippingapis.com /ShippingAPI.dll ?API=PTSPod &XML=(see below)

 

Note: The “stg-production.shippingapis.com” signature host is for testing purposes. If you experience any issues connecting to this test server, please contact our helpdesk at uspstechnicalsupport@mailps.custhelp.com

?

Request Description

Tag Name Occurs Description Type
PTSPodRequest required once (group)
PTSPodRequest / @USERID required This attribute specifies your Web Tools ID. See the Developer’s Guide for information on obtaining your USERID. string
PTSPodRequest / TrackId required Must be alphanumeric characters.For example:

<TrackId>EJ123456780US</TrackId>

string
PTSPodRequest / ClientIp optional User IP address.

For Example:

<ClientIp>127.0.0.1</ClientIp>

string
PTSPodRequest / SourceId optional Internal User Identification.

For Example:

<SourceId>XYZ Corp</SourceId>

string
PTSPodRequest / MpSuffix required MPSUFFIX value located in Track/Confirm Fields API response data. Unique to each TrackId.For Example: <MpSuffix>9402</MpSuffix> integer
PTSPodRequest / MpDate required MPDATE value located in Track/Confirm Fields API response data. Unique to each TrackID.For Example:

<MpDate>2009-07-02 00:42:23.35744</MpDate>

string
PTSPodRequest / RequestType required Enter a notification request type from the choices available.

For Example:

<RequestType>Email</RequestType>

string
PTSPodRequest / FirstName required Recipient First Name.

For example: <FirstName>John</FirstName>

string
PTSPodRequest / LastName required Recipient Last Name.

For example: <LastName>Doe</LastName>

string
PTSPodRequest / Email1 optional Required when PTSPodRequest[RequestType=’Email’]

Complete valid e-mail address is required if tag is used.

 

For example: <Email1>cpapple@email.com</Email1>

string
PTSPodRequest / Email2 optional Complete valid e-mail address is required if tag is used. string
PTSPodRequest / Email3 optional Complete valid e-mail address is required if tag is used. string
PTSPodRequest / FaxNumber optional Deprecated.? “Fax” option no longer available. string
PTSPodRequest / AddressLine1 optional Deprecated.? “Mail” option no longer available. string
PTSPodRequest / AddressLine2 optional Deprecated.? “Mail” option no longer available. string
PTSPodRequest / City optional Deprecated.? “Mail” option no longer available. string
PTSPodRequest / State optional Deprecated.? “Mail” option no longer available. string
PTSPodRequest / Zip optional Deprecated.? “Mail” option no longer available. string
PTSPodRequest / VerifyAddress optional Deprecated.? “Mail” option no longer available. boolean
PTSPodRequest / TableCode required TableCode value located in Track/Confirm Fields API response data. Unique to each TrackID.For Example:

<TableCode>T</TableCode>

string

Sample Requests and Response

Test XML Request:

<PTSPodRequest USERID=”xxx”><TrackId>21010521297326074392</TrackId >

<ClientIp>127.0.0.1</ClientIp>

<SourceId>XYZ Corp</SourceId>

<MpSuffix >9402</MpSuffix>

<MpDate >2009-07-02 00:42:23.35744</MpDate>

<RequestType >Email</RequestType>

<FirstName >John</FirstName>

<LastName >Doe</LastName>

<Email1> cpapple@email.com </Email1>

<Email2></Email2>

<Email3></Email3>

<TableCode>T</TableCode>

</PTSPodRequest>

?

Test XML Response:

<PTSPODRESULT>

<ResultText>Your Proof of Delivery record is complete and will be processed shortly.</ResultText>

<ReturnCode>0</ReturnCode>

</PTSPODRESULT>

 

Return Receipt Electronic API

The Return Receipt Electronic API allows the customer to request a copy of the proof of delivery record via email.

Return Receipt Electronic Request

The table below presents the XML input tags for generating Live requests and the restrictions on the values allowed.? An error message will be returned if an incorrect value is entered.? Also, be aware of the maximum character amounts allowed for some tags.? If the user enters more than those amounts, an error will not be generated.? The Web Tool will simply pass in the characters up to the maximum amount allowed and disregard the rest.? This is important since the resulting value could prevent a correct response.

When building the XML request, pay particular attention to the order and case for tags.? An error message will be returned if an incorrect value is entered.? Remember that all data and attribute values in this document are for illustration purposes and are to be replaced by your actual values.? For instance, a line of sample code may be:

 

<TrackID> EJ123456780US </TrackID>

In this instance, you will replace “EJ123456780US” with the tracking ID for the package.

 

API Signature

Scheme Host Path API XML
http:// stg-production.shippingapis.com /ShippingAPI.dll ?API=PTSRre &XML=(see below)
http:// production.shippingapis.com /ShippingAPI.dll ?API=PTSRre &XML=(see below)

 

Note: The “stg-production.shippingapis.com” signature host is for testing purposes. If you experience any issues connecting to this test server, please contact our helpdesk at uspstechnicalsupport@mailps.custhelp.com

Request Description

Tag Name Occurs Description Type
PTSRreRequest required once (group)
PTSRreRequest / @USERID required This attribute specifies your Web Tools ID. See the Developer’s Guide for information on obtaining your USERID. string
PTSRreRequest / TrackId required Must be alphanumeric characters.For example:

<TrackId>EJ123456780US</TrackId>

string
PTSRreRequest / ClientIp optional User IP address.

For Example:

<ClientIp>127.0.0.1</ClientIp>

string
PTSRreRequest / SourceId optional Internal User Identification.

For Example:

<SourceId>XYZ Corp</SourceId>

string
PTSRreRequest / MpSuffix required MPSUFFIX value located in Track/Confirm Fields API response data. Unique to each TrackId.For Example: <MpSuffix>9402</MpSuffix> integer
PTSRreRequest / MpDate required MPDATE value located in Track/Confirm Fields API response data. Unique to each TrackID.For Example:

<MpDate>2009-07-02 00:42:23.35744</MpDate>

string
PTSRreRequest / FirstName required Recipient First Name.

For example: <FirstName>John</FirstName>

string
PTSRreRequest / LastName required Recipient Last Name.

For example: <LastName>Doe</LastName>

string
PTSRreRequest / Email1 required once Complete valid e-mail address is required if tag is used.

For example: <Email1>cpapple@email.com</Email1>

string
PTSRreRequest / Email2 optional Complete valid e-mail address is required if tag is used. string
PTSRreRequest / Email3 optional Complete valid e-mail address is required if tag is used. string
PTSRreRequest / TableCode required TableCode value located in Track/Confirm Fields API response data. Unique to each TrackID.For Example:

<TableCode>T</TableCode>

string

 

Sample Request and Response

Test XML Request:

<PTSRreRequest USERID=”xxx”><TrackId>05878510510001001318</TrackId >

<ClientIp>127.0.0.1</ClientIp>

<SourceId>XYZ Corp</SourceId>

<MpSuffix>9402</MpSuffix>

<MpDate>2009-07-02 00:42:23.35744</MpDate>

<FirstName>John</FirstName>

<LastName>Doe</LastName>

<Email1>cpapple@email.com</Email1>

<Email2></Email2>

<Email3></Email3>

<TableCode>T</TableCode>

</PTSRreRequest>

?

Test XML Response:

<PTSRRERESULT>

<ResultText> Your Proof of Delivery record is complete and will be processed shortly.</ResultText>

<ReturnCode>0</ReturnCode>

</PTSRRERESULT>

 

 

?

Restore API

The Restore API allows the customer to restore tracking information from the archives.

Restore Request

The table below presents the XML input tags for generating Live requests and the restrictions on the values allowed.? An error message will be returned if an incorrect value is entered.? Also, be aware of the maximum character amounts allowed for some tags.? If the user enters more than those amounts, an error will not be generated.? The Web Tool will simply pass in the characters up to the maximum amount allowed and disregard the rest.? This is important since the resulting value could prevent a correct response.

When building the XML request, pay particular attention to the order and case for tags.? An error message will be returned if an incorrect value is entered.? Remember that all data and attribute values in this document are for illustration purposes and are to be replaced by your actual values.? For instance, a line of sample code may be:

 

<TrackID> EJ123456780US </TrackID>

In this instance, you will replace “EJ123456780US” with the tracking ID for the package.

 

API Signature

Scheme Host Path API XML
http:// stg-production.shippingapis.com /ShippingAPI.dll ?API=PTSRestore &XML=(see below)
http:// production.shippingapis.com /ShippingAPI.dll ?API=PTSRestore &XML=(see below)

 

Note: The “stg-production.shippingapis.com” signature host is for testing purposes. If you experience any issues connecting to this test server, please contact our helpdesk at uspstechnicalsupport@mailps.custhelp.com

Request Description

Tag Name Occurs Description Type Validation
PTSRestoreRequest required once (group)
PTSRestoreRequest / @USERID required This attribute specifies your Web Tools ID. See the Developer’s Guide for information on obtaining your USERID. string
PTSRestoreRequest / TrackId required Must be alphanumeric characters.For example:

<TrackId>EJ123456780US</TrackId>

string
PTSRestoreRequest / ClientIp optional User IP address.

For Example:

<ClientIp>127.0.0.1</ClientIp>

string
PTSRestoreRequest / SourceId optional Internal User Identification.

For Example:

<SourceId>XYZ Corp</SourceId>

string
PTSRestoreRequest / MpDate required MPDATE value located in Track/Confirm Fields API response data. Unique to each TrackID.For Example:

<MpDate>2009-07-02 00:42:23.35744</MpDate>

string
PTSRestoreRequest / FirstName optional Recipient First Name.

For example: <FirstName>John</FirstName>

string
PTSRestoreRequest / LastName optional Recipient Last Name.

For example: <LastName>Doe</LastName>

string
PTSRestoreRequest / Email optional Complete valid e-mail address is required if tag is used.

For example: <Email>cpapple@email.com</Email>

string

 

Sample Request and Response

Test XML Request:

<PTSRestoreRequest USERID=”xxx”><TrackId>70010320000307851274</TrackId >

<ClientIp>127.0.0.1</ClientIp>

<SourceId>XYZ Corp</SourceId>

<MpDate>2009-07-02 00:42:23.35744</MpDate>

<FirstName>John</FirstName>

<LastName>Doe</LastName>

<Email>cpapple@email.com</Email>

</PTSRestoreRequest>

?

Test XML Response:

<PTSRESTORERESULT>

<ResultText>Records will generally be restored within four hours. Restored records will be available online for 30 days. Please check back later to view your restored event information.</ResultText>

<ReturnCode>0</ReturnCode>

</PTSRESTORERESULT>

?

RRAM API

The Return Receipt After Mailing API allows the customer to receive a delivery record of an item after the item has been mailed. Current customers must request and purchase a return receipt (POD Letter) after mailing at the Post Office. This ability will provide an additional access channel for customers to request RRAM online through the USPS Tracking website.

Restore Request

The table below presents the XML input tags for generating Live requests and the restrictions on the values allowed.? An error message will be returned if an incorrect value is entered.? Also, be aware of the maximum character amounts allowed for some tags.? If the user enters more than those amounts, an error will not be generated.? The Web Tool will simply pass in the characters up to the maximum amount allowed and disregard the rest.? This is important since the resulting value could prevent a correct response.

When building the XML request, pay particular attention to the order and case for tags.? An error message will be returned if an incorrect value is entered.? Remember that all data and attribute values in this document are for illustration purposes and are to be replaced by your actual values.? For instance, a line of sample code may be:

 

<TrackID> EJ123456780US </TrackID>

In this instance, you will replace “EJ123456780US” with the tracking ID for the package.

 

API Signature

Scheme Host Path API XML
http:// stg-production.shippingapis.com /ShippingAPI.dll ?API=PTSRram &XML=(see below)
http:// production.shippingapis.com /ShippingAPI.dll ?API=PTSRram &XML=(see below)

 

Note: The “stg-production.shippingapis.com” signature host is for testing purposes. If you experience any issues connecting to this test server, please contact our helpdesk at uspstechnicalsupport@mailps.custhelp.com

?

Request Description

Tag Name Occurs Description Type
PTSRramRequest required once (group)
PTSRramRequestt / @USERID required This attribute specifies your Web Tools ID. See the Developer’s Guide for information on obtaining your USERID. string
PTSRramRequest / TrackId required Must be alphanumeric characters.For example:

<TrackId>EJ123456780US</TrackId>

string
PTSRramRequest / ClientIp optional User IP address.

For Example:

<ClientIp>127.0.0.1</ClientIp>

string
PTSRramRequest / SourceId optional Internal User Identification.

For Example:

<SourceId>XYZ Corp</SourceId>

string
PTSRramRequest / MpSuffix required MPSUFFIX value located in Track/Confirm Fields API response data. Unique to each TrackId.For Example: <MpSuffix>9402</MpSuffix> integer
PTSRramRequest / MpDate required MPDATE value located in Track/Confirm Fields API response data. Unique to each TrackID.For Example:

<MpDate>2009-07-02 00:42:23.35744</MpDate>

string
PTSRramRequest / FirstName required Recipient First Name.

For example: <FirstName>John</FirstName>

string
PTSRramRequest / LastName required Recipient Last Name.

For example: <LastName>Doe</LastName>

string
PTSRramRequest / Email1 optional Required when PTSRramRequest[RequestType=’Email’]

Complete valid e-mail address is required if tag is used.

 

For example: <Email1>cpapple@email.com</Email1>

string
PTSRramRequest / Email2 optional Complete valid e-mail address is required if tag is used. string
PTSRramRequest / Email3 optional Complete valid e-mail address is required if tag is used. string
PTSRramRequest / CommerceId optional ATG generated unique key that ties RRAM and Postal Store OrderId. Can be used for reporting, refunds and fraud investigation, etc.Example: ci519000001 string
PTSRramRequest / OrderId optional ATG confirmation number for Postal Store financials.Example: o313284853 string
PTSRramRequest / TableCode required TableCode value located in Track/Confirm Fields API response data. Unique to each TrackID.For Example:

<TableCode>T</TableCode>

string

Sample Request and Response

Test XML Request:

<PTSRramRequest><TrackId>EA123456789US</TrackId>

<ClientIp>123.0.0.1</ClientIp>

<SourceId>USPSTOOLS</SourceId>

<MpSuffix>9425</MpSuffix>

<MpDate>2011-07-25</MpDate>

<FirstName>JOHN</FirstName>

<LastName>PUBLIC</LastName>

<Email1>JOHN.Q.PUBLIC@USPS.GOV</Email1>

<Email2></Email2>

<Email3></Email3>

<CommerceId></CommerceId>

<OrderId></OrderId>

<TableCode></TableCode>

</PTSRramRequest>

?

Test XML Response:

<PTSRRAMRESULT>

<ResultText>Success</ResultText>

<ReturnCode>0</ReturnCode>

</PTSRRAMRESULT>

 

Error Responses

Error conditions are handled at the main XML document level.? When parsing, it is best to check for an error document first before checking for good data.? Error documents have the following format:

<Error>

<Number></Number>

<Source></Source>

<Description></Description>

<HelpFile></HelpFile>

<HelpContext></HelpContext>

</Error>

Where:

  • Number = the error number generated by the Web Tools server.
  • Source = the component and interface that generated the error on the Web Tools server.
  • Description = the error description.
  • HelpFile = [reserved for future use].
  • HelpContext = [reserved for future use].

Errors that are further down in the hierarchy also follow the above format.

An <Error> element may be returned at the top (response) level if there is a problem with the syntax of the request, or if a system error occurs.

?

If you need assistance with an error response, contact the Internet Customer Care Center uspstechnicalsupport@mailps.custhelp.com
测试返回结果

string(1292) "<?xml version="1.0" encoding="UTF-8"?>
<TrackResponse><TrackInfo ID="LS26111008622CN"><TrackSummary>Your item was delivered to the front desk or reception area at 12:35 pm on November 25, 2015 in OLYMPIA, WA 98516.</TrackSummary><TrackDetail>Out for Delivery, November 25, 2015, 6:56 am, OLYMPIA, WA 98516</TrackDetail><TrackDetail>Sorting Complete, November 25, 2015, 6:46 am, OLYMPIA, WA 98516</TrackDetail><TrackDetail>Arrived at Unit, November 25, 2015, 4:30 am, LACEY, WA 98503</TrackDetail><TrackDetail>Departed USPS Facility, November 25, 2015, 1:23 am, FEDERAL WAY, WA 98003</TrackDetail><TrackDetail>Arrived at USPS Destination Facility, November 24, 2015, 8:46 pm, FEDERAL WAY, WA 98003</TrackDetail><TrackDetail>Departed USPS Facility, November 22, 2015, 11:24 pm, SAN FRANCISCO, CA 94128</TrackDetail><TrackDetail>Arrived at USPS Facility, November 22, 2015, 9:02 am, SAN FRANCISCO, CA 94128</TrackDetail><TrackDetail>Processed Through Sort Facility, November 22, 2015, 7:53 am, ISC SAN FRANCISCO (USPS)</TrackDetail><TrackDetail>Processed Through Sort Facility, November 19, 2015, 6:11 pm, FUZHOU EMS, CHINA</TrackDetail><TrackDetail>Origin Post is Preparing Shipment</TrackDetail><TrackDetail>Acceptance, November 18, 2015, 8:56 pm, CHINA</TrackDetail></TrackInfo></TrackResponse>"
array(1) {
  ["TrackResponse"]=>
  array(1) {
    ["TrackInfo"]=>
    array(2) {
      ["TrackSummary"]=>
      string(114) "Your item was delivered to the front desk or reception area at 12:35 pm on November 25, 2015 in OLYMPIA, WA 98516."
      ["TrackDetail"]=>
      array(11) {
        [0]=>
        string(63) "Out for Delivery, November 25, 2015, 6:56 am, OLYMPIA, WA 98516"
        [1]=>
        string(63) "Sorting Complete, November 25, 2015, 6:46 am, OLYMPIA, WA 98516"
        [2]=>
        string(60) "Arrived at Unit, November 25, 2015, 4:30 am, LACEY, WA 98503"
        [3]=>
        string(73) "Departed USPS Facility, November 25, 2015, 1:23 am, FEDERAL WAY, WA 98003"
        [4]=>
        string(87) "Arrived at USPS Destination Facility, November 24, 2015, 8:46 pm, FEDERAL WAY, WA 98003"
        [5]=>
        string(76) "Departed USPS Facility, November 22, 2015, 11:24 pm, SAN FRANCISCO, CA 94128"
        [6]=>
        string(77) "Arrived at USPS Facility, November 22, 2015, 9:02 am, SAN FRANCISCO, CA 94128"
        [7]=>
        string(85) "Processed Through Sort Facility, November 22, 2015, 7:53 am, ISC SAN FRANCISCO (USPS)"
        [8]=>
        string(78) "Processed Through Sort Facility, November 19, 2015, 6:11 pm, FUZHOU EMS, CHINA"
        [9]=>
        string(33) "Origin Post is Preparing Shipment"
        [10]=>
        string(45) "Acceptance, November 18, 2015, 8:56 pm, CHINA"
      }
    }
  }
}

备注 ?由中国发出邮件 可通过EMS 查询

转载请注明:(●--●) Hello.My Weicot » Usps 快递API文档 最新版

蜀ICP备15020253号-1