Expanding resources
Many resources, like transactions, have other resources linked to them. By default only the resource type (resource
), id (id
) and path (resource_path
) are exposed which can be used to fetch the resource separately. In some cases it's useful to expand the resource in the response body. While this might increase the request time and payload, it's still faster than fetching several resources separately.
Resources are expanded by passing an array of fields to expand with expand
parameter (e.g. ?expand[]=to&expand[]=account
). This can be done both when fetching existing or creating new resources. If you want to expand all available resources, you can pass expand=all
. This is useful with large and complex resources like transactions but it makes queries slower and increases the request payload size.
Show transactions
curl https://api.coinbase.com/v2/accounts/8fcd97cd-50ca-5803-8c27-1146e54b1c09/transactions/0ec2de93-7dae-5a50-8580-6445a08e4ae4 /
-H 'Authorization: Bearer abd90df5f27a7b170cd775abf89d632b350b7c1c9d53e08b340cd9832ce52c2c'
Regular response
{
"data": {
"id": "0ec2de93-7dae-5a50-8580-6445a08e4ae4",
"type": "send",
"status": "pending",
"amount": {
"amount": "-1.00000000",
"currency": "BTC"
},
"native_amount": {
"amount": "-10.00",
"currency": "USD"
},
"description": null,
"created_at": "2015-01-31T20:49:02Z",
"updated_at": "2015-01-31T20:49:02Z",
"resource": "transaction",
"resource_path": "/v2/accounts/8fcd97cd-50ca-5803-8c27-1146e54b1c09/transactions/0ec2de93-7dae-5a50-8580-6445a08e4ae4",
"network": {
"status": "unconfirmed",
"hash": "a7e23afeccf863dc8359ba04d2b854eddb6dea6901643828fdb3aca53d8bf600"
},
"to": {
"resource": "user",
"id": "9d55bef5-47f1-5936-b771-b07c1d8140a2",
"resource_path": "/v2/users/9d55bef5-47f1-5936-b771-b07c1d8140a2"
}
}
}
Same call with expanded resource
curl https://api.coinbase.com/v2/accounts/8fcd97cd-50ca-5803-8c27-1146e54b1c09/transactions/0ec2de93-7dae-5a50-8580-6445a08e4ae4?expand[]=to /
-H 'Authorization: Bearer abd90df5f27a7b170cd775abf89d632b350b7c1c9d53e08b340cd9832ce52c2c'
Expanded response
{
"data": {
"id": "0ec2de93-7dae-5a50-8580-6445a08e4ae4",
"type": "send",
"status": "pending",
"amount": {
"amount": "-1.00000000",
"currency": "BTC"
},
"native_amount": {
"amount": "-10.00",
"currency": "USD"
},
"description": null,
"created_at": "2015-01-31T20:49:02Z",
"updated_at": "2015-01-31T20:49:02Z",
"resource": "transaction",
"resource_path": "/v2/accounts/8fcd97cd-50ca-5803-8c27-1146e54b1c09/transactions/0ec2de93-7dae-5a50-8580-6445a08e4ae4",
"network": {
"status": "unconfirmed",
"hash": "a7e23afeccf863dc8359ba04d2b854eddb6dea6901643828fdb3aca53d8bf600"
},
"to": {
"id": "9d55bef5-47f1-5936-b771-b07c1d8140a2",
"name": "James Smith",
"username": null,
"profile_location": null,
"profile_bio": null,
"profile_url": null,
"avatar_url": "https://images.coinbase.com/avatar?h=KphlECxEemoPGv3xtMSxqG2Ud7gEzke9mh0Ff3ifsiu9ggPwStQLCCuQfk6N%0AyY1p&s=128",
"resource": "user",
"resource_path": "/v2/users/9d55bef5-47f1-5936-b771-b07c1d8140a2"
}
}
}