Difficulty: Beginner
Estimated Time: 10 minutes

This tutorial will get you started using Alpaca with Javascript

You're now ready to use Alpaca with Javascript

Getting Started with Javascript

Step 1 of 2

Authenticating

First, let's install the Alpaca API from npm.

Run npm install @alpacahq/alpaca-trade-api to install the API.

Now, we can import and initialize our Alpaca module.

const Alpaca = require('@alpacahq/alpaca-trade-api')
const alpaca = new Alpaca({
  keyId: YOUR_KEY_ID, // Paste your key id here
  secretKey: YOUR_SECRET,// Paste your secret key here
  paper: true
})

To start, let's just get your account info.

alpaca.getAccount().then(account =>
  console.log('Your account: ', account)
)

We can run this code with node ./main.js

main.js