Announcing the new RESTful API Node.js SDK


Since the launch of the new PayPal RESTful APIs, the development teams have been hard at work to provide the development community with new features and ways of working with our new initiatives.

With that said, I am happy to announce the launch of the new Node.js SDK for the RESTful APIs. As a Node.js developer myself, I am always happy to see how much eBay and PayPal support the Node.js community.

Getting the SDK As with all of our SDKs, the Node.js SDK is available on the

PayPal Github account. What makes this approach excellent for the community is that all issues and enhancements that users may want to contribute can be done directly through the Github project itself, meaning that the progress and work that the teams are doing to enhance the projects are completely transparent.

To find samples for working with the SDK, you can also take a look through the Node.js SDK sample repository. This is an excellent place to get started.

Using the SDK There are a few steps that we need to go through in order to integrate the SDK into a Node.js application.

1. Create the package.json file To start out an integration, we first need to create our package.json file that will give our application all of its configuration information.

The easiest way to get started is to copy the sample package.json file from the PayPal Node.js SDK Github repository. Once copied to your application folder, open it up for editing.

We now need to add the PayPal Node.js SDK as a dependency for our application. Go down to the dependencies object declaration and add a new paypal-rest-sdk definition. That section should now look like the following: "dependencies": {
"node-uuid": "*",
"paypal-rest-sdk": "*"
2. Install dependencies and create your test file With the package.json file created, we now need to use it to install our application dependencies. At the application folder root, where the package.json file is, simply run the following command: npm install Once completed, you should now see a new node_modules folder within your project, containing all of the required project dependencies. Next, go ahead and create a new Node.js application file, such as test.js, where we will put all of our test code. 3. Configure your application details Open up your new Node.js file to begin adding in our application configuration details. We’re going to start by creating a new variable for the SDK, paypal_sdk. With that in place, we then create a PayPal configuration object. This section will contain:
* host: The API host to use, for the PayPal sandbox, or for live requests.
* port: The port to use.
* client_id: Your PayPal application client id.
* client_secret: Your PayPal application client secret.

4. Making your first request Now that the configuration object is in place, we can make our first request. Let’s go ahead and store credit card information in the vault. We start by creating a credit card object with the information that we want to store in the vault. Once that’s in place, we make a call to the credit_card.create method to initiate the storage request. Once the code is called, you should see a valid response coming back with the credit card store response, looking something like this:

Going Further To continue exploring the Node.js SDK and the methods available, you can take a look through the

SDK lib itself at the end of the file in the return structure, or see the API methods on the PayPal Developer site.

If you want to see what other SDKs are available, you can explore this earlier SDK announcement post.

5 thoughts on “Announcing the new RESTful API Node.js SDK

  1. DeveloperDan

    I have used this to implement a credit card gateway.
    Works a treat!

    Only thing is this is for the new REST API and isnt available in the UK
    Any idea when it might be available?
    Or if there will be a version for use with the classic API ?

    1. jcleblanc

      I’m glad to hear that it’s working well for you – please do let us know if you ever run into issues and I’ll share it with the teams.

      I, unfortunately, don’t have any information about release timelines for the new REST API in the UK. As soon as I have some timeframes that I can share I’ll post out on the blog. I don’t think there will be an official Node.js SDK created for the classic APIs, just these ones for the new REST APIs that will support each region.

  2. Vitaliy

    This is Awesome news! Thank you. Its best module and easy to use, unlike most of payment modules i’ve ever seen.

  3. Manish Sivanandan

    Hi. Any idea how to implement a simple payment using paypal in a nodejs app? I have been looking for tutorials and the documentation is very hard.

Comments are closed.