Acquiring a v2 Integrator ID. Connect with the Squid team and we will enable your existing integratorID from a v1 Integrator ID to a v2.1 Integrator ID.
The /route endpoint is now POST. /status is still a /GET request.
Our SDK handles this behind the scenes. No changes needed
// Get the swap route using Squid SDKconst { route,requestId } =awaitsquid.getRoute(params);
// Function to get the optimal route for the swap using Squid APIconstgetRoute=async (params:any) => {try {constresult=awaitaxios.post("https://apiplus.squidrouter.com/v2/route", params, { headers: {"x-integrator-id": integratorId,"Content-Type":"application/json", }, } );constrequestId=result.headers["x-request-id"]; // Retrieve request ID from response headersreturn { data:result.data, requestId: requestId }; } catch (error) {if (error.response) {console.error("API error:",error.response.data); }console.error("Error with parameters:", params);throw error; }};
// Function to get Squid SDK instanceconstgetSDK= ():Squid=> {constsquid=newSquid({ baseUrl:"https://apiplus.squidrouter.com", integratorId: integratorId, });return squid;};
Add integrator-id to headers of every GET and POST request:
// Function to get the optimal route for the swap using Squid APIconstgetRoute=async (params:any) => {try {constresult=awaitaxios.post("https://apiplus.squidrouter.com/v2/route", params, { headers: {"x-integrator-id": integratorId,"Content-Type":"application/json", }, } );constrequestId=result.headers["x-request-id"]; // Retrieve request ID from response headersreturn { data:result.data, requestId: requestId }; } catch (error) {if (error.response) {console.error("API error:",error.response.data); }console.error("Error with parameters:", params);throw error; }};
V2.1 Parameters
const params = { fromChain: number | string; //the chainID assets are being bridged FROM toChain: number | string; //the chainID assets are being bridged TO fromToken: string; //the asset address being swapped FROM, "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE" for native assets toToken: string; // The asset address being swapped TO, "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE" for native assets fromAmount: string; // The unadjusted decimal amount assets fromAddress: string; // The address FROM which assets are being sent to be bridged toAddress: string; // The address TO which bridged assets will be sent to slippage?: number; //OPTIONAL, If set it determines the max slippage across the route (0.01-99.99) 1 = 1% slippage. quoteOnly?: boolean; //OPTIONAL, If true, returns only a quote for the route. Omits transaction data needed for execution. Defaults to false};
API Migration
Migrating from v1 to v2.1, enables route requests under 1 second and sustainability scalability.. You can find out-of-the-box examples to implement Squid v2.1 in our github examples repo.
Route Request
The route request now uses the new endpoint and requires the updated Integrator ID in the headers.
Ensure you're passing the requestId obtained from the route request.
API Parameter Changes
Include slippage as a number instead of an object
API Response Handling
Extract requestId from response headers for status checks
Use route.transactionRequest for transaction execution
SDK Migration
If you're using the Squid SDK, you can find the key changes to implement below. You can find out-of-the-box examples to implement Squid v2.1 and our SDK in our Github examples repo.
SDK Initialization
Initialize the SDK with the new base URL and your updated Integrator ID:
There are two required modifications to Request Params
slippage: NUMBER(0.01-99.99); this number can be 0.01 to 99.99 and represents the associated slippage with a transaction. This parameter is now optional and will be dynamically set by Squid if not included.
Recommendation: Slippage is an optional parameter. We recommend you don’t set the slippage value so it is dynamically set by Squid during the route request
we have added a fundAmount and fundToken to preHooks. We have also added a provider, description , and logoURI to the both the preHook and postHook call.