### Get Additional Requirements - Swift Source: https://docs.transak.com/api/whitelabel/kyc/get-additional-requirements.md Use Foundation's URLSession to perform a GET request. This example configures the request, starts the data task, and handles potential errors. ```swift import Foundation let request = NSMutableURLRequest(url: NSURL(string: "https://api-gateway-stg.transak.com/api/v2/kyc/additional-requirements?metadata%5BquoteId%5D=&apiKey=")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` -------------------------------- ### Install JWT Package (Go) Source: https://docs.transak.com/guides/how-to-decrypt-webhook-payload.md Install the Go JWT library from GitHub using the go get command. ```bash go get github.com/golang-jwt/jwt/v5 ``` -------------------------------- ### Get Orders using Go Source: https://docs.transak.com/api/whitelabel/orders/get-orders.md This Go example demonstrates making an HTTP GET request to the orders endpoint and printing the response body. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api-gateway-stg.transak.com/api/v2/orders" req, _ := http.NewRequest("GET", url, nil) res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get Order Details (Go) Source: https://docs.transak.com/api/public/get-order-by-order-id.md Implement a GET request in Go to fetch order information. This example demonstrates setting headers and reading the response body. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api-stg.transak.com/partners/api/v2/order/:orderId" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("access-token", "") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get Pricing Quotes with Ruby SDK Source: https://docs.transak.com/api/public/get-price.md Fetch pricing quotes using Ruby's Net::HTTP library. This example sets up an SSL connection and makes a GET request. Ensure you have the 'uri' and 'net/http' gems installed. ```ruby require 'uri' require 'net/http' url = URI("https://api-stg.transak.com/api/v1/pricing/public/quotes?partnerApiKey=&fiatCurrency=fiatCurrency&cryptoCurrency=cryptoCurrency&network=network&isBuyOrSell=BUY") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) response = http.request(request) puts response.read_body ``` -------------------------------- ### Get User Limits in PHP Source: https://docs.transak.com/api/whitelabel/user/get-user-limits.md This example uses the Guzzle HTTP client. Make sure to install Guzzle via Composer. ```php request('GET', 'https://api-gateway-stg.transak.com/api/v2/orders/user-limit?isBuyOrSell=BUY&paymentCategory=&kycType=&fiatCurrency='); echo $response->getBody(); ``` -------------------------------- ### Get KYC ID Proof Status (Go) Source: https://docs.transak.com/api/whitelabel/kyc/get-kyc-idproof-status.md This Go example demonstrates making an HTTP GET request to the API. It reads and prints the response body. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api-gateway-stg.transak.com/api/v2/kyc/id-proof-status?workFlowRunId=" req, _ := http.NewRequest("GET", url, nil) res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get Orders using Swift Source: https://docs.transak.com/api/whitelabel/orders/get-orders.md This Swift example demonstrates making a GET request using URLSession and NSMutableURLRequest. It includes basic error checking. ```swift import Foundation let request = NSMutableURLRequest(url: NSURL(string: "https://api-gateway-stg.transak.com/api/v2/orders")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` -------------------------------- ### Get Fiat Currencies (Go) Source: https://docs.transak.com/api/whitelabel/lookup/get-fiat-currencies.md This Go example demonstrates how to perform an HTTP GET request to fetch fiat currency information. It prints both the response status and the body. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api-gateway-stg.transak.com/api/v2/lookup/currencies/fiat-currencies?apiKey=" req, _ := http.NewRequest("GET", url, nil) res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get Webhooks using Go Source: https://docs.transak.com/api/public/get-webhooks.md This Go example demonstrates making an HTTP GET request to the webhooks endpoint using the standard `net/http` package. It prints both the response status and the body. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api-stg.transak.com/partners/api/v2/webhooks" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("access-token", "") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get Additional Requirements - C# Source: https://docs.transak.com/api/whitelabel/kyc/get-additional-requirements.md Employ the RestSharp library to execute a GET request. This example shows how to instantiate the client and execute the request, capturing the response. ```csharp using RestSharp; var client = new RestClient("https://api-gateway-stg.transak.com/api/v2/kyc/additional-requirements?metadata%5BquoteId%5D=&apiKey="); var request = new RestRequest(Method.GET); IRestResponse response = client.Execute(request); ``` -------------------------------- ### Get Additional Requirements - Java Source: https://docs.transak.com/api/whitelabel/kyc/get-additional-requirements.md Leverage the Unirest library to simplify HTTP requests. This example demonstrates a straightforward GET request and retrieves the response as a string. ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("https://api-gateway-stg.transak.com/api/v2/kyc/additional-requirements?metadata%5BquoteId%5D=&apiKey=") .asString(); ``` -------------------------------- ### Get Quote using Go Source: https://docs.transak.com/api/ledger-off-ramp/get-quote.md This Go example shows how to perform a GET request to the quote API using the standard `net/http` package. It includes reading the response body. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api-stg.transak.com/ledger/v1/quote?to=&from=&payment-method=&amount=" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("x-api-key", "") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Onboard New User - C# Source: https://docs.transak.com/api/whitelabel/user/onboard-user-auth-reliance.md This C# example demonstrates how to onboard a new user using the RestSharp library to interact with the Transak API. ```csharp using RestSharp; var client = new RestClient("https://api-gateway-stg.transak.com/api/v2/user/onboard"); var request = new RestRequest(Method.POST); request.AddHeader("x-user-identifier", "test@gmail.com"); request.AddHeader("x-access-token", ""); IRestResponse response = client.Execute(request); ``` -------------------------------- ### Get KYC ID Proof Status (PHP) Source: https://docs.transak.com/api/whitelabel/kyc/get-kyc-idproof-status.md This PHP example uses the Guzzle HTTP client to send a GET request to the API. Ensure you have Guzzle installed via Composer. ```php request('GET', 'https://api-gateway-stg.transak.com/api/v2/kyc/id-proof-status?workFlowRunId='); echo $response->getBody(); ``` -------------------------------- ### Onboard New User Source: https://docs.transak.com/api/whitelabel/user/onboard-user-auth-reliance.md Code examples for onboarding a new user. ```APIDOC ## POST /api/v2/user/onboard ### Description Onboards a new user. ### Method POST ### Endpoint https://api-gateway-stg.transak.com/api/v2/user/onboard ### Headers - **x-user-identifier** (string) - Required - The identifier for the user. - **x-access-token** (string) - Required - The access token for authentication. ``` ```Python import requests url = "https://api-gateway-stg.transak.com/api/v2/user/onboard" headers = { "x-user-identifier": "test@gmail.com", "x-access-token": "" } response = requests.post(url, headers=headers) print(response.json()) ``` ```JavaScript const url = 'https://api-gateway-stg.transak.com/api/v2/user/onboard'; const options = { method: 'POST', headers: {'x-user-identifier': 'test@gmail.com', 'x-access-token': ''} }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```Go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api-gateway-stg.transak.com/api/v2/user/onboard" req, _ := http.NewRequest("POST", url, nil) req.Header.Add("x-user-identifier", "test@gmail.com") req.Header.Add("x-access-token", "") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```Ruby require 'uri' require 'net/http' url = URI("https://api-gateway-stg.transak.com/api/v2/user/onboard") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["x-user-identifier"] = 'test@gmail.com' request["x-access-token"] = '' response = http.request(request) puts response.read_body ``` ```Java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api-gateway-stg.transak.com/api/v2/user/onboard") .header("x-user-identifier", "test@gmail.com") .header("x-access-token", "") .asString(); ``` -------------------------------- ### Start Development Server Source: https://docs.transak.com/guides/biconomy.md Run this command to start the Vite development server. ```shell bun dev ``` -------------------------------- ### Get Quote using PHP (Guzzle) Source: https://docs.transak.com/api/whitelabel/lookup/get-quote.md This PHP example uses the Guzzle HTTP client to make a GET request to the Transak API and retrieve quote details. Ensure you have Guzzle installed via Composer. ```php request('GET', 'https://api-gateway-stg.transak.com/api/v2/lookup/quotes?apiKey=&fiatCurrency=&cryptoCurrency=&isBuyOrSell=&network=&paymentMethod='); echo $response->getBody(); ``` -------------------------------- ### Onboard Existing User Source: https://docs.transak.com/api/whitelabel/user/onboard-user-auth-reliance.md Code examples for onboarding an existing user. ```APIDOC ## POST /api/v2/user/onboard ### Description Onboards an existing user. ### Method POST ### Endpoint https://api-gateway-stg.transak.com/api/v2/user/onboard ### Headers - **x-user-identifier** (string) - Required - The identifier for the user. - **x-access-token** (string) - Required - The access token for authentication. ``` ```Python import requests url = "https://api-gateway-stg.transak.com/api/v2/user/onboard" headers = { "x-user-identifier": "test@gmail.com", "x-access-token": "" } response = requests.post(url, headers=headers) print(response.json()) ``` ```JavaScript const url = 'https://api-gateway-stg.transak.com/api/v2/user/onboard'; const options = { method: 'POST', headers: {'x-user-identifier': 'test@gmail.com', 'x-access-token': ''} }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```Go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api-gateway-stg.transak.com/api/v2/user/onboard" req, _ := http.NewRequest("POST", url, nil) req.Header.Add("x-user-identifier", "test@gmail.com") req.Header.Add("x-access-token", "") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```Ruby require 'uri' require 'net/http' url = URI("https://api-gateway-stg.transak.com/api/v2/user/onboard") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["x-user-identifier"] = 'test@gmail.com' request["x-access-token"] = '' response = http.request(request) puts response.read_body ``` ```Java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api-gateway-stg.transak.com/api/v2/user/onboard") .header("x-user-identifier", "test@gmail.com") .header("x-access-token", "") .asString(); ``` ```PHP request('POST', 'https://api-gateway-stg.transak.com/api/v2/user/onboard', [ 'headers' => [ 'x-access-token' => '', 'x-user-identifier' => 'test@gmail.com', ], ]); echo $response->getBody(); ``` ```C# using RestSharp; var client = new RestClient("https://api-gateway-stg.transak.com/api/v2/user/onboard"); var request = new RestRequest(Method.POST); request.AddHeader("x-user-identifier", "test@gmail.com"); request.AddHeader("x-access-token", ""); IRestResponse response = client.Execute(request); ``` ```Swift import Foundation let headers = [ "x-user-identifier": "test@gmail.com", "x-access-token": "" ] let request = NSMutableURLRequest(url: NSURL(string: "https://api-gateway-stg.transak.com/api/v2/user/onboard")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` -------------------------------- ### JavaScript: Onboard Existing User Source: https://docs.transak.com/api/whitelabel/user/onboard-user-auth-reliance.md This JavaScript example shows how to onboard an existing user using the Transak API. It utilizes the fetch API and requires correct 'x-user-identifier' and 'x-access-token' headers. ```javascript const url = 'https://api-gateway-stg.transak.com/api/v2/user/onboard'; const options = { method: 'POST', headers: {'x-user-identifier': 'test@gmail.com', 'x-access-token': ''} }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` -------------------------------- ### Get Additional Requirements (C#) Source: https://docs.transak.com/api/whitelabel/kyc/get-additional-requirements.md A C# example using RestSharp to fetch additional KYC requirements from the Transak API. Make sure RestSharp is installed. ```csharp using RestSharp; var client = new RestClient("https://api-gateway-stg.transak.com/api/v2/kyc/additional-requirements?metadata%5BquoteId%5D=&apiKey="); var request = new RestRequest(Method.GET); IRestResponse response = client.Execute(request); ``` -------------------------------- ### Get KYC Reliance Status in PHP Source: https://docs.transak.com/api/whitelabel/kyc-reliance/get-kyc-reliance-status.md This PHP example uses the Guzzle HTTP client to fetch KYC reliance status. Make sure to install Guzzle via Composer. ```php request('GET', 'https://api-gateway-stg.transak.com/api/v2/kyc/share-token-status?quoteId=&kycShareTokenProvider=&kycShareToken='); echo $response->getBody(); ``` -------------------------------- ### Connect wallet and initialize MEE client Source: https://docs.transak.com/guides/biconomy.md Sets up the wallet client, retrieves the user's account, initializes the MultichainSmartAccount (Orchestrator), and creates the MEE client for transaction coordination. ```typescript const usdcAddress = '0x036CbD53842c5426634e7929541eC2318f3dCF7e'; const [account, setAccount] = useState(null); const [walletClient, setWalletClient] = useState(null); const [meeClient, setMeeClient] = useState(null); const [orchestrator, setOrchestrator] = useState(null); const connectAndInit = async () => { if (typeof window.ethereum === 'undefined') { alert('MetaMask not detected'); return; } const wallet = createWalletClient({ chain: baseSepolia, transport: custom(window.ethereum) }); setWalletClient(wallet); const [address] = await wallet.requestAddresses(); setAccount(address); const multiAccount = await toMultichainNexusAccount({ chainConfigurations: [ { chain: baseSepolia, transport: http(), version: getMEEVersion(MEEVersion.V2_1_0) } ], signer: createWalletClient({ account: address, transport: custom(window.ethereum) }) }); setOrchestrator(multiAccount); const mee = await createMeeClient({ account: multiAccount }); setMeeClient(mee); }; ``` -------------------------------- ### Get Pricing Quotes with PHP SDK Source: https://docs.transak.com/api/public/get-price.md Fetch pricing quotes using the Guzzle HTTP client in PHP. This example assumes you have Guzzle installed via Composer and the autoloader included. ```php request('GET', 'https://api-stg.transak.com/api/v1/pricing/public/quotes?partnerApiKey=&fiatCurrency=fiatCurrency&cryptoCurrency=cryptoCurrency&network=network&isBuyOrSell=BUY'); echo $response->getBody(); ?> ``` -------------------------------- ### Install Project Dependencies Source: https://docs.transak.com/guides/biconomy.md Install the required libraries for your project, including Biconomy and Wagmi. ```shell bun add viem wagmi @biconomy/abstractjs @tanstack/react-query ``` -------------------------------- ### Get User Details - PHP Source: https://docs.transak.com/api/whitelabel/user/get-user-details.md This PHP example utilizes the Guzzle HTTP client to fetch user details. Make sure Guzzle is installed via Composer. The API key should be appended to the request URL. ```php request('GET', 'https://api-gateway-stg.transak.com/api/v2/user/?apiKey='); echo $response->getBody(); ``` -------------------------------- ### Initialize Transak SDK v1 (JavaScript) Source: https://docs.transak.com/integration/web/js-sdk.md Initialize the Transak SDK with configuration and set up event listeners. This example is for JavaScript projects using SDK v1. ```javascript import transakSDK from '@transak/transak-sdk'; let transak = new transakSDK({ widgetUrl: "https://global-stg.transak.com?apiKey=YOUR_API_KEY&sessionId=", // ..... }); transak.init(); // To get all the events transak.on(transak.ALL_EVENTS, (data) => { console.log(data); }); // This will trigger when the user closed the widget transak.on(transak.EVENTS.TRANSAK_WIDGET_CLOSE, (orderData) => { transak.close(); }); // This will trigger when the user marks payment is made transak.on(transak.EVENTS.TRANSAK_ORDER_SUCCESSFUL, (orderData) => { console.log(orderData); transak.close(); }); ``` -------------------------------- ### Create Order - Go Source: https://docs.transak.com/api/whitelabel/orders/create-order.md This Go program demonstrates creating an order using the standard net/http package. It constructs the request with the necessary headers and payload. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api-gateway-stg.transak.com/api/v2/orders" payload := strings.NewReader("{\n \"quoteId\": \"\",\n \"paymentInstrumentId\": \"\",\n \"walletAddress\": \"\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("authorization", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get Orders using Python Source: https://docs.transak.com/api/whitelabel/orders/get-orders.md Use the requests library to make a GET request to the orders endpoint. Ensure you have the 'requests' library installed. ```python import requests url = "https://api-gateway-stg.transak.com/api/v2/orders" response = requests.get(url) print(response.json()) ``` -------------------------------- ### Get Fiat Currencies (C#) Source: https://docs.transak.com/api/whitelabel/lookup/get-fiat-currencies.md This C# example uses the RestSharp library to execute a GET request to the API endpoint for fiat currencies. ```csharp using RestSharp; var client = new RestClient("https://api-gateway-stg.transak.com/api/v2/lookup/currencies/fiat-currencies?apiKey="); var request = new RestRequest(Method.GET); IRestResponse response = client.Execute(request); ``` -------------------------------- ### Onboard New User - PHP Source: https://docs.transak.com/api/whitelabel/user/onboard-user-auth-reliance.md Use this PHP snippet to onboard a new user via the Transak API. Ensure you have the Guzzle HTTP client installed. ```php request('POST', 'https://api-gateway-stg.transak.com/api/v2/user/onboard', [ 'headers' => [ 'x-access-token' => '', 'x-user-identifier' => 'test@gmail.com', ], ]); echo $response->getBody(); ``` -------------------------------- ### Get KYC ID Proof Status (C#) Source: https://docs.transak.com/api/whitelabel/kyc/get-kyc-idproof-status.md A C# example using the RestSharp library to execute a GET request against the API endpoint. ```csharp using RestSharp; var client = new RestClient("https://api-gateway-stg.transak.com/api/v2/kyc/id-proof-status?workFlowRunId="); var request = new RestRequest(Method.GET); IRestResponse response = client.Execute(request); ``` -------------------------------- ### Onboard New User - Swift Source: https://docs.transak.com/api/whitelabel/user/onboard-user-auth-reliance.md Integrate new user onboarding with the Transak API using this Swift code example. It utilizes URLSession for making the POST request. ```swift import Foundation let headers = [ "x-user-identifier": "test@gmail.com", "x-access-token": "" ] let request = NSMutableURLRequest(url: NSURL(string: "https://api-gateway-stg.transak.com/api/v2/user/onboard")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` -------------------------------- ### Get User Limits in Python Source: https://docs.transak.com/api/whitelabel/user/get-user-limits.md Use the requests library to make a GET request to the user limits endpoint. Ensure the 'requests' library is installed. ```python import requests url = "https://api-gateway-stg.transak.com/api/v2/orders/user-limit" querystring = {"isBuyOrSell":"BUY","paymentCategory":"","kycType":"","fiatCurrency":""} response = requests.get(url, params=querystring) print(response.json()) ``` -------------------------------- ### Python: Get Sell Redirect URL Source: https://docs.transak.com/api/ledger-off-ramp/get-sell-redirect.md Use this Python snippet to make a GET request to the sell-redirect endpoint. Ensure you have the 'requests' library installed. ```python import requests url = "https://api-stg.transak.com/ledger/v1/sell-redirect" querystring = {"accountId":"","cryptoCurrency":"","fiatCurrency":"","cryptoAmount":"","paymentMethod":"","mode":"","bankResidency":"","ledgerTransactionId":""} headers = {"x-api-key": ""} response = requests.get(url, headers=headers, params=querystring) print(response.json()) ``` -------------------------------- ### Get KYC Requirement in Swift Source: https://docs.transak.com/api/whitelabel/kyc/get-kyc-requirement.md Employ URLSession to perform a GET request for KYC requirements. This example shows asynchronous data task handling. ```swift import Foundation let request = NSMutableURLRequest(url: NSURL(string: "https://api-gateway-stg.transak.com/api/v2/kyc/requirement?metadata%5BquoteId%5D=+&apiKey=")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` -------------------------------- ### Submit Source of Income (Swift) Source: https://docs.transak.com/api/whitelabel/kyc/submit-source-of-income.md This Swift example shows how to create and send an HTTP POST request using URLSession. It configures the request with the necessary headers. ```swift import Foundation let headers = ["Content-Type": "application/json"] let request = NSMutableURLRequest(url: NSURL(string: "https://api-gateway-stg.transak.com/api/v2/user/source-of-income")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` -------------------------------- ### Get KYC Requirement in C# Source: https://docs.transak.com/api/whitelabel/kyc/get-kyc-requirement.md Utilize RestSharp to send a GET request to the KYC requirement API. This example demonstrates basic API interaction. ```csharp using RestSharp; var client = new RestClient("https://api-gateway-stg.transak.com/api/v2/kyc/requirement?metadata%5BquoteId%5D=+&apiKey="); var request = new RestRequest(Method.GET); IRestResponse response = client.Execute(request); ``` -------------------------------- ### Submit Source of Income (Ruby) Source: https://docs.transak.com/api/whitelabel/kyc/submit-source-of-income.md This Ruby example shows how to make a POST request using Net::HTTP. It sets the Content-Type header and sends the request. ```ruby require 'uri' require 'net/http' url = URI("https://api-gateway-stg.transak.com/api/v2/user/source-of-income") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Content-Type"] = 'application/json' response = http.request(request) puts response.read_body ``` ```ruby require 'uri' require 'net/http' url = URI("https://api-gateway-stg.transak.com/api/v2/user/source-of-income") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Content-Type"] = 'application/json' request.body = "{\n \"monthlyVolume\": \"\",\n \"sourceOfFundsType\": \"\"\n}" response = http.request(request) puts response.read_body ``` -------------------------------- ### Example Redirect URL with Query Parameters Source: https://docs.transak.com/guides/how-to-use-advanced-query-params.md Use this example to construct your `redirectURL`. Transak automatically appends various query parameters like `orderId`, `fiatCurrency`, `cryptoCurrency`, and more, allowing you to track transaction details on your end. ```html https://www.url.com/?orderId={{id}}&fiatCurrency={{code}}&cryptoCurrency={{code}}&fiatAmount={{amount}}&cryptoAmount={{amount}}&isBuyorSell=Sell&status={{orderStatus}}&walletAddress={{address}}&totalFeeInFiat={{amount}}&partnerCustomerId={{id}}&partnerOrderId={{id}}&network={{code}} ``` -------------------------------- ### Install Transak SDK (With Expo) Source: https://docs.transak.com/integration/mobile/react-native.md Install the Expo SDK and its required peer dependencies for projects using Expo. ```bash npm i @transak/ui-expo-sdk ``` ```bash npm i react-native-webview npm i expo-web-browser npm i @react-native-community/netinfo ``` -------------------------------- ### Get KYC Requirement in Go Source: https://docs.transak.com/api/whitelabel/kyc/get-kyc-requirement.md Use the net/http package to make a GET request to the KYC requirement API. This example shows how to read the response body. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api-gateway-stg.transak.com/api/v2/kyc/requirement?metadata%5BquoteId%5D=+&apiKey=" req, _ := http.NewRequest("GET", url, nil) res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get KYC Requirement in JavaScript Source: https://docs.transak.com/api/whitelabel/kyc/get-kyc-requirement.md Utilize the fetch API to perform a GET request for KYC requirements. This example demonstrates handling asynchronous responses and errors. ```javascript const url = 'https://api-gateway-stg.transak.com/api/v2/kyc/requirement?metadata%5BquoteId%5D=+&apiKey='; const options = {method: 'GET'}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` -------------------------------- ### Main Application Setup with Wagmi and React Query Source: https://docs.transak.com/guides/biconomy.md Sets up the root of the React application, providing the wagmi configuration and React Query client to the application context. This is essential for enabling blockchain interactions and data fetching. ```typescript import ReactDOM from 'react-dom/client'; import { WagmiProvider } from 'wagmi'; import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; import { config } from './wagmi'; import App from './App'; const queryClient = new QueryClient(); ReactDOM.createRoot(document.getElementById('root')!).render( ); ``` -------------------------------- ### User_verify-user-otp_example Source: https://docs.transak.com/api/whitelabel/user/verify-user-otp.md This example demonstrates how to verify a user's OTP using the Transak API. ```APIDOC ## POST https://api-gateway-stg.transak.com/api/v2/auth/verify ### Description Verifies the One-Time Password (OTP) sent to the user's email. ### Method POST ### Endpoint https://api-gateway-stg.transak.com/api/v2/auth/verify ### Request Body - **apiKey** (string) - Required - Your Transak API key. - **email** (string) - Required - The user's email address. - **otp** (string) - Required - The One-Time Password received by the user. - **stateToken** (string) - Required - A token representing the current state of the user's session. ### Request Example ```json { "apiKey": "", "email": "test@transak.com", "otp": "123456", "stateToken": "" } ``` ### Response #### Success Response (200) - **message** (string) - A success message indicating OTP verification. - **data** (object) - Contains additional data related to the verification process. #### Response Example ```json { "message": "OTP verified successfully.", "data": {} } ``` ``` -------------------------------- ### Create Widget URL with Go Source: https://docs.transak.com/api/public/create-widget-url.md Employ the net/http package to construct and send a POST request for widget session creation. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api-gateway-stg.transak.com/api/v2/auth/session" payload := strings.NewReader("{\n \"widgetParams\": {\n \"apiKey\": \"\",\n \"referrerDomain\": \"\"\n }\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("access-token", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get Fiat Currencies (PHP) Source: https://docs.transak.com/api/whitelabel/lookup/get-fiat-currencies.md Using GuzzleHttp in PHP, this example sends a GET request to retrieve fiat currency information and outputs the response body. ```php request('GET', 'https://api-gateway-stg.transak.com/api/v2/lookup/currencies/fiat-currencies?apiKey='); echo $response->getBody(); ``` -------------------------------- ### Example Widget URL Source: https://docs.transak.com/integration/api.md This is an example of a generated widget URL. It is single-use and valid for 5 minutes. ```text https://global-stg.transak.com?apiKey=YOUR_API_KEY&sessionId=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9... ``` -------------------------------- ### Get Crypto Currencies (C#) Source: https://docs.transak.com/api/ledger-off-ramp/get-crypto-currencies.md A C# example using the RestSharp library to interact with the API. This demonstrates setting the API key and executing a GET request. ```csharp using RestSharp; var client = new RestClient("https://api-stg.transak.com/ledger/v1/crypto-currencies"); var request = new RestRequest(Method.GET); request.AddHeader("x-api-key", ""); IRestResponse response = client.Execute(request); ``` -------------------------------- ### Initialize Transak SDK v2 (TypeScript) Source: https://docs.transak.com/integration/web/js-sdk.md Initialize the Transak SDK with configuration and set up event listeners for various transaction states. Use this for TypeScript projects. ```typescript import { TransakConfig, Transak } from '@transak/ui-js-sdk'; const transakConfig: TransakConfig = { widgetUrl: "https://global-stg.transak.com?apiKey=YOUR_API_KEY&sessionId=", // ..... }; const transak = new Transak(transakConfig); transak.init(); // To get all the events Transak.on('*', (data) => { console.log(data); }); // This will trigger when the user closed the widget Transak.on(Transak.EVENTS.TRANSAK_WIDGET_CLOSE, () => { console.log('Transak SDK closed!'); }); /* * This will trigger when the user has confirmed the order * This doesn't guarantee that payment has completed in all scenarios * If you want to close/navigate away, use the TRANSAK_ORDER_SUCCESSFUL event */ Transak.on(Transak.EVENTS.TRANSAK_ORDER_CREATED, (orderData) => { console.log(orderData); }); /* * This will trigger when the user marks payment is made * You can close/navigate away at this event */ Transak.on(Transak.EVENTS.TRANSAK_ORDER_SUCCESSFUL, (orderData) => { console.log(orderData); transak.close(); }); ``` -------------------------------- ### Install react-native-webview Source: https://docs.transak.com/integration/mobile/react-native.md Install the react-native-webview package using npm to manage the WebView component. ```bash npm i react-native-webview ``` -------------------------------- ### Get Crypto Currencies (Ruby) Source: https://docs.transak.com/api/ledger-off-ramp/get-crypto-currencies.md This Ruby example uses the Net::HTTP library to perform the GET request. Ensure SSL is enabled for secure connections. ```ruby require 'uri' require 'net/http' url = URI("https://api-stg.transak.com/ledger/v1/crypto-currencies") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["x-api-key"] = '' response = http.request(request) puts response.read_body ``` -------------------------------- ### Get Quote using JavaScript Source: https://docs.transak.com/api/ledger-off-ramp/get-quote.md Utilize the `fetch` API to retrieve a quote. This example demonstrates making an asynchronous GET request and handling the JSON response. ```javascript const url = 'https://api-stg.transak.com/ledger/v1/quote?to=&from=&payment-method=&amount='; const options = {method: 'GET', headers: {'x-api-key': ''}}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` -------------------------------- ### KYC Upload Proof Document Example Source: https://docs.transak.com/api/whitelabel/kyc/upload-proof-document.md This example demonstrates how to upload a KYC document, specifying the document ID and the file itself. ```APIDOC ## POST /api/v2/kyc/upload ### Description Uploads a proof document for KYC verification. ### Method POST ### Endpoint https://api-gateway-stg.transak.com/api/v2/kyc/upload ### Parameters #### Request Body - **docId** (string) - Required - The identifier for the document type (e.g., "PAYSLIP"). - **file** (file) - Required - The document file to upload. ### Request Example ```python import requests url = "https://api-gateway-stg.transak.com/api/v2/kyc/upload" files = { "file": "open('payslip.pdf', 'rb')" } payload = { "docId": "PAYSLIP" } response = requests.post(url, data=payload, files=files) print(response.json()) ``` ```javascript const url = 'https://api-gateway-stg.transak.com/api/v2/kyc/upload'; const form = new FormData(); form.append('docId', 'PAYSLIP'); form.append('file', 'payslip.pdf'); const options = {method: 'POST'}; options.body = form; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. - **message** (string) - A message describing the result of the operation. ``` -------------------------------- ### Sample Get Price API Response Source: https://docs.transak.com/guides/get-price-based-on-user-region.md This is an example of a successful response from the Get Price API, showing a region-adjusted quote with details on conversion price, fees, and amounts. ```json { "response": { "quoteId": "5b42f946-47b4-4bea-9e7e-563488d03333", "conversionPrice": 1.10475627488855, "marketConversionPrice": 1.1161162939576061, "slippage": 1.02, "fiatCurrency": "EUR", "cryptoCurrency": "USDC", "paymentMethod": "credit_debit_card", "fiatAmount": 100, "cryptoAmount": 107.68, "isBuyOrSell": "BUY", "network": "arbitrum", "feeDecimal": 0.0253, "totalFee": 2.53, "feeBreakdown": [ { "name": "Transak fee", "value": 2.51, "id": "transak_fee", "ids": ["transak_fee"] }, { "name": "Network/Exchange fee", "value": 0.02, "id": "network_fee", "ids": ["network_fee"] } ], "nonce": 1727442044, "cryptoLiquidityProvider": "transak", "notes": [] } } ``` -------------------------------- ### Get Order Details (Swift) Source: https://docs.transak.com/api/public/get-order-by-order-id.md Fetch order details in Swift using URLSession. This example demonstrates setting up the request, headers, and handling the response asynchronously. ```swift import Foundation let headers = ["access-token": ""] let request = NSMutableURLRequest(url: NSURL(string: "https://api-stg.transak.com/partners/api/v2/order/:orderId")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` -------------------------------- ### Create Order - Java Source: https://docs.transak.com/api/whitelabel/orders/create-order.md This Java example uses the Unirest library to create an order. Ensure Unirest is included in your project dependencies. ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api-gateway-stg.transak.com/api/v2/orders") .header("authorization", "") .header("Content-Type", "application/json") .body("{\n \"quoteId\": \"\",\n \"paymentInstrumentId\": \"\",\n \"walletAddress\": \"\"\n}") .asString(); ``` -------------------------------- ### Get KYC Requirement in Ruby Source: https://docs.transak.com/api/whitelabel/kyc/get-kyc-requirement.md Employ Net::HTTP to send a GET request to the KYC requirement endpoint. This example demonstrates setting up SSL and making the request. ```ruby require 'uri' require 'net/http' url = URI("https://api-gateway-stg.transak.com/api/v2/kyc/requirement?metadata%5BquoteId%5D=+&apiKey=") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) response = http.request(request) puts response.read_body ``` -------------------------------- ### Upload KYC Document with Ruby Source: https://docs.transak.com/api/whitelabel/kyc/upload-proof-document.md This Ruby example demonstrates how to send a POST request to upload KYC documents. It sets up SSL and constructs the multipart form data. ```Ruby require 'uri' require 'net/http' url = URI("https://api-gateway-stg.transak.com/api/v2/kyc/upload") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"docId\"\r\n\r\nPAYSLIP\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"payslip.pdf\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001--\r\n" response = http.request(request) puts response.read_body ``` -------------------------------- ### Get KYC Requirement in Python Source: https://docs.transak.com/api/whitelabel/kyc/get-kyc-requirement.md Use the requests library to make a GET request to the KYC requirement endpoint. This example includes query parameters for quoteId and apiKey. ```python import requests url = "https://api-gateway-stg.transak.com/api/v2/kyc/requirement" querystring = {"metadata[quoteId]":" ","apiKey":""} response = requests.get(url, params=querystring) print(response.json()) ```