If you're a Freightview customer, you know how easy it is to provide your shipment details and get tailored quotes quickly through our web site. But you can also get those quotes via our API, so you can integrate them into other applications and tools you use everyday.
About the API
Freightview's API is considered RESTful. It uses JSON, a common and lightweight data representation that is easily consumed by most languages and frameworks. The documentation is clear and robust (check it out here). Even if you're not a developer, this post will explain how you can test the API without writing a single line of code.
If you've ever connected to an API before, you know that the biggest challenge is the first step: authenticating. In the same way that you log in on our web site, the API needs to know who you are in order to give you back rates based on your carrier relationships.If you don't include the correct authentication with each request, all calls to the Freightview API will return a
401 Unauthorized error." You'll find subsequent calls to be very straightforward.
First thing's first: Obtaining your API key
Rather than your username and password, Freightview's API requires a special key to recognize your account. You can find this key by clicking on the gear in the upper right hand corner of the site, then choosing "API key" from the menu. A panel will slide out presenting the account and user API keys. Copy the account API key for the following step. Either method will get the job done, so you can choose the one you prefer.
Method 1: Simple API authentication with cURL
Freightview's developer documentation provides a one-line command you can run in your terminal to ensure you can successfully connect to the API. This command is called "cURL", and it simply verifies that a URL (in this case, Freightview's API URL) gives the expected response. When you run this command, along with your API key, you should get a 200 OK response like the one shown here. Notice the trailing colon (:) after the API key. This tells cURL that the password is empty.
Method 2: Simple API authentication with Postman
cURL is great, but some folks prefer a nice user interface to interact with instead. The gold standard for testing APIs is a free and cross-platform application called Postman. You can get it at https://www.getpostman.com.
As you can see in the screenshot below, you'll provide all of the same information as you would with cURL, but you enter it in Postman's fields. Again, the password field is empty. The result should be the same: a 200 OK response.
- Ensure the method is GET
- Enter the authenticate URL
- On the Authorization tab, choose Basic Auth in the dropdown, and enter your API key for the Username.
- Hit Send
The methods above allow you to ensure the Freightview API is up, reachable and successfully authenticating your account. If you want to take things further, you can use Postman to do a few rate requests, just like you would in the web site.
- Change the method from GET to POST
- Replace "authenticate" with "rates" in the URL
- On the Headers tab, add a Content-Type header with "application/json" as the value. (You can leave the Authorization header alone.)
- On the Body tab, choose "raw" and build your JSON request according to the documentation.
- Hit Send
Successful responses will once again return a 200 OK response, along with an array of quotes.f you get an error, check the response documentation for the corresponding HTTP status code (e.g. 400, 500) for that endpoint.
Notice that endpoints like /rates are versioned. You may specify a version in the URL using this format: https://www.freightview.com/api/v1.0/rates. If you do not specify a version, it will default to version 1.0.
They're your rates, use them your way
At Freightview, we strive to make every aspect of your shipping needs easier; whether you're using our web site or a complementary tool. Our API makes it easy to see and use your rates however you need them. And of course, we're here to help if you have questions or comments. Happy shipping!
This post was updated on August 26th, 2020