DEV Community

Pipedream
Pipedream

Posted on • Edited on • Originally published at blog.pipedream.com

Use any API in seconds with auth managed by Pipedream

Pipedream makes it easy to write Node.js and use any API in seconds! We securely manage auth for 100+ apps (with more added daily) – just connect your app accounts and use the auths object in code to reference tokens and keys.

Github HTTP API

For example, to use Github's HTTP API,  just connect your account using a browser-based oauth flow and and pass auths.github.access_token as the value of the Bearer token (check out the octokit section below for an example of how to use auths with an npm package).

const axios = require('axios')

const response = await axios({
  url: `https://api.github.com/user`,
  headers: {
    Authorization: `Bearer ${auths.github.oauth_access_token}`,
  }, 
})

return response.data

Here's a GIF that demonstrates how to use the Github API in 30-seconds:

In ~30-seconds, I add a code step with Github auth, paste in the code above, connect my account, query the API and inspect the results. Copy this template to try it yourself .

Github via Octokit

You're not limited to using Pipedream managed auth with HTTP APIs – it works with npm packages too! Here's an example of the same API request as above, but using Github's octokit package:

const Octokit = require('@octokit/rest')

const octokit = new Octokit({
  auth: auths.github.oauth_access_token
})

return (await octokit.users.getAuthenticated()).data

Pipedream transparently installs any npm packages you require in your code when you deploy. To try it yourself, copy this template, enable steps.octokit, connect your account and run the code.

Scaffolding API + Auth Code

Pipedream also supports actions, which are re-usable code steps. Actions provides scaffolding for popular APIs and functions. To scaffold a generic API for an app, just click the plus (+) button , select the app and choose Run Node.js with [App Name]:

To scaffold a specific API for an app, just click the plus (+) button , select the app and choose the action that you want to scaffold. Try editing the code and confirm that you want to customize it:

Triggering Your Code

Trigger your code:

  • Manually
  • On an interval or cron schedule
  • On HTTP request (Pipedream will generate a unique URL — any requests to this URL will trigger your code)
  • On an email (Pipedream will generate a unique email address — any emails sent to this address will trigger your code)
  • Via the Pipedream Node.js or Ruby SDKs

Getting Started

To get started, just sign in with your Google or Github account at https://pipedream.com. Check out the project templates at https://pipedream.com/explore, and join our public Slack at https://pipedream.com/community!

Top comments (0)