Typescript/Javascript library for interacting with the Venmo API.
This example will login and request $1.00 from the users listed in USERNAMES
.
-
Negative amounts are payment requests.+
Positive amounts are payments.
// Create a venmo client.
const v = new Venmo();
await v.easyLogin(process.env.EMAIL, process.env.PASSWORD);
const usernames = process.env.USERNAMES?.split(',') || [];
// For each recipient username
for (const username of usernames) {
// Query user so we can get the id.
const userResponse = await v.userQuery(username);
const user = userResponse?.find(
(user) => user.username.toLowerCase() === username.toLowerCase()
);
if (user) {
// Request payment with the user id.
const paymentRes = await v.pay(user.id, -1, 'Note for transaction.', 'private');
}
}
You can deal with 2FA by passing a callback function that returns the otp code. In this example we are using stdin to have the user manually type the code they get via SMS.
import { Venmo } from "venmo-typescript";
import readline from 'readline';
const v = new Venmo();
await v.easyLogin(process.env.EMAIL, process.env.PASSWORD, async () => {
return await new Promise((res) => {
readline.createInterface({
input: process.stdin,
output: process.stdout
}).question('Enter OTP code:', (answer) => res(answer))
});
});
import { Venmo } from "venmo-typescript";
const v = new Venmo();
await v.easyLogin(process.env.EMAIL, process.env.PASSWORD);
console.log(await v.getUserProfile());
You can also manually login and manage the otp code yourself. See how easyLogin works.