Hi @sgealbhain
Here’s an example (with sensitive info like API Key, secret, etc… removed)
{
"info": {
"_postman_id": "8f8e421a-bc64-4271-92e9-a42a87aab2eb",
"name": "Sign-in With Coinbase API v2",
"schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json",
"_exporter_id": "20929894"
},
"item": [
{
"name": "Send money",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
}
],
"request": {
"auth": {
"type": "noauth"
},
"method": "POST",
"header": [
{
"key": "CB-ACCESS-KEY",
"value": "",
"type": "text"
},
{
"key": "CB-ACCESS-SIGN",
"value": "{{CB-ACCESS-SIGN}}",
"type": "text"
},
{
"key": "CB-ACCESS-TIMESTAMP",
"value": "{{CB-ACCESS-TIMESTAMP}}",
"type": "text"
},
{
"key": "CB-VERSION",
"value": "",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"type\": \"send\",\n \"to\" : \"\",\n \"amount\" : \"1\",\n \"currency\": \"EUR\"\n\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": "{{api_url}}/v2/accounts/account_id//transactions"
},
"response": []
},
{
"name": "Accounts",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
}
],
"request": {
"auth": {
"type": "noauth"
},
"method": "GET",
"header": [
{
"key": "CB-ACCESS-KEY",
"value": "",
"type": "text"
},
{
"key": "CB-ACCESS-SIGN",
"value": "{{CB-ACCESS-SIGN}}",
"type": "text"
},
{
"key": "CB-ACCESS-TIMESTAMP",
"value": "{{CB-ACCESS-TIMESTAMP}}",
"type": "text"
},
{
"key": "CB-VERSION",
"value": "",
"type": "text"
}
],
"url": "{{api_url}}/v2/accounts"
},
"response": []
},
{
"name": "Buy",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
}
],
"request": {
"auth": {
"type": "noauth"
},
"method": "POST",
"header": [
{
"key": "CB-ACCESS-KEY",
"value": "",
"type": "text"
},
{
"key": "CB-ACCESS-SIGN",
"value": "{{CB-ACCESS-SIGN}}",
"type": "text"
},
{
"key": "CB-ACCESS-TIMESTAMP",
"value": "{{CB-ACCESS-TIMESTAMP}}",
"type": "text"
},
{
"key": "",
"value": "",
"type": "text",
"disabled": true
}
],
"body": {
"mode": "raw",
"raw": "{\n \"amount\": 1,\n \"currency\": \"EUR\",\n \"payment_method\" :\"\"\n\n} \n",
"options": {
"raw": {
"language": "json"
}
}
},
"url": "{{api_url}}/v2/accounts/account_id/buys"
},
"response": []
},
{
"name": "Payment Methods",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
}
],
"request": {
"auth": {
"type": "noauth"
},
"method": "GET",
"header": [
{
"key": "CB-ACCESS-KEY",
"value": "",
"type": "text"
},
{
"key": "CB-ACCESS-SIGN",
"value": "{{CB-ACCESS-SIGN}}",
"type": "text"
},
{
"key": "CB-ACCESS-TIMESTAMP",
"value": "{{CB-ACCESS-TIMESTAMP}}",
"type": "text"
},
{
"key": "",
"value": "",
"type": "text",
"disabled": true
}
],
"url": "{{api_url}}/v2/payment-methods"
},
"response": []
},
{
"name": "Transactions",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
}
],
"request": {
"auth": {
"type": "noauth"
},
"method": "GET",
"header": [
{
"key": "CB-ACCESS-KEY",
"value": "",
"type": "text"
},
{
"key": "CB-ACCESS-SIGN",
"value": "{{CB-ACCESS-SIGN}}",
"type": "text"
},
{
"key": "CB-ACCESS-TIMESTAMP",
"value": "{{CB-ACCESS-TIMESTAMP}}",
"type": "text"
},
{
"key": "",
"value": "",
"type": "text"
}
],
"url": "{{api_url}}/v2/accounts/account_id/transactions/transaction_id"
},
"response": []
}
],
"event": [
{
"listen": "prerequest",
"script": {
"type": "text/javascript",
"exec": [
"// Computes the HMAC for requests sent to the Coinbase Pro API.",
"//",
"// - Add the following code as Postman pre-request script",
"// - Adapt the getPatch function an the variable names according to your needs",
"",
"const timestamp = Math.floor(Date.now() / 1000);",
"",
"function getPath(url) {",
" // URL path regex works only if your URLs look like this: {{api_url}}/resource",
" // If you use hardcoded URLs or any other scheme, adapt the regex pattern!",
" const matches = url.match(/.+?(\\/.+?)(?:#|\\?|$)/);",
" return (matches && matches.length > 1) ? matches[1] : ''; ",
"}",
" ",
"function computeSignature(request) {",
" const data = request.data;",
" const method = request.method;",
" const path = getPath(request.url);",
" const body = typeof(data) == \"object\" ? '' : data;",
" const message = timestamp + method + path + body;",
" console.log(message);",
" const key = \"\";",
" const hash = CryptoJS.HmacSHA256(message, key).toString(CryptoJS.enc.hash);",
"",
" return hash;",
"}",
"",
"",
"postman.setEnvironmentVariable('CB-ACCESS-SIGN', computeSignature(request));",
"",
"postman.setEnvironmentVariable('CB-ACCESS-TIMESTAMP', timestamp)"
]
}
},
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
""
]
}
}
],
"variable": [
{
"key": "api_url",
"value": "https://api.coinbase.com/",
"type": "string"
}
]
}