Skip to content

amor71/alpaca-gcp-proxy

Repository files navigation

pdm-managed Sourcery

alpaca-gcp-proxy

GCP Function to securely proxy API calls to Alpaca Broker API, including Plaid and Stytch.

The repo is intended to simplify development of mobile / web apps on top Alpaca.

Proxies

Alpaca

All calls abbreviated by /alpaca will be forwarded to Alpaca, using the predefined Alpaca.Markets Broker API base URL.

Plaid

All calls abbreviated by /plaid will be forwarded to Plaid.

Stytch

All calls abbreviated by /stytch will be forwarded to Stych.

General

The proxy function can log requests & responses (based on the DEBUG environment variable)

The function uses security best practices to ensure compliance and security of Alpaca credentials.

Deployment

The project is deployed using GCP Cloud Build. The deployment will create a proxy end-point. It is suggested to set up a deployment trigger in CloudBuild.

Secrets

Alpaca

Add two secrets to GCP Secrets Manager:

  • alpaca_api_key
  • alpaca_api_secret

Obtained after registering to Alpaca Broker API

Plaid

  • plaid_client_id
  • plaid_secret

Obtained after registering to Plaid

Stytch

  • stytch_projet_id
  • stytch_secret

Obtained after registering to Stytch

General

Once deployed, the GCP Function service account needs to be added to the Secrets with role Secret Accessor

Environment Variables

  • PROJECT_ID: GCP project-id hosting GCP Function and secret
  • ALPACA_BASE_URL: Alpaca base URL defaults to sandbox
  • PLAID_BASE_URL: Plaid base URL default to sandbox
  • STYTCH_BASE_URL: Stytch base URL default to test
  • DEBUG: "True"/"False" (default "True") log both request and response