Overview
The Fibrous Router API V2 introduces enhanced features and improved response structure while maintaining backward compatibility with V1 endpoints. This guide will help you migrate your integration to take advantage of V2 features.Quick Reference: Endpoint Mapping
| V1 Endpoint | V2 Endpoint | HTTP Method | What Changed |
|---|---|---|---|
/{network}/route | /{network}/v2/route | GET | Same functionality, added integrator support |
/{network}/calldata | /{network}/v2/routeAndCallData | GET | Renamed - Same functionality (route + calldata in one call) |
/{network}/execute | /{network}/v2/calldata | POST | Renamed - Same functionality (generate calldata from route) |
/{network}/healthcheck | /{network}/v2/healthcheck | GET | Same functionality, added meta field |
- V1
/calldata→ V2/routeAndCallData: Endpoint renamed for clarity (still GET, still returns route + calldata) - V1
/execute→ V2/calldata: Endpoint renamed for clarity (still POST, still generates calldata from route)
What’s New in V2
Integrator Features
Support for integrator fees and surplus sharing to monetize your integration
Enhanced Metadata
All responses include API version and timestamp for better tracking
Endpoint Reorganization
Endpoints renamed for clarity:
/calldata → /routeAndCallData, /execute → /calldataImproved Structure
Better organized response format with consistent meta fields
Key Differences
Response Structure
V1 Response:Endpoint Mapping
V2 API reorganizes endpoint names for better clarity. Here’s how V2 endpoints map to V1:| V1 Endpoint | V2 Endpoint | Description | HTTP Method |
|---|---|---|---|
/{network}/route | /{network}/v2/route | Find optimal route | GET |
/{network}/calldata | /{network}/v2/routeAndCallData | Get route and calldata in one request | GET |
/{network}/execute | /{network}/v2/calldata | Generate calldata from existing route | POST |
/{network}/healthcheck | /{network}/v2/healthcheck | Health check | GET |
Important: The V2 endpoint names better reflect their functionality:
routeAndCallData(V2) replacescalldata(V1) - combines route finding and calldata generationcalldata(V2) replacesexecute(V1) - generates calldata from a pre-calculated route
Integrator Features
V2 supports monetization through integrator fees or surplus sharing:- Integrator Fee: Charge a percentage (0-5%) on swaps routed through your integration
- Integrator Surplus: Share in surplus value (0-50%) when routing finds better prices
- Note: You cannot use both fee and surplus in the same request
Migration Steps
Step 1: Update Base URL
Change your base URL from:Step 2: Handle Meta Field
All V2 responses include ameta field. Update your response handling:
Step 3: Update Route Endpoint
V1:Step 4: Update Calldata Endpoint (V1 → routeAndCallData V2)
Important: V1’s/calldata endpoint is now /routeAndCallData in V2.
V1 /calldata endpoint:
/routeAndCallData endpoint:
Migration Note: If you were using V1’s
/calldata endpoint, update your code to use /v2/routeAndCallData. The functionality is the same - it gets route and calldata in one request.Step 5: Update Execute Endpoint (V1 → calldata V2)
Important: V1’s/execute endpoint is now /calldata in V2.
V1 /execute endpoint:
/calldata endpoint:
Migration Note: If you were using V1’s
/execute endpoint, update your code to use /v2/calldata. The functionality is the same - it generates calldata from a pre-calculated route.Step 6: Handle Integrator Features (Optional)
If you want to monetize your integration:Parameter Changes
New Optional Parameters
All V2 endpoints support these optional integrator parameters:| Parameter | Type | Description |
|---|---|---|
integratorAddress | string | Wallet address to receive fees/surplus |
integratorFeePercentageBps | number | Fee percentage in basis points (0-500, max 5%) |
integratorSurplusPercentageBps | number | Surplus percentage in basis points (0-5000, max 50%) |
Response Field Changes
| Field | V1 | V2 | Notes |
|---|---|---|---|
meta | ❌ | ✅ | Always present in V2 |
outputAmountAfterFee | ❌ | ✅ | Present when integrator fee is used |
integratorAddress | ❌ | ✅ | Present when integrator features are used |
integratorFeePercentageBps | ❌ | ✅ | Present when integrator fee is set |
integratorSurplusPercentageBps | ❌ | ✅ | Present when integrator surplus is set |
integratorName | ❌ | ✅ | Present when API key is used |
Code Examples
Complete Migration Example
With Integrator Features
Backward Compatibility
V1 endpoints remain available and fully functional. You can migrate at your own pace without breaking existing integrations.
- V1 endpoints:
https://api.fibrous.finance/{network}/* - V2 endpoints:
https://api.fibrous.finance/{network}/v2/*
Testing Your Migration
-
Test with small amounts first
- Verify responses match expected format
- Check that meta fields are present
- Validate integrator features if used
-
Monitor API version in responses
- Log
meta.apiVersionto ensure you’re using V2 - Track
meta.timestampfor debugging
- Log
-
Verify integrator features
- Test with API key authentication
- Verify fee calculations
- Check outputAmountAfterFee values
Common Issues
Issue: Missing Meta Field
Problem: Response doesn’t includemeta field
Solution: Ensure you’re using /{network}/v2/* endpoints, not /{network}/*
Issue: Integrator Features Not Working
Problem: Integrator parameters are ignored Solution:- Obtain an API key: Integrator features require an API key from Fibrous Finance. Contact us at [email protected] or join our Discord to request an API key
- Verify API key is included in request headers as
X-API-Key - Check that integrator address is valid
- Ensure only one of fee or surplus is set
Issue: Route and Calldata Endpoint Returns 404
Problem:/{network}/v2/routeAndCallData not found
Solution: This endpoint is V2-only. Use /{network}/v2/routeAndCallData (not /{network}/routeAndCallData)
Note: If you were using V1’s /calldata endpoint, remember it’s now /v2/routeAndCallData in V2.
Issue: Endpoint Name Confusion
Problem: Confused about which V2 endpoint to use Solution: Use this mapping guide:| What You Need | V1 Endpoint | V2 Endpoint |
|---|---|---|
| Get route only | /{network}/route | /{network}/v2/route |
| Get route + calldata in one call | /{network}/calldata | /{network}/v2/routeAndCallData |
| Generate calldata from existing route | /{network}/execute | /{network}/v2/calldata |
- V1’s
/calldata→ V2’s/routeAndCallData(GET request, gets route and calldata together) - V1’s
/execute→ V2’s/calldata(POST request, generates calldata from route)
Next Steps
- Review V2 Route Endpoint documentation
- Check V2 Calldata Endpoint for POST endpoint details
- Explore Integrator Features for monetization
Support
If you encounter issues during migration:- Check our FAQ
- Join our Discord for community support
- Contact us at [email protected]