axios and got HTTP clients in the examples below, but you can use any npm package you’d like on Pipedream, so feel free to experiment with other clients, too.
If you’re developing Pipedream components, you may find the @pipedream/platform version of axios helpful for displaying error data clearly in the Pipedream UI.
If you’re new to HTTP, see our glossary of HTTP terms for a helpful introduction.
Basic axios usage notes
To use axios on Pipedream, you’ll just need to import the axios npm package:
axios that defines the parameters of the request. For example, you’ll typically want to define the HTTP method and the URL you’re sending data to:
axios returns a Promise, which is just a fancy way of saying that it makes the HTTP request in the background (asynchronously) while the rest of your code runs. On Pipedream, all asynchronous code must be run synchronously, which means you’ll need to wait for the HTTP request to finish before moving on to the next step. You do this by adding an await in front of the call to axios.
Putting all of this together, here’s how to make a basic HTTP request on Pipedream:
resp contains a lot of information about the response: its data, headers, and more. Typically, you just care about the data, which you can access in the data property of the response:
Send a GET request to fetch data
Make a request to retrieve Star Wars films from the Star Wars API:

Send a POST request to submit data
POST sample JSON to JSONPlaceholder, a free mock API service:
POST request, you pass POST as the method, and include the data you’d like to send in the data object.
Pass query string parameters to a GET request
Retrieve fake comment data on a specific post using JSONPlaceholder, a free mock API service. Here, you fetch data from the /comments resource, retrieving data for a specific post by query string parameter: /comments?postId=1.
- axios
- http-request prop
Send a request with HTTP headers
You pass HTTP headers in theheaders object of the axios request:
Send a request with a secret or API key
Most APIs require you authenticate HTTP requests with an API key or other token. Please review the docs for your service to understand how they accept this data. Here’s an example showing an API key passed in an HTTP header:Send multiple HTTP requests in sequence
There are many ways to make multiple HTTP requests. This code shows you a simple example that sends the numbers1, 2, and 3 in the body of an HTTP POST request:
Send multiple HTTP requests in parallel
Sometimes you’ll want to make multiple HTTP requests in parallel. If one request doesn’t depend on the results of another, this is a nice way to save processing time in a workflow. It can significantly cut down on the time you spend waiting for one request to finish, and for the next to begin. To make requests in parallel, you can use two techniques. By default, we recommend usingpromise.allSettled, which makes all HTTP requests and returns data on their success / failure. If an HTTP request fails, all other requests will proceed.
axios.get requests (which are all Promises), and then call Promise.allSettled to run them in parallel.
When you want to stop future requests when one of the requests fails, you can use Promise.all, instead:
ThePromise.allSettled()method returns a promise that resolves after all of the given promises have either fulfilled or rejected, with an array of objects that each describes the outcome of each promise.
It is typically used when you have multiple asynchronous tasks that are not dependent on one another to complete successfully, or you’d always like to know the result of each promise.
In comparison, the Promise returned byPromise.all()may be more appropriate if the tasks are dependent on each other / if you’d like to immediately reject upon any of them rejecting.
Send a multipart/form-data request
Download a file to the /tmp directory
This example shows you how to download a file to a file in the /tmp directory. This can be especially helpful for downloading large files: it streams the file to disk, minimizing the memory the workflow uses when downloading the file.
Upload a file from the /tmp directory
This example shows you how to make a multipart/form-data request with a file as a form part. You can store and read any files from the /tmp directory.
This can be especially helpful for uploading large files: it streams the file from disk, minimizing the memory the workflow uses when uploading the file.
IP addresses for HTTP requests made from Pipedream workflows
By default, HTTP requests made from Pipedream can come from a large range of IP addresses. If you need to restrict the IP addresses HTTP requests come from, you have two options:- Use a Pipedream VPC to route all outbound HTTP requests through a single IP address
- If you don’t need to access the HTTP response data, you can use
$send.http()to send requests from a limited set of IP addresses.
Use an HTTP proxy to proxy requests through another host
By default, HTTP requests made from Pipedream can come from a range of IP addresses. If you need to make requests from a single IP address, you can route traffic through an HTTP proxy:Stream a downloaded file directly to another URL
Sometimes you need to upload a downloaded file directly to another service, without processing the downloaded file. You could download the file and then upload it to the other URL, but these intermediate steps are unnecessary: you can just stream the download to the other service directly, without saving the file to disk. This method is especially effective for large files that exceed the limits of the/tmp directory.
Copy this workflow or paste this code into a new Node.js code step:
https://example.com with the URL you’d like to stream data from, and replace https://example2.com with the URL you’d like to send the data to. got streams the content directly, downloading the file using a GET request and uploading it as a POST request.
If you need to modify this behavior, see the got Stream API.
Catch and process HTTP errors
By default,axios throws an error when the HTTP response code is in the 400-500 range (a client or server error). If you’d like to process the error data instead of throwing an error, you can pass a custom function to the validateStatus property:
axios docs for more details.
Paginating API requests
When you fetch data from an API, the API may return records in “pages”. For example, if you’re trying to fetch a list of 1,000 records, the API might return those in groups of 100 items. Different APIs paginate data in different ways. You’ll need to consult the docs of your API provider to see how they suggest you paginate through records.Send GraphQL request
Make a GraphQL request using thegraphql-request NPM package:
The graphql package is requiredThe
graphql package is required for popular GraphQL clients to function, like graphql-request and urql.Even though you will not need to use the graphql code itself in your code step, it’s required to import it in order for graphql-request to function.Send an authenticated GraphQL request
Authenticate your connected accounts in Pipedream with GraphQL requests using theapp prop: