API Connector Documentation
Import FedEx Data to Google Sheets
In this guide, we’ll walk through how to import FedEx shipping data directly into Google Sheets, using the API Connector add-on for Sheets.
Contents
- Before You Begin
- Part 1: Create a FedEx Project
- Part 2: Connect FedEx to API Connector
- Part 3: Pull FedEx Data into Sheets
- Part 4: API Documentation
Before You Begin
Click here to install the API Connector add-on from the Google Marketplace.
Part 1: Create a FedEx Project
- If you haven't already, navigate to https://developer.fedex.com and log in or create an account.
- Once you're logged in, click My Projects > +Create A Project
- From the Create Project screen, select why you need API access
- Choose the APIs to which you'd like to have access
- Accept their terms, configure your project, and click Create
- You should now see test credentials on the page. We'll start with these to show how it works. If you've already done this you can switch to your production key.
Part 2: Connect FedEx to API Connector
- Open up Google Sheets and click Extensions > API Connector > Manage Connections
- Scroll to the bottom of the sidebar and click Add Custom OAuth
- Fill in the Custom OAuth modal as follows:
- OAuth Grant Type:
Client Credentials
- Name:
Custom FedEx
- Token URL:
https://apis.fedex.com/oauth/token
- Client ID: The API Key provided by FedEx
- Client Secret: The Secret Key provided by FedEx
- OAuth Grant Type:
- Click Save
Part 3: Get FedEx Data in Sheets
You can create a request using any of the endpoints and parameters described in FedEx's documentation. Here's an example to their tracking API. Substitute in your own tracking numbers, up to 30 at a time (if you need more than 30, you can cycle through a list of request bodies using a multi-query request).
- Application:
Custom
- Method:
POST
- Request URL:
https://apis.fedex.com/track/v1/trackingnumbers
- OAuth:
Custom Fedex
- Request body:
{"trackingInfo":[{"trackingInfo":[{"trackingNumberInfo":{"trackingNumber":"11111111111111"}},{"trackingNumberInfo":{"trackingNumber":"22222222222222"}},{"trackingNumberInfo":{"trackingNumber":"33333333333333"}}]}
Part 4: API Documentation
Official Track API documentation: https://developer.fedex.com/api/en-us/catalog/track/v1/docs.html
Is it possible to just load a script into editor and not have to use external or third party API apps?
Yes! Google provides a scripting language called Apps Script, which is a variation on JavaScript. API Connector and other extensions are built using Apps Script, but you can write your own scripts by opening Sheets and clicking Extensions > Apps Script. Here's one article to get you started.
Hi Ana,
Thanks for the info! On the FedEx API documentation, it provides us a script to use. Do you know how to incorporate that script into Google Sheets? I pasted the script below. Thanks!!
// 'input' refers to JSON Payload
var data = JSON.stringify(input);
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://apis-sandbox.fedex.com/track/v1/trackingnumbers");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("X-locale", "en_US");
xhr.setRequestHeader("Authorization", "Bearer ");
xhr.send(data);
You'll need to modify that for Apps Script (Apps Script doesn't support
XMLHttpRequest()
, add a method to fetch the token and input tracking numbers etc, and add some code to trigger the function as well as convert the JSON response from Fedex into a tabular format for Google Sheets. Basically this requires development work. May I ask why you don't want to use the API Connector extension? It already does all of those things, for free.My organization doesn't allow third party app of any sort due to security and privacy. I been seeking around different forums and your site is the only one that contains the most information and knowledge. I really wish we an use API connector because your writeup is informative and thorough.
Ah, got it, that's too bad. In that case maybe you can try out the open source ImportJSON script, it is a script that you can copy/paste into Apps Script that lets you connect APIs to Google Sheets.
Hi Ana, using your method can you share a sheet with how each column works and what to label it
I'm not sure I understand this, what do you mean by "how each column works"?
Sorry for the confusion, I'm using the api connector privately to understand how it works. I got it to work but i'm not sure how you can do multiple tracking at once.
Fedex's docs say you can input up to 30 tracking numbers at once, like this:
{"trackingInfo":[{"trackingNumberInfo":{"trackingNumber":"1111111111"}},{"trackingNumberInfo":{"trackingNumber":"22222222"}},{"trackingNumberInfo":{"trackingNumber":"3333333"}}]}
Hi
I received this error " The given JWT is invalid. Please modify your request and try again."
What could be the reason?
Thanks
That means your access token is invalid. The access token only lasts for an hour, so make sure you fetch and include a fresh, valid token before running your request.
Update: you can now use API Connector's OAuth Manager to automatically refresh these tokens.
Hi,
I wanna integrate FedEx Rates and Transit Times API with Google Sheets to get an estimate on multiple packages to be shipped. The steps would be the same or there would be any difference? Please let me know. Thank you!!
Most of the steps would be the same. You'll need to select the "Rate and Transit Times API" when creating your FedEx project, but fetching and including your token should work the same way. You'll also need to use a request URL of
https://apis.fedex.com/rate/v1/rates/quotes
and construct the request body as shown here: https://developer.fedex.com/api/en-cn/catalog/rate/v1/docs.html#operation/Rate%20and%20Transit%20timesHi,
First, thanks for the comprehensive tutorial. This might be a follow-up question. How do you get all those columns in the screenshot in Part 3? I did everything as you did and all I get is a column called "transactionID" which then shows me the ID of the tracking number I put in. Also, is it possible to make the tracking numbers variable inside the API body? So that I can refer to a specific cell and if the tracking number in that cell changes I dont have to manually add it to the body.
Thanks in advance!
It sounds like you may have filtered out some fields, can you please click Edit fields and check if you see those missing fields in the preview window?
As for making tracking numbers variable, you can reference cells to make the requests dynamic.