![]() ![]() Reverse engineering an OpenAPI specification Let’s look at the challenges we faced improving the developer experience. Many companies offer an interactive API explorer as part of their documentation, we thought a good solution was a USPS Web Tools public workspace with Postman. Finally, we created a video tutorial so you can try out these tools. We crafted a USPS Web Tools OpenAPI 3.0 specification from the PDF docs, then used the spec to generate modern USPS Web Tools API documentation with Redoc and host them on Netlify. API documentation often ranks number one for how developers evaluate a technology and the USPS Web Tools APIs reference docs are only available as PDFs, so we decided to start there. ![]() Now, we can’t change the APIs themselves, but perhaps an open-source project that leverages new tools could make a difference. Unfortunately, many of these endpoints were developed over a decade ago and during the intervening years developers have come to expect increasingly better and better developer experiences.Īs we looked at the USPS Web Tools site, we started thinking of ways to improve the experience. Their current API set includes address verification, rate calculators, shipping labels, package pickup, domestic mail service, tracking & confirmation, and even an API to retrieve Hold for Pickup facility information. Postal Service opens up their data and makes it easy to access with a free USPS Web Tools® account. Lob also utilizes the USPS tracking data in our webhooks so customers can observe the journey of each mail piece. The mail that flows through Lob to our print partner network reaches its final destination with help from the U.S Postal Service. Package.ShippingLabel = Convert.FromBase64String(xml.At Lob we help developers automate sending letters, checks, and postcards, and improve address quality through RESTful APIs. 'package.ShippingLabel = StringToUTF8ByteArray(xml.Substring(i1, i2 - i1)) 4, (), package.OriginZipcode, (), labeldate, _ĭim xml As String = web.DownloadString(url)ĭim idx1 As Integer = xml.IndexOf(" ") + 13ĭim errDesc As String = xml.Substring(idx1, idx2 - idx1)ĭim i1 As Integer = xml.IndexOf(" ") + 27 ![]() Format(url, Me._userid, CInt(package.LabelType),, , 1, _ If () = () Thenĭim url As String = "?API=ExpressMailLabelCertify&XML= " Public Function GetExpressMailConfirmationLabel(package As Package) As Packageĭim labeldate As String = () I have updated the source code to include the XML Parser version of the FromXML method on the Address object. I will look into this and make changes to the code accordingly. It appears that USPS may have changed some of the behaviour of their Web services. Note: If you want to test the other label methods, you will need to download the Guides from the USPS Web Tools site and use the sample data they provide. P.PackageType = PackageType.Flat_Rate_Box P.ToAddress.Address2 = " 6060 PRIMACY PKWY" P.FromAddress.Address2 = " 475 L'Enfant Plaza, SW" USPSManager m = new USPSManager( " YOUR_USER_ID", true) / true if you want to use the USPS Test Servers. / your USPS Web Tools User ID and the second is / The constructor takes 2 arguments, the first is / Create a new instance of the USPS Manager class Once you have tested your application, you can request your profile to be updated by USPS to access the production environment, where you can use any appropriate data. If you change the address or anything else, you will get an error. Note: If you are using the USPS Test servers, then the data in the examples below are the only data that will work. You can do this by filling out this form. Please keep in mind that this is my first CodeProject article, so go easy! :) USPS Web Toolsīefore you can use this library, you will need to get a USPS Web Tools ID. (This library will work in ASP.NET Web applications also.) The USPS Web tools are fairly easy to integrate, but I wanted to create a reusable component that I could use in future projects. I was in need of a library that would integrate the USPS Web Tools into my Windows form application. I will post them here on The Code Project when I am finished, but you can check this Web site until then for updates and to contact me directly. The DHL version should be the next one I release. UPDATE: I am working on a FedEx, UPS and DHL version of this tool. ![]()
0 Comments
Leave a Reply. |