Asset Rates API

Use the Asset Rates API to manage exchange rates between asset pairs.

Create an asset rate

POST /v1/organizations/{{id}}/ledgers/{{id}}/asset-rates

Create the exchange rate for a pair of assets.

Headers

Request body
{
    "baseAssetCode": "BRL",
    "counterAssetCode": "BTC",
    "amount": 35000000,
    "scale": 2,
    "source": "Chainlink database",
    "status": {
        "code": "My custom ACTIVE code",
        "description": "My description"
    },
    "metadata": {
        "updateCycle": 300,
        "urgent": true
    }
}

Response codes

{
    "id": "d0aa3885-0f9d-4856-9ca8-7da4fe6e2a95",
    "ledgerId": "77b0fb8b-1bd9-4810-9c6d-7e80064fab0c",
    "organizationId": "5f3a4c55-8b28-4276-bed7-f7c8a4bb44e8",
    "baseAssetCode": "BRL",
    "counterAssetCode": "BTC",
    "amount": 35000000,
    "scale": 2,
    "source": "Chainlink database",
    "status": {
        "code": "My custom ACTIVE code",
        "description": "My description"
    },
    "metadata": {
        "updateCycle": 300,
        "urgent": true
    },
    "createdAt": "2024-01-29T00:12:00+0300",
    "updatedAt": "2024-01-29T00:12:00+0300",
    "deletedAt": null
}

Retrieve all asset rates

GET /v1/organizations/{{id}}/ledgers/{{id}}/asset-rates

Use this endpoint to retrieve the information of all asset exchange rate pairs.

Headers

Query parameters

Response codes

[
    {
        "id": "d0aa3885-0f9d-4856-9ca8-7da4fe6e2a95",
        "ledgerId": "77b0fb8b-1bd9-4810-9c6d-7e80064fab0c",
        "organizationId": "5f3a4c55-8b28-4276-bed7-f7c8a4bb44e8",
        "baseAssetCode": "BRL",
        "counterAssetCode": "BTC",
        "amount": 35000000,
        "scale": 2,
        "source": "Chainlink database",
        "status": {
            "code": "My custom ACTIVE code",
            "description": "My description"
        },
        "metadata": {
            "updateCycle": 300,
            "urgent": true
        }
    },
    {
        "id": "8d47ade1-dfe3-4036-9000-a0ff045715e4",
        "ledgerId": "77b0fb8b-1bd9-4810-9c6d-7e80064fab0c",
        "organizationId": "5f3a4c55-8b28-4276-bed7-f7c8a4bb44e8",
        "baseAssetCode": "BTC",
        "counterAssetCode": "USD",
        "amount": 6900000,
        "scale": 2,
        "source": "Coinmarketcap",
        "status": {
            "code": "ACTIVE",
            "description": null
        },
        "metadata": {
            "anyKey": "anyValue"
        }
    }
]

Retrieve an asset rate by id

GET /v1/organizations/{{id}}/ledgers/{{id}}/asset-rates/{{id}}

Use this endpoint to retrieve the information of a specific exchange rate pair using the identifier (id).

Headers

Response codes

{
    "id": "8d47ade1-dfe3-4036-9000-a0ff045715e4",
    "baseAssetCode": "BRL",
    "counterAssetCode": "BTC",
    "ledgerId": "77b0fb8b-1bd9-4810-9c6d-7e80064fab0c",
    "organizationId": "5f3a4c55-8b28-4276-bed7-f7c8a4bb44e8",
    "amount": 35000000,
    "scale": 2,
    "source": "Chainlink database",
    "status": {
        "code": "ACTIVE",
        "description": null
    },
    "metadata": {
        "updateCycle": 300,
        "urgent": true
    }
}

Update an asset rate

PATCH /v1/organizations/{{id}}/ledgers/{{id}}/asset-rates/{{id}}

Use this endpoint to edit and update the information of a specific asset exchange rate. When you update a Product, the following fields cannot be edited:

  • createdAt

  • updatedAt

  • deletedAt

When updating the metadata object, all previous key-value pairs must be included in the update, or they will be removed. Check the Metadata section for more information.

Headers

Request body
{
    "source": "my head",
    "status": {
        "code": "New code",
        "description": "New description"
    },
    "metadata": {
        "whoAmI": "Jhon Doe"
    }
}

Response codes

{
    "id": "8d47ade1-dfe3-4036-9000-a0ff045715e4",
    "ledgerId": "77b0fb8b-1bd9-4810-9c6d-7e80064fab0c",
    "organizationId": "5f3a4c55-8b28-4276-bed7-f7c8a4bb44e8",
    "baseAssetCode": "BRL",
    "counterAssetCode": "BTC",
    "amount": 35000000,
    "scale": 2,
    "status": {
        "code": "New code",
        "description": "New description"
    },
    "status": "ACTIVE",
    "metadata": {
        "whoAmI": "John Doe"
    },
}

Delete an asset rate

DELETE /v1/organizations/{{id}}/ledgers/{{id}}/asset-rates/{{id}}

Use this endpoint to delete a specific asset exchange rate. When you do this, the "status" will change to "INACTIVE" and the "deletedAt" == "current_timestamp()".

Headers

Response codes

Last updated