Advanced data import from import.io to Google Sheets using Google Apps Script

This tutorial will walk you through getting data from import.io in to Google Sheets, making use of the Google Apps Script integration and our shared library.

1. Open up your spreadsheet


We can start with a blank Google Sheets document, or you can use one you use already. However, be advised that the library puts the data returned in the top left corner of the sheet called "Sheet1" by default, so make sure it is empty otherwise your data may be overwritten.

2. Start the Script Editor


Navigate to Tools > Script editor...:



This will open a script editor window in a new tab, that looks like the image below. If you have a popup then just click "Close" first.


3. Include import.io library


You can include our library so that you can access it in your script - this saves you writing a lot of code!

Choose Resources > Libraries... from the menu (you may have to name your script first - if so, just enter a project name and click "OK"):


In this popup, put import.io's library ID into the "Find a Library" box then press "Select".

The import.io library ID is: MKo1A089fnQbphn0MDcszZJLGncKf5Rex



You will see the library called "ImportIO". Choose the latest version (highest number) from the dropdown in the "Version" column, then click "Save".

4. Copy in example code


Copy our example code from this page into the code window, replacing all of the other contents, and then press save (Ctrl+S). The code may change, but should look something like this:


5. Fill in your details


In the execute function, there is some data you need to fill in.

Firstly, userGuid and apiKey need to be set. You can get these two pieces of data from your account page.

You can also modify connectorGuid and input. For now we will leave them unchanged to show you an example, but you can get a Connector GUID and the inputs it needs from your My Data page.

6. Execute the script


The final step is to execute the script. In the script editor, press the "Play" button, ensuring "execute" is selected in the dropdown next to it:



The first time you do this, you will see an "Authorization required" popup - click "Continue" and then "Accept" in the two popups.

The script will run, and all being well, the data will be displayed in your spreadsheet:



As always, get in touch with us at support@import.io and we will be more than happy to help out!

Thanks to Martin Hawksey for his contributions which spawned this version of our client library.

Feedback and Knowledge Base