Print

Import PayPal Data to Google Sheets

In this guide, we'll pull PayPal transaction data into Google Sheets, using the API Connector add-on for Sheets.

PayPal is probably the best-known online payments system, and, founded in the late '90s, certainly the longest-running. However their APIs are a bit clunky and convoluted. This guide will sort it out!

Contents

Before You Begin

Click here to install the API Connector add-on from the Google Marketplace.

Part 1: Get Your Paypal Credentials

  1. Navigate to Paypal's Apps & Credentials page (https://developer.paypal.com/developer/applications). Click Log into Dashboard if you aren't already logged into your account. You will need to sign up if you don't already have a developer account. paypal-img1
  2. Once you're logged in, toggle to Live mode and click Create App.
    paypal-img2
  3. Give your app a name. It can be anything, but we'll call it 'Google Sheets'. Click Create App.
    paypal-img3
  4. You'll now see your credentials. Pay particular attention to the Client ID and the Secret as we need them next.
    paypal-img4
  5. Scroll down and choose the features you want to access. For this tutorial you'll at least need to have Transaction Search enabled.
    paypal-img12
  6. When you enable Transaction Search, it takes up to a day before the permission is actually applied to your app. So take a long break before proceeding.

Part 2: Connect PayPal to API Connector

  1. Open up Google Sheets and click Extensions > API Connector > Manage Connections
  2. Scroll to the bottom of the sidebar and click Add Custom OAuth
  3. Fill in the Custom OAuth modal as follows:
    • OAuth Grant Type: Client Credentials
    • NameCustom PayPal
    • Token URLhttps://api-m.paypal.com/v1/oauth2/token
    • Client IDprovided by PayPal
    • Client Secretprovided by PayPal
  4. Click Save

Part 3: Pull PayPal Transaction Data into Sheets

To create a request, include your full request URL in the request URL field, and select your custom PayPal connection from the dropdown OAuth menu. You can see the full list of available endpoint and parameters in the API documentation.

For this example, we'll get a list of transactions created between two dates. Note that this endpoint can only retrieve 30 days of data per request. To get more than 30 days data at a time, you can either run separate requests and append / merge them together after, or stack your requests such that they automatically run one after the other and print into the same sheet.

  1. Open up Google Sheets and click Extensions > API Connector > Open > Create request.
  2. In the request form enter the following:
    • ApplicationCustom
    • MethodGET
    • Request URLhttps://api-m.paypal.com/v1/reporting/transactions?start_date=2023-10-01T00:00:00-0700&end_date=2023-10-31T23:59:59-0700&fields=transaction_info&page_size=500
    • OAuth: Custom Paypal
  3. Create a new tab and click Set current to use that tab as your data destination.
  4. Create a new tab, name your query, and hit Run. A moment later you'll see your transactions populate your sheet (change the date parameters if you'd like to see a different time range).

Part 4: Handle Pagination

By default, PayPal only returns 500 records at once. To get more, you can use pagination handling, like this:

  • URL: enter your URL, including page_size=500
  • Pagination: page parameter
  • Page parameter: page
  • Run until: choose when to stop fetching data
    pagination-page-parameter

Part 5: API Documentation

Official API documentation: https://developer.paypal.com/docs/api/transaction-search/v1/

10 thoughts on “Import PayPal Data to Google Sheets”

    • I just tested and it still works on this side. Can you please try again? I've seen that it may take a few hours for the token to update with the "transactions search" permissions.

      Reply
  1. Hi, I confirm I needed about ~12 hours to be able to access Paypal API data without the 403 error after creating the API key with "transactions search" permissions.

    Reply
  2. Hello, I keep getting this.

    We received an error from paypal.com (401) show response{"name":"AUTHENTICATION_FAILURE","message":"Authentication failed due to invalid authentication credentials or a missing Authorization header.","links":[{"href":"https://developer.paypal.com/docs/api/overview/#error","rel":"information_link"}]}

    Any info on what this could be?

    Reply
    • Can you please double check that
      a) you're using the access token you got back from the https://api-m.paypal.com/v1/oauth2/token request, and
      b) you created your app in Live (not Sandbox) mode
      Update: you can now use API Connector's OAuth Manager to automatically fetch and apply the access token.

      Reply
  3. Hi there, I can't seem to import the cURL request into the Extension in Google Sheets. I keep getting the error message:

    Failed to import cURL command, please check if it's valid cURL command

    Any thoughts on how to fix this? I have pasted it exactly as above, just with my client ID and Secret ID replacing those words.

    Thanks!
    Brayden

    Reply
    • Oh, I'm seeing the same thing, looks like we have a bug there. I'll get that fixed ASAP. In the meantime, you can get your token like this:
      Application: Custom
      Method: POST
      Headers:
      Accept: application/json
      Authorization: Basic your_encoded_credentials (encode your credentials by entering your_client_id:your_client_secret in this form)
      Request body: {"grant_type":"client_credentials"}
      Edit: curl import bug should now be fixed!
      Edit #2: you can now use API Connector's OAuth Manager to automatically fetch and apply the access token.

      Reply
    • You can filter using any of the parameters shown here. I think balance_affecting_records_only or transaction_type might be what you want, e.g. https://api-m.paypal.com/v1/reporting/transactions?start_date=2023-08-01T00:00:00-0700&end_date=2023-08-30T23:59:59-0700&fields=transaction_info&page_size=500&transaction_type=T1000

      Reply

Leave a Comment

Jump To