Complete Integration Guide
A comprehensive guide to integrating with the Glider API
This guide provides a detailed walkthrough of integrating with the Glider API, covering every aspect of portfolio creation, management, and automation.
Glider is a platform for creating and automating on-chain portfolios. Define your asset allocations, deposit tokens, and let Glider automate rebalancing based on your specifications.
Glider is currently in early access.
We’re currently operating on
Base with plans to expand to more chains.
Terminology
- Portfolio: A set of assets managed by the Glider platform according to your specifications.
- Portfolio Template: A blueprint that defines the composition and behavior of a portfolio, including asset allocations and rebalancing parameters.
- Vault: A secure smart contract that holds your assets on-chain and allows for automated management.
- Rebalance: The process of adjusting your portfolio’s asset allocation to match your target allocation.
- Session Key: A secure signature-based authentication method that allows Glider to execute transactions on behalf of your portfolio.
- Automation: Scheduled rebalancing of your portfolio based on your chosen time intervals or threshold triggers.
Authentication
Glider is currently in early access. Sign up for the waitlist on the Glider App.
Prerequisites
Before you begin, you’ll need:
- A Glider platform account
- An API key for authentication
- A wallet for signing portfolio creation and transaction permissions
Authenticate
First, you need to get an API key that will authenticate your requests to the Glider API.
- Log in to the Glider platform
- Navigate to your profile settings
- Select “API Keys” and create a new key
- Store your API key securely - you’ll need to include it in the header of all API requests
API Response Format
All Glider API responses follow a consistent format:
Error responses include additional error information:
Portfolio Management Lifecycle
Let’s walk through the complete lifecycle of portfolio management using the Glider API.
1. Portfolio Creation Process
Portfolio creation follows a signature-based authentication flow to ensure secure user authorization:
1.1 Request a signature message
First, request a message that your user will sign to authorize portfolio creation:
The response will contain a signature request object that includes a message the user needs to sign:
1.2 Sign the message with the user’s wallet
Next, have the user sign this message with their wallet. How you implement this will depend on the wallet provider you’re using:
1.3 Create the portfolio with the signed message
Once you have the signature, submit it along with the original request data to create the portfolio:
The response will include the newly created portfolio ID and other details:
2. Portfolio Configuration
If you didn’t include template data during portfolio creation, or if you need to update an existing portfolio’s configuration, you can use the update endpoint:
2.1 Template Structure
The template data defines how your portfolio is structured:
name
: The display name of the portfolio (optional)description
: A description of the portfolio (optional)entry
: The portfolio structure (required)blockType
: Type of portfolio structure (required, must be “weight” for weighted allocation)weightType
: For weighted portfolios, specifies how weights are calculated (required, must be “specified-percentage”)weightings
: Array of string percentages for each asset (required, must match the number of children)children
: Array of assets or nested structures (required, at least 1 child)- For assets:
{ blockType: "asset", assetId: "0xTokenAddress:chainId" }
- The assetId must follow the format
0xTokenAddress:chainId
- For assets:
tradingSettings
: Rebalancing configuration (optional)type
: Type of rebalancing - “threshold” or “calendar” (required if tradingSettings is provided)triggerPercentage
: Deviation percentage to trigger rebalancing (required if type is “threshold”)frequency
: Rebalance frequency (required if type is “calendar”): “daily”, “weekly”, “biweekly”, “monthly”
The sum of all percentages in weightings
must equal 100, and the number of weightings must match the number of children in the template.
3. Portfolio Funding
3.1 Depositing Assets
To deposit assets into a portfolio, you first need to get the deposit instructions:
The response will include transaction data that you can use to create a transaction for the user to sign:
You’ll need to create a transaction with this data and have the user sign and send it:
3.2 Withdrawing Assets
Withdrawing assets follows a similar pattern:
4. Portfolio Automation
4.1 Starting Automation
Once your portfolio is funded, you can start automated rebalancing:
This sets up a schedule that will automatically rebalance the portfolio based on the trading settings defined in the template.
4.2 Checking Automation Status
To check the current status of portfolio automation:
4.3 Pausing and Resuming Automation
You can pause automation when needed:
And resume it later:
4.4 Manually Triggering a Rebalance
You can also manually trigger a rebalance at any time:
5. Portfolio Monitoring
5.1 Getting Portfolio Details
To retrieve the current state of a portfolio:
This returns comprehensive data about the portfolio, including:
- Portfolio metadata (name, description, etc.)
- Assets and their balances
- Template configuration
- Vault addresses
5.2 Getting Portfolio Performance
To check the portfolio’s performance over time:
Available time windows include: 1d
, 7d
, 30d
, 90d
, 180d
, 1y
, all
.
5.3 Viewing Transactions
To view transaction history:
6. Advanced Portfolio Management
6.1 Executing Custom Transactions
For advanced use cases, you can execute custom transactions through the portfolio:
6.2 Archiving a Portfolio
To archive a portfolio that’s no longer needed:
Archived portfolios can be unarchived if needed:
6.3 Refreshing Session Keys
If a portfolio’s session keys need to be refreshed:
7. Listing and Filtering Portfolios
To retrieve a list of all portfolios for a specific user:
Available query parameters include:
userAddress
: Filter by owner addressportfolioId
: Filter by portfolio IDportfolioAddress
: Filter by portfolio vault addressportfolioChainId
: Filter by chain IDisArchived
: Filter for archived or active portfolioshasAutomation
: Filter for portfolios with automation enabledlimit
,offset
: For paginationsort
,order
: For sorting resultssearch
: Text searchchainId
: Filter by chain IDtag
: Filter by portfolio tagincludeAssets
: Include detailed asset datarealtime
: Use real-time blockchain data instead of cached data
Error Handling
The API uses standard HTTP response codes:
2xx
: Success4xx
: Client error (invalid request, authentication error, etc.)5xx
: Server error
All error responses follow this format:
Common error codes include:
INVALID_API_KEY
: The API key is missing or invalidINVALID_REQUEST
: The request is malformedPORTFOLIO_NOT_FOUND
: The specified portfolio doesn’t existPORTFOLIO_TEMPLATE_VALIDATION_ERROR
: The template data is invalidUNAUTHORIZED
: The user doesn’t have permission to perform this action
Best Practices
Rate Limiting
The API has rate limits to ensure fair usage. If you exceed these limits, you’ll receive a 429 Too Many Requests
response. Consider implementing:
- Exponential backoff for retries
- Caching frequently accessed data
- Batching requests where possible
Security
- Never expose your API key in client-side code
- Always validate user input before sending it to the API
- Use HTTPS for all API requests
- Implement proper error handling to avoid exposing sensitive information
Performance
- Fetch only the data you need
- Use pagination for large data sets
- Consider using the
includeAssets=false
parameter when listing portfolios if you don’t need asset details - Use the
realtime=false
parameter (default) for faster response times
Next Steps
Now that you understand the complete Glider API integration process, you can:
- Explore the API Reference for detailed endpoint documentation
- Review specific guides for Portfolio Creation, Deposits, or Automation
- Implement a full-featured portfolio management application using the Glider API