PayPal is a well-known online payments processor that enables money transfers for companies and regular users alike.
Paypal’s API enables users to create apps that interact with their accounts, automating operations that pertain to billing, invoicing, orders, payments and many other elements.
To pull data from the PayPal API to Google Sheets easily and without writing any code, first install and open the Apipheny Google Sheets add-on.
Apipheny is a no-code API integrator for Google Sheets that you can use to make unlimited API requests, connect to unlimited APIs (including the PayPal API), save API requests, schedule API requests, and more. Click here if you want to learn more about Apipheny.
Install Apipheny by clicking the Install button on this page.
After you’ve installed Apipheny, open a Google Sheet and then click “Add-Ons” in the menu.
In the menu, click Apipheny and then after accepting the permissions, click Import API. The Apipheny sidebar will then open on the right side of the Google Sheet:
To use the PayPal REST API, you have to create a dedicated app in your Paypal account. You can create either a sandbox app, used for testing, or a live app that uses the actual information in your account.
In this tutorial we will use a live app, to show you how you can import actual live information from Paypal into your Google Sheets. Here’s the steps:
2.) Once logged in, click on My Apps & Credentials and toggle the switch to the Live option, to start creating a live app (Paypal may prompt you to upgrade your account to a business account):
3.) After clicking “Live”, scroll down, and in the REST API apps section, click Create App. Then type a name for your app and then click Create App again:
4.) Your new app’s details page will open and display the app’s identifying information. Copy and save the Client ID and Secret for your app somewhere safe and get ready to use them in the next step.
5.) Review your app’s information and for the purposes of this example, make sure that the Transaction Search option is checked, before saving your app:
In order to access most PayPal REST API endpoints, you will need an access token. To obtain an access token, you’ll either need to do a cURL command or use the Postman app.
Here’s the instruction for cURL:
To make a cURL command, pass your OAuth 2.0 credentials through a dedicated PayPal REST API command, using the cURL command line tool:
Use the same values for Client ID and for Secret that you copied in the previous step, into the <client_id> and <secret> placeholders you see above.
You can also use other command-line tools besides cURL, but for those, you’ll have to set the Accept header to application/x-www-form-urlencoded instead of application/json.
In response to this command, the PayPal authorization server will return your access token in the access_token field of the JSON result:
Copy the access token somewhere safe because you will need it in the next step.
Note: This JSON result also contains an expires_in field, containing the number of seconds after which your newly-retrieved access token expires. For instance, access tokens with a value of 3600 in the expires_ field will expire in one hour from the time the response was generated, meaning you will need to get a new access token if it’s been longer than an hour.
For this example, we will use the Transaction Search API to get your PayPal account’s transaction history. This example URL uses the GET HTTP method and includes a number of parameters: start_date, end_date, fields, page_size and page.
See the screenshot below to see the URL in Apipheny.
In the headers section in Apipheny, you should have two rows with the following keys and values:
Key 1: Content-Type Value 1: application/json
Key 2: Authorization Value 2: Bearer your-access-token
It doesn’t matter what order the headers are entered. “your-access-token” is the value from the access_token field in the JSON response you obtained in Step 3. Enter the access token after “Bearer”, with a space between “Bearer” and the token (see screenshot below).
The Content-Type and Authorization headers are also required, so you should add them as their own header:
Click the Run button at the bottom of the Apipheny sidebar and then wait for the Paypal API data to be retrieved and added in to your Google spreadsheet, like this:
In this example, we got our Paypal transaction history data in Google Sheets by using the Apipheny add-on.
Now that you know how to query the Paypal API, try using different parameters in your Paypal API URL. Click here to see a list of available parameters.
Keep in mind that the access token you obtained expires after an hour, so you’ll need to get a new access token if it’s been more than an hour.
You could also try using one of the more advance features in the Apipheny add-on, such as: