API

The Brink API can be used to build a profit-driven executor, a cool UI, or whatever your mind can dream

Get API Information

GET https://api.brink.trade/info

This endpoint returns Brink API information, such as the version of the API.

{    "service": "@brinkninja/api",    "version": "v1.0"    }

Get Account Information

GET https://api.brink.trade/account/:owner

This will return the account information associated with the owner address provided.

Path Parameters

{    "account": "0x3F62d3Ca386175E65154732910DB76aEcB4024e1"    }ThaccountFromOwner() Error: 'Insert into messages' is not a valid address

Get Account Tokens

GET https://api.brink.trade/account_tokens/:owner

Given an owner address, this API will return the token addresses of the owned tokens of the Brink account associated with that owner address , as well as the Brink account address

Path Parameters

{    "account": "0x3F62d3Ca386175E65154732910DB76aEcB4024e1",    "tokens": ["0x6b175474e89094c44da98b954eedeac495271d0f", "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984"]    }

Get Account Messages

GET https://api.brink.trade/account_messages/:owner

Get messages associated with the owner address's account

Path Parameters

{    "account": "0x3F62d3Ca386175E65154732910DB76aEcB4024e1",    "messages": ["0x6b175474e89094c44da98b954eedeac495271d0f", "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984"]    }

Get Messages

GET https://api.brink.trade/messages?states=UNDER_LIMIT,UNDER_PROFIT

Get all messages with the selected states. State is Brink's own internal determination of the message's current state. You can pass in the following options individually: ALL will return every message EXECUTABLE will return all executable messages (Executable: QUEUED, IN_PROGRESS, INSUFFICIENT_FUNDS, RETRY, UNDER_LIMIT, UNDER_PROFIT) (Note this does not mean they are profitable) The full list of possible states are as follows: QUEUED: A message that is in our SQS queue and will soon be handled IN_PROGRESS: A message that is currently being evaluated by one of our executors INSUFFICIENT_FUNDS: A message that occurs when an account does not have the required funds for the transaction to be successful, but would otherwise be executable RETRY: A message that has either failed between 1-5 transactions, was not executed because of executor error, or is in this state by default once created. Once a transaction fails more than 5 messages, the state becomes 'NEVER_EXECUTABLE' UNDER_LIMIT: A message that when last evaluated could not be executed because the requested limit had not yet been crossed UNDER_PROFIT: A message the when last evaluated had crossed the limit threshold, but the profit for the executor would not cover gas costs NEVER_EXECUTABLE: A message that has been determine to be never executable by our executors Note if no state parameter is provided, the API will default to ALL

Query Parameters

{"messages":
    [
        {
            "message":"0xe70ac0a98a8a9c84c855d8e6a529507c66b19eb02f97b058ea24218f20eb711f",
            "signature":"0x7ee483de0dd7b0db1a59efff36b5e21be0022fe4e7a4b9f1ff057610fb181dd2280544a268acf0a812c698e46e875ec5c5da730d05b5a66b2b5f86144884f0ac1c",
            "signer":"0xb4dc65f8ade347d9d87d0d077f256afc798c4dc6",
            "accountAddress":"0x8aa5eef4d4b2b5d7354cc1d923ad6d3fe9e664aa",
            "functionName":"metaDelegateCall",
            "signedParams":
                [
                    {
                        "name":"to",
                        "type":"address",
                        "value":"0xa96dc3076db393e83139c807227e53b54b007073"
                    },
                    {
                        "name":"data",
                        "type":"bytes",
                        "value":"0xdc0ed0fe00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000cfd77caf9160909b361f597c94ff27e05ca6c8800000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000013ee0fc2914b9d1109ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
                        "callData":
                            {
                                "functionName":"ethToToken",
                                "params":
                                    [
                                        {
                                            "name":"bitmapIndex",
                                            "type":"uint256",
                                            "value":"0"
                                        },
                                        {
                                            "name":"bit",
                                            "type":"uint256",
                                            "value":"1"
                                        },
                                        {
                                            "name":"token",
                                            "type":"address",
                                            "value":"0xcfd77caf9160909b361f597c94ff27e05ca6c880"
                                        },
                                        {
                                            "name":"ethAmount",
                                            "type":"uint256",
                                            "value":"1000000000000000000"
                                        },
                                        {
                                            "name":"tokenAmount",
                                            "type":"uint256",
                                            "value":"367642280835453620489"
                                        },
                                        {
                                            "name":"expiryBlock",
                                            "type":"uint256",
                                            "value":"115792089237316195423570985008687907853269984665640564039457584007913129639935"
                                        },
                                        {
                                            "name":"to",
                                            "type":"address"
                                        },
                                        {
                                            "name":"data",
                                            "type":"bytes"
                                        }
                                    ]
                                }
                            }
                        ],"failedTxs":[],"pendingTxs":[]
                    }
                ]
}

Get Events

GET https://api.brink.trade/events

The Get Events API is a server-sent event stream that allows you to retrieve new messages as they are inserted into the database. In the code block below you will find a reference implementation on the client side (Node.js) const EventSource = require("eventsource") const source = new EventSource(`https://api.brink.trade`) source.addEventListener('message', message => { console.log(message) })

MessageEvent {
  type: 'message',
  data: 
      {
        "message": "0x4b4c4eeb5474afc041f3f966f125035fac103c59327d83093bdc6369721eb596",
        "signature": "0x210988d0b3842f3163604372c2b487500520cca44c89823234a0563ae549012841fea5b2f56f3ca1e33a5148b9d4078c5499a1399a6f158e0f868029f1a7c8ff1c",
        "signer": "0xea5dfd42f8d668d910478efab56c4f5c45375879",
        "accountAddress": "0xf43f82e8a0a30603681c855245264bdc11c6c655",
        "functionName": "metaDelegateCall",
        "signedParams": [
            {
                "name": "to",
                "type": "address",
                "value": "0xa96dc3076db393e83139c807227e53b54b007073"
            },
            {
                "name": "data",
                "type": "bytes",
                "value": "0xdc0ed0fe00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000e7b9d7cd757a1a6838985c83c7f571346ee78e810000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000000000016d5ed6dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
                "callData": {
                    "functionName": "ethToToken",
                    "params": [
                        {
                            "name": "bitmapIndex",
                            "type": "uint256",
                            "value": "0"
                        },
                        {
                            "name": "bit",
                            "type": "uint256",
                            "value": "1"
                        },
                        {
                            "name": "token",
                            "type": "address",
                            "value": "0xe7b9d7cd757a1a6838985c83c7f571346ee78e81"
                        },
                        {
                            "name": "ethAmount",
                            "type": "uint256",
                            "value": "1000000000000000000"
                        },
                        {
                            "name": "tokenAmount",
                            "type": "uint256",
                            "value": "383118701"
                        },
                        {
                            "name": "expiryBlock",
                            "type": "uint256",
                            "value": "115792089237316195423570985008687907853269984665640564039457584007913129639935"
                        },
                        {
                            "name": "to",
                            "type": "address"
                        },
                        {
                            "name": "data",
                            "type": "bytes"
                        }
                    ]
                }
            }
        ],
        "failedTxs": [],
        "pendingTxs": []
    },
  origin: 'http://localhost:3001'
}

Submit Message

POST https://api.brink.trade/submit_message

Submit a signed message to the database to be executed

Request Body

Last updated