You've successfully subscribed to Alpaca Learn - Developer API Trading Tutorials, Code Samples
Great! Next, complete checkout for full access to Alpaca Learn - Developer API Trading Tutorials, Code Samples
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.
Success! Your billing info is updated.
Billing info update failed.
Broker API

Easily allow users to fund their account with Plaid and Broker API

Christie Ruales
Christie Ruales

Since the release of Ribbit, our open source reference implementation of a commission-free trading app, we walked through how to quickly mock up the account onboarding process of your own app using Ribbit as an example.

Quickly mock up the account onboarding process of your commission-free trading app
Account onboarding comes with asking lots of questions. In this post, learn how to set up the initial version of the onboarding process as quickly as possible to start testing and improving the flow.

In this article, we dive into the core functionality of any trading app - account funding and executing orders. We point to the specific API calls you can leverage through Broker API and reference Ribbit to demonstrate how our products can be used in your own app!

To Recap, What is Ribbit?

While our Broker API is easy to use, visualizing how API calls translate to a specific user experience can be tricky. To help speed up your app development and help you focus on getting your app out to users, we created Ribbit. Ribbit is an open source commission-free trading app built on the Alpaca Broker API to demonstrate just how easy it is to build a fully functional trading app using our products.

How Does Ribbit Accomplish Funding?

There are multiple ways to enable your users to fund their Alpaca brokerage accounts to enable them to start trading. Ribbit uses ACH transfers via Plaid. This is the method we will be exploring in this article. For more information on other funding methods, see our Funding API documentation here.

Ribbit uses Plaid. Using Plaid Link, a drop-in client-side integration for the Plaid API, you can allow your users to safely link their financial account to their Alpaca brokerage account. Plaid validates all the bank information so all Alpaca needs to do is link the bank account to a brokerage account.

How Does it Work?

Ribbit receives the user’s bank information as a token from the Plaid API. This Plaid token can then be passed to Alpaca’s ACH Relationships API to establish a connection between a specific bank account and an Alpaca brokerage account. See the sample request below.

POST /v1/accounts/{account_id}/ach_relationships
“Processor_token”: "processor-sandbox-161c86dd-d470-47e9-a741-d381c2b2cb6f"

As a demo app, Ribbit uses a sandbox environment which simulates production environment behavior. It also connects to the Plaid sandbox environment which lets you enter your credentials as `user_good` and `pass_good`  to connect with any banks shown in the app. This makes it easy to test out user funding flows before making your app live.

Step 2: Depositing and Withdrawing Money

Once an ACH relationship has been created the transfer of funds into the brokerage account is initiated by the Transfers API. Using Alpaca’s sandbox environment Ribbit simulates the ACH transactions and the virtual money is credited in the user’s account instantly.

Let’s Trade!

Once your users fund their Alpaca brokerage account, how do they start trading? Our APIs make it incredibly simple to build this functionality into your app. With our Trading API, they have access to real-time market data, commission free, fractional trading* and more. Now let’s dive into the specific API requests that Ribbit utilizes to allow users to trade.

From Ribbit’s home page, users can click the Search icon to find specific stocks. All of the tradable assets that Alpaca offers can be queried using our Assets API.

Let’s say a user is interested in the stock TSLA. Ribbit offers an overview of TSLA’s historical and real time price data, how much funds the user has in their account, and the option to buy or sell. When it comes to managing stock market data, Alpaca helps provide seamless integration via our Market Data API.

Now that the user has funds in their account, they are ready to buy! They have the ability to enter their desired amount either through the quantity of shares or the notional amount in US Dollars. Once the user hits buy, Ribbit’s backend uses our Orders API to execute the order. Since Ribbit is connected to the sandbox environment, an order execution simulator engine runs that executes it using the real-time market price. This makes it easy to test trading functionality before you launch your app to users.

Once the order has been executed, Ribbit’s homepage will reflect the value of the user’s portfolio in real time. This is accomplished through our Portfolio History API. This endpoint can be used to build a graphical representation of your user’s portfolio.

What’s next?

Now that you’ve seen our funding and trading APIs in action, you can get started on integrating this into your own trading app! Since Ribbit is a reference application, we highly encourage you to explore and test out different user experiences and even add on more features unique to your app. We invite you to check out our Broker API documentation to see what else you can accomplish with our products.

Example Mobile App
See what you can build with the Broker API!

As an API-first product company, we are committed to providing the best developer experience. If you have feedback or questions, don’t hesitate to get in touch at [email protected] or @AlpacaHQ on Twitter.

Get details at

Commission-Free trading means that there are no commission charges for Alpaca self-directed individual cash brokerage accounts that trade U.S. listed securities through an API. Relevant SEC and FINRA fees may apply.

*Alpaca does not make recommendations with regard to fractional share trading, whether to use fractional shares at all, or whether to invest in any specific security. A security’s eligibility on the list of fractional shares available for trading is not an endorsement of any of the securities, nor is it intended to convey that such stocks have low risk. Fractional share transactions are executed either on a principal or riskless principal basis, and can only be bought or sold with market orders during normal market hours.

Please note that this code is for example use only and is not intended to be used for distribution. The code is provided as an open-source for the purpose of demonstration of the Broker API usage. It is not designed for production use and Alpaca does not offer official support of the code.

This article is for educational and informational purposes only. All screenshots are for illustrative purposes only. Alpaca does not recommend any specific securities or investment strategies.
Brokerage services are provided by Alpaca Securities LLC ("Alpaca"), member FINRA/SIPC, a wholly-owned subsidiary of AlpacaDB, Inc. Technology and services are offered by AlpacaDB, Inc.

Interested in learning more about Broker API?

Don't miss out on any updates about our Broker API suite of solutions! Share your details with us and be the first to know about our latest content.

Broker API