Getting Started

triangle-exclamation

Before starting to use PayPal's REST APIs, you need to get your client ID and client secret as described in the following steps:

  1. Go to the Dashboardarrow-up-right and log in or sign up.

  2. Select Apps & Credentials.

  3. Select Create App to create a new project. &#xNAN;Note: New accounts come with a Default Application in the REST API apps section.

  4. Copy the client ID and client secret for your app.

Getting Your Access Token

circle-info

Prerequisites

Curl installed.

After successfully getting your client ID and client secret, you can generate an access token by completing the following steps:

  1. Open a text/code editor.

  2. Copy and paste the following code:

  1. Now modify the code by replacing:

    1. CLIENT_ID with your client ID.

    2. CLIENT_SECRET with your client secret.

  2. Encode CLIENT_ID:CLIENT_SECRET in Base64 before sending it in the API call.

  3. Run the updated code in your command line.

PayPal will return a response containing the access token and the number of seconds the access token is valid, as shown in the following JSON code:

circle-info

Available languages You can call the PayPal OAuth API in any language.

Making API Calls

After successfuly getting an access token, you can start making API calls. Just replace ACCESS-TOKEN with your access token in the authorization header as follows:

-H Authorization: Bearer ACCESS-TOKEN.

When your access token expires, run again the previous curl code to request a new access token:

About PayPal Sandbox Account Credentials

The PayPal sandbox is a test environment that mirrors real-world transactions. By default, PayPal developer accounts have 2 sandbox accounts:

  • a personal account for buying

  • a business account for selling.

You'll get the login information for both accounts. Watch sandbox money move between accounts to test API calls.

To get sandbox login information for business and personal accounts complete the following steps:

  1. Select Testing Tools > Sandbox Accounts.

  2. Locate the account you want to get credentials for and select ⋮.

  3. Select View/Edit Account to see mock information such as the account email and system-generated password.

  4. Sign in to sandbox.paypal.com/signinarrow-up-right using your personal sandbox credentials.

  5. In a separate browser, sign in with the business sandbox credentials.

  6. Make API calls with your app's access token to see sandbox money move between personal and business accounts.

circle-info

Additional sandobox accounts You can create more sandbox accounts by selecting Create account.

Last updated