Record a swap event
curl --request POST \
--url https://api.hypermid.io/v1/swap-event \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"provider": "<string>",
"from_chain": "<string>",
"from_token": "<string>",
"to_chain": "<string>",
"to_token": "<string>",
"amount_usd": 123,
"fee_usd": 123,
"tx_hash": "<string>",
"wallet_hash": "<string>",
"from_amount": "<string>",
"to_amount": "<string>",
"duration_seconds": 123,
"error_message": "<string>"
}
'import requests
url = "https://api.hypermid.io/v1/swap-event"
payload = {
"provider": "<string>",
"from_chain": "<string>",
"from_token": "<string>",
"to_chain": "<string>",
"to_token": "<string>",
"amount_usd": 123,
"fee_usd": 123,
"tx_hash": "<string>",
"wallet_hash": "<string>",
"from_amount": "<string>",
"to_amount": "<string>",
"duration_seconds": 123,
"error_message": "<string>"
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
provider: '<string>',
from_chain: '<string>',
from_token: '<string>',
to_chain: '<string>',
to_token: '<string>',
amount_usd: 123,
fee_usd: 123,
tx_hash: '<string>',
wallet_hash: '<string>',
from_amount: '<string>',
to_amount: '<string>',
duration_seconds: 123,
error_message: '<string>'
})
};
fetch('https://api.hypermid.io/v1/swap-event', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.hypermid.io/v1/swap-event",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'provider' => '<string>',
'from_chain' => '<string>',
'from_token' => '<string>',
'to_chain' => '<string>',
'to_token' => '<string>',
'amount_usd' => 123,
'fee_usd' => 123,
'tx_hash' => '<string>',
'wallet_hash' => '<string>',
'from_amount' => '<string>',
'to_amount' => '<string>',
'duration_seconds' => 123,
'error_message' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.hypermid.io/v1/swap-event"
payload := strings.NewReader("{\n \"provider\": \"<string>\",\n \"from_chain\": \"<string>\",\n \"from_token\": \"<string>\",\n \"to_chain\": \"<string>\",\n \"to_token\": \"<string>\",\n \"amount_usd\": 123,\n \"fee_usd\": 123,\n \"tx_hash\": \"<string>\",\n \"wallet_hash\": \"<string>\",\n \"from_amount\": \"<string>\",\n \"to_amount\": \"<string>\",\n \"duration_seconds\": 123,\n \"error_message\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.hypermid.io/v1/swap-event")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"provider\": \"<string>\",\n \"from_chain\": \"<string>\",\n \"from_token\": \"<string>\",\n \"to_chain\": \"<string>\",\n \"to_token\": \"<string>\",\n \"amount_usd\": 123,\n \"fee_usd\": 123,\n \"tx_hash\": \"<string>\",\n \"wallet_hash\": \"<string>\",\n \"from_amount\": \"<string>\",\n \"to_amount\": \"<string>\",\n \"duration_seconds\": 123,\n \"error_message\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.hypermid.io/v1/swap-event")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"provider\": \"<string>\",\n \"from_chain\": \"<string>\",\n \"from_token\": \"<string>\",\n \"to_chain\": \"<string>\",\n \"to_token\": \"<string>\",\n \"amount_usd\": 123,\n \"fee_usd\": 123,\n \"tx_hash\": \"<string>\",\n \"wallet_hash\": \"<string>\",\n \"from_amount\": \"<string>\",\n \"to_amount\": \"<string>\",\n \"duration_seconds\": 123,\n \"error_message\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"eventId": "evt_abc123",
"received": true
},
"error": null,
"meta": {
"requestId": "c9f0a1b2-c3d4-5678-2345-789012345678",
"timestamp": 1711234587,
"rateLimit": {
"limit": 2000,
"remaining": 1971,
"reset": 1711234627
}
}
}
Partner
Submit Swap Event
Submit a swap lifecycle event for tracking
POST
/
v1
/
swap-event
Record a swap event
curl --request POST \
--url https://api.hypermid.io/v1/swap-event \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"provider": "<string>",
"from_chain": "<string>",
"from_token": "<string>",
"to_chain": "<string>",
"to_token": "<string>",
"amount_usd": 123,
"fee_usd": 123,
"tx_hash": "<string>",
"wallet_hash": "<string>",
"from_amount": "<string>",
"to_amount": "<string>",
"duration_seconds": 123,
"error_message": "<string>"
}
'import requests
url = "https://api.hypermid.io/v1/swap-event"
payload = {
"provider": "<string>",
"from_chain": "<string>",
"from_token": "<string>",
"to_chain": "<string>",
"to_token": "<string>",
"amount_usd": 123,
"fee_usd": 123,
"tx_hash": "<string>",
"wallet_hash": "<string>",
"from_amount": "<string>",
"to_amount": "<string>",
"duration_seconds": 123,
"error_message": "<string>"
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
provider: '<string>',
from_chain: '<string>',
from_token: '<string>',
to_chain: '<string>',
to_token: '<string>',
amount_usd: 123,
fee_usd: 123,
tx_hash: '<string>',
wallet_hash: '<string>',
from_amount: '<string>',
to_amount: '<string>',
duration_seconds: 123,
error_message: '<string>'
})
};
fetch('https://api.hypermid.io/v1/swap-event', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.hypermid.io/v1/swap-event",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'provider' => '<string>',
'from_chain' => '<string>',
'from_token' => '<string>',
'to_chain' => '<string>',
'to_token' => '<string>',
'amount_usd' => 123,
'fee_usd' => 123,
'tx_hash' => '<string>',
'wallet_hash' => '<string>',
'from_amount' => '<string>',
'to_amount' => '<string>',
'duration_seconds' => 123,
'error_message' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.hypermid.io/v1/swap-event"
payload := strings.NewReader("{\n \"provider\": \"<string>\",\n \"from_chain\": \"<string>\",\n \"from_token\": \"<string>\",\n \"to_chain\": \"<string>\",\n \"to_token\": \"<string>\",\n \"amount_usd\": 123,\n \"fee_usd\": 123,\n \"tx_hash\": \"<string>\",\n \"wallet_hash\": \"<string>\",\n \"from_amount\": \"<string>\",\n \"to_amount\": \"<string>\",\n \"duration_seconds\": 123,\n \"error_message\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.hypermid.io/v1/swap-event")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"provider\": \"<string>\",\n \"from_chain\": \"<string>\",\n \"from_token\": \"<string>\",\n \"to_chain\": \"<string>\",\n \"to_token\": \"<string>\",\n \"amount_usd\": 123,\n \"fee_usd\": 123,\n \"tx_hash\": \"<string>\",\n \"wallet_hash\": \"<string>\",\n \"from_amount\": \"<string>\",\n \"to_amount\": \"<string>\",\n \"duration_seconds\": 123,\n \"error_message\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.hypermid.io/v1/swap-event")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"provider\": \"<string>\",\n \"from_chain\": \"<string>\",\n \"from_token\": \"<string>\",\n \"to_chain\": \"<string>\",\n \"to_token\": \"<string>\",\n \"amount_usd\": 123,\n \"fee_usd\": 123,\n \"tx_hash\": \"<string>\",\n \"wallet_hash\": \"<string>\",\n \"from_amount\": \"<string>\",\n \"to_amount\": \"<string>\",\n \"duration_seconds\": 123,\n \"error_message\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"eventId": "evt_abc123",
"received": true
},
"error": null,
"meta": {
"requestId": "c9f0a1b2-c3d4-5678-2345-789012345678",
"timestamp": 1711234587,
"rateLimit": {
"limit": 2000,
"remaining": 1971,
"reset": 1711234627
}
}
}
Submits a swap lifecycle event to Hypermid for analytics and tracking purposes. Use this to report when users interact with your swap UI or when swap steps are completed.
The event type. Possible values:
quote_requested, quote_received, swap_started, swap_signed, swap_completed, swap_failed, swap_cancelled.The transaction ID or quote ID associated with this event.
Source chain ID.
Destination chain ID.
Source token address.
Destination token address.
Amount being swapped.
Transaction hash (for signed/completed/failed events).
Additional metadata to attach to the event.
{
"data": {
"eventId": "evt_abc123",
"received": true
},
"error": null,
"meta": {
"requestId": "c9f0a1b2-c3d4-5678-2345-789012345678",
"timestamp": 1711234587,
"rateLimit": {
"limit": 2000,
"remaining": 1971,
"reset": 1711234627
}
}
}
await client.submitSwapEvent({
event: "swap_completed",
transactionId: "txn_abc123",
fromChain: 1,
toChain: 42161,
fromToken: "0x0000000000000000000000000000000000000000",
toToken: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
fromAmount: "1000000000000000000",
txHash: "0xCompletedTxHash",
metadata: {
userAgent: "MyDeFiApp/1.0",
sessionId: "sess_xyz",
},
});
curl -X POST "https://api.hypermid.io/v1/swap-event" \
-H "Content-Type: application/json" \
-H "X-API-Key: your-api-key" \
-d '{
"event": "swap_completed",
"transactionId": "txn_abc123",
"fromChain": 1,
"toChain": 42161,
"txHash": "0xCompletedTxHash"
}'
body := `{
"event": "swap_completed",
"transactionId": "txn_abc123",
"fromChain": 1,
"toChain": 42161,
"txHash": "0xCompletedTxHash"
}`
req, _ := http.NewRequest("POST",
"https://api.hypermid.io/v1/swap-event",
strings.NewReader(body))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("X-API-Key", "your-api-key")
resp, _ := http.DefaultClient.Do(req)
Submitting swap events improves your analytics in the Partner Dashboard and helps Hypermid optimize route selection for your users.
Authorizations
Partner API key. Optional for public endpoints, required for /v1/partner/*.
Body
application/json
⌘I