curl --request POST \
--url https://api.prime.coinbase.com/v1/portfolios/{portfolio_id}/wallets/{wallet_id}/conversion \
--header 'Content-Type: application/json' \
--data '
{
"amount": "50.50",
"destination": "e84255eb-2e21-439e-a1d0-f5dd1e1292b9",
"idempotency_key": "e84255eb-2e21-439e-a1d0-f5dd1e1292b9",
"source_symbol": "USD",
"destination_symbol": "USDC"
}
'import requests
url = "https://api.prime.coinbase.com/v1/portfolios/{portfolio_id}/wallets/{wallet_id}/conversion"
payload = {
"amount": "50.50",
"destination": "e84255eb-2e21-439e-a1d0-f5dd1e1292b9",
"idempotency_key": "e84255eb-2e21-439e-a1d0-f5dd1e1292b9",
"source_symbol": "USD",
"destination_symbol": "USDC"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
amount: '50.50',
destination: 'e84255eb-2e21-439e-a1d0-f5dd1e1292b9',
idempotency_key: 'e84255eb-2e21-439e-a1d0-f5dd1e1292b9',
source_symbol: 'USD',
destination_symbol: 'USDC'
})
};
fetch('https://api.prime.coinbase.com/v1/portfolios/{portfolio_id}/wallets/{wallet_id}/conversion', 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.prime.coinbase.com/v1/portfolios/{portfolio_id}/wallets/{wallet_id}/conversion",
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([
'amount' => '50.50',
'destination' => 'e84255eb-2e21-439e-a1d0-f5dd1e1292b9',
'idempotency_key' => 'e84255eb-2e21-439e-a1d0-f5dd1e1292b9',
'source_symbol' => 'USD',
'destination_symbol' => 'USDC'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$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.prime.coinbase.com/v1/portfolios/{portfolio_id}/wallets/{wallet_id}/conversion"
payload := strings.NewReader("{\n \"amount\": \"50.50\",\n \"destination\": \"e84255eb-2e21-439e-a1d0-f5dd1e1292b9\",\n \"idempotency_key\": \"e84255eb-2e21-439e-a1d0-f5dd1e1292b9\",\n \"source_symbol\": \"USD\",\n \"destination_symbol\": \"USDC\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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.prime.coinbase.com/v1/portfolios/{portfolio_id}/wallets/{wallet_id}/conversion")
.header("Content-Type", "application/json")
.body("{\n \"amount\": \"50.50\",\n \"destination\": \"e84255eb-2e21-439e-a1d0-f5dd1e1292b9\",\n \"idempotency_key\": \"e84255eb-2e21-439e-a1d0-f5dd1e1292b9\",\n \"source_symbol\": \"USD\",\n \"destination_symbol\": \"USDC\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.prime.coinbase.com/v1/portfolios/{portfolio_id}/wallets/{wallet_id}/conversion")
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 \"amount\": \"50.50\",\n \"destination\": \"e84255eb-2e21-439e-a1d0-f5dd1e1292b9\",\n \"idempotency_key\": \"e84255eb-2e21-439e-a1d0-f5dd1e1292b9\",\n \"source_symbol\": \"USD\",\n \"destination_symbol\": \"USDC\"\n}"
response = http.request(request)
puts response.read_body{
"activity_id": "e84255eb-2e21-439e-a1d0-f5dd1e1292b9",
"source_symbol": "USD",
"destination_symbol": "USDC",
"amount": "50.50",
"destination": "e84255eb-2e21-439e-a1d0-f5dd1e1292b9",
"source": "e84255eb-2e21-439e-a1d0-f5dd1e1292b9",
"transaction_id": "e84255eb-2e21-439e-a1d0-f5dd1e1292b9"
}Create Conversion
Perform a conversion between 2 assets.
curl --request POST \
--url https://api.prime.coinbase.com/v1/portfolios/{portfolio_id}/wallets/{wallet_id}/conversion \
--header 'Content-Type: application/json' \
--data '
{
"amount": "50.50",
"destination": "e84255eb-2e21-439e-a1d0-f5dd1e1292b9",
"idempotency_key": "e84255eb-2e21-439e-a1d0-f5dd1e1292b9",
"source_symbol": "USD",
"destination_symbol": "USDC"
}
'import requests
url = "https://api.prime.coinbase.com/v1/portfolios/{portfolio_id}/wallets/{wallet_id}/conversion"
payload = {
"amount": "50.50",
"destination": "e84255eb-2e21-439e-a1d0-f5dd1e1292b9",
"idempotency_key": "e84255eb-2e21-439e-a1d0-f5dd1e1292b9",
"source_symbol": "USD",
"destination_symbol": "USDC"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
amount: '50.50',
destination: 'e84255eb-2e21-439e-a1d0-f5dd1e1292b9',
idempotency_key: 'e84255eb-2e21-439e-a1d0-f5dd1e1292b9',
source_symbol: 'USD',
destination_symbol: 'USDC'
})
};
fetch('https://api.prime.coinbase.com/v1/portfolios/{portfolio_id}/wallets/{wallet_id}/conversion', 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.prime.coinbase.com/v1/portfolios/{portfolio_id}/wallets/{wallet_id}/conversion",
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([
'amount' => '50.50',
'destination' => 'e84255eb-2e21-439e-a1d0-f5dd1e1292b9',
'idempotency_key' => 'e84255eb-2e21-439e-a1d0-f5dd1e1292b9',
'source_symbol' => 'USD',
'destination_symbol' => 'USDC'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$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.prime.coinbase.com/v1/portfolios/{portfolio_id}/wallets/{wallet_id}/conversion"
payload := strings.NewReader("{\n \"amount\": \"50.50\",\n \"destination\": \"e84255eb-2e21-439e-a1d0-f5dd1e1292b9\",\n \"idempotency_key\": \"e84255eb-2e21-439e-a1d0-f5dd1e1292b9\",\n \"source_symbol\": \"USD\",\n \"destination_symbol\": \"USDC\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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.prime.coinbase.com/v1/portfolios/{portfolio_id}/wallets/{wallet_id}/conversion")
.header("Content-Type", "application/json")
.body("{\n \"amount\": \"50.50\",\n \"destination\": \"e84255eb-2e21-439e-a1d0-f5dd1e1292b9\",\n \"idempotency_key\": \"e84255eb-2e21-439e-a1d0-f5dd1e1292b9\",\n \"source_symbol\": \"USD\",\n \"destination_symbol\": \"USDC\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.prime.coinbase.com/v1/portfolios/{portfolio_id}/wallets/{wallet_id}/conversion")
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 \"amount\": \"50.50\",\n \"destination\": \"e84255eb-2e21-439e-a1d0-f5dd1e1292b9\",\n \"idempotency_key\": \"e84255eb-2e21-439e-a1d0-f5dd1e1292b9\",\n \"source_symbol\": \"USD\",\n \"destination_symbol\": \"USDC\"\n}"
response = http.request(request)
puts response.read_body{
"activity_id": "e84255eb-2e21-439e-a1d0-f5dd1e1292b9",
"source_symbol": "USD",
"destination_symbol": "USDC",
"amount": "50.50",
"destination": "e84255eb-2e21-439e-a1d0-f5dd1e1292b9",
"source": "e84255eb-2e21-439e-a1d0-f5dd1e1292b9",
"transaction_id": "e84255eb-2e21-439e-a1d0-f5dd1e1292b9"
}- Java
- .NET
- Go
- Python
- CLI
- TS/JS
TransactionsService transactionsService = PrimeServiceFactory.createTransactionsService(client);
CreateConversionRequest request = new CreateConversionRequest.Builder()
.portfolioId("PORTFOLIO_ID_HERE")
.walletId("WALLET_ID_HERE")
.amount("1")
.destination("DESTINATION_WALLET_UUID")
.idempotencyKey(UUID.randomUUID().toString())
.sourceSymbol("USD")
.destinationSymbol("USDC")
.build();
CreateConversionResponse response = transactionsService.createConversion(request);
var transactionsService = new TransactionsService(client);
var request = new CreateConversionRequest("PORTFOLIO_ID_HERE", "WALLET_ID_HERE")
{
Amount = "1",
Destination = "DESTINATION_WALLET_UUID",
IdempotencyKey = Guid.NewGuid().ToString(),
SourceSymbol = "USD",
DestinationSymbol = "USDC",
};
var response = transactionsService.CreateConversion(request);
transactionsService := transactions.NewTransactionsService(client)
request := &transactions.CreateConversionRequest{
PortfolioId: "PORTFOLIO_ID_HERE",
WalletId: "WALLET_ID_HERE",
Amount: "1",
Destination: "DESTINATION_WALLET_UUID",
IdempotencyKey: uuid.New().String(),
SourceSymbol: "USD",
DestinationSymbol: "USDC",
}
response, err := transactionsService.CreateConversion(context.Background(), request)
prime_client = PrimeClient(credentials)
request = CreateConversionRequest(
portfolio_id="PORTFOLIO_ID_HERE",
wallet_id="WALLET_ID_HERE",
amount = '1',
destination = 'DESTINATION_WALLET_UUID',
idempotency_key = str(uuid.uuid4()),
source_symbol = 'USD',
destination_symbol = 'USDC',
)
response = prime_client.create_conversion(request)
primectl create-conversion --help
const transactionsService = new TransactionsService(client);
transactionsService.createConversion({
portfolioId: 'PORTFOLIO_ID_HERE',
walletId: 'WALLET_ID_HERE',
amount: "1",
destination: "DESTINATION_WALLET_UUID",
idempotencyKey: uuidv4(),
sourceSymbol: "USD",
destinationSymbol: "USDC",
}).then(async (response) => {
console.log('Conversion: ', response);
})
Path Parameters
The ID of the portfolio
The wallet ID that the conversion will originate from
Body
The amount in whole units to convert
"50.50"
The UUID of the destination wallet
"e84255eb-2e21-439e-a1d0-f5dd1e1292b9"
The idempotency key associated with this conversion
"e84255eb-2e21-439e-a1d0-f5dd1e1292b9"
The currency symbol to convert from
"USD"
The currency symbol to convert to
"USDC"
Response
A successful response.
The activity ID for the conversion
"e84255eb-2e21-439e-a1d0-f5dd1e1292b9"
The currency symbol to convert from
"USD"
The currency symbol to convert to
"USDC"
The amount in whole units to convert
"50.50"
The UUID of the destination wallet
"e84255eb-2e21-439e-a1d0-f5dd1e1292b9"
The UUID of the source wallet
"e84255eb-2e21-439e-a1d0-f5dd1e1292b9"
The UUID of the conversion transaction
"e84255eb-2e21-439e-a1d0-f5dd1e1292b9"
Was this page helpful?