Insufficient Data

I’m building an ios app the grabs the snapshot data of the order book by using the rest api endpoint. Then I’m subscribing to the websocket stream at “wss://ws-feed.exchange.coinbase.com” and the full channel. However, watching your app and my trades is no where near the same. I’ve even added the matches channel to make sure I’m not missing any orders converting to trades and I get a couple trades a minute at best and your app shows hundreds of trades going through. I’ve tried using the advanced websocket but I cannot get authentication to work. Because every single example includes a passcode for your api key, which your system doesn’t give anymore. So I don’t know how to authenticate to use a different order/trade feed that is more accurate. I would prefer to use the advance trade api but again I can’t authenticate and there isn’t any documentation on how to do this in iOS with swift.

Hi coinsensei,

The Advanced Trade API is essentially a derivative feed created from the Exchange Websocket API. So it does not provide any additional data beyond what the Exchange Websocket API provides. It’s also a separate product offering so it requires different API key credentials, which is likely why you’re encountering issues connecting to it.

On the Exchange side, the Websocket ‘full’ channel is indeed the appropriate means to gather all event data. Please ensure you’ve correctly specified the right ‘product_id’ and that your application isn’t inadvertently filtering out or dropping any message types. The most commonly encountered message types are ‘received’, ‘open’, and ‘done’.

To help illustrate this, I just recently attempted the following subscription:

{
    "type": "subscribe",
    "product_ids": [
        "BTC-USD"
    ],
    "channels": ["full"]
}

Upon doing this, I observed ~1,400 messages within the first 10 seconds, which is fairly average for that book. I hope this information has been useful, please reach out if you need further assistance.

Thanks for the response. I find this very interesting! I the first 10 seconds my responded with just 216 responses for orders. Of those 216 only 2 were of match type. During a minute long test I received 12 matches which I convert to trades. I wonder what is the cause? I’m not doing any filtering of any kind prior. This is my server response from the websocket.

Hi @coinsensei
Thank you for taking the time to provide us with feedback!

We’ve logged your feedback about the advanced websocket with our internal teams so we can continue improving our user experience. Most new features and improvements to our products come directly from feedback like yours, so it’s very valuable to us. While we can’t offer any specific timeline for adding features, we are constantly working to build products our customers will love.

If you want to stay up to date on the latest from Coinbase Cloud, you can also bookmark the following webpage and subscribe to email updates at the bottom of the page: https://www.coinbase.com/cloud/discover

We hope this is helpful, and please let us know if you have any other questions.

@coinsensei

Thanks for sharing your observation! It is not uncommon for many orders to come in for any given product that may not always result in matches. In fact, it’s not uncommon observe that less than 1% of messages received on the full channel for some products (like BTC-USD) are matches and the rest are various new orders / cancels / etc.

Just to share, if you find you do need the full channel but would prefer smaller payloads / less overall data to parse, feel free to check out this Level3 channel here: https://docs.cloud.coinbase.com/exchange/docs/websocket-channels#level3-channel. It conveys the same order by order data in a more compress / compact form which might easier for an iOS device to handle at higher volumes.

Let us know if you have anymore questions or observations!

I see that now the level2, level3 and full order books are required to be authenticated. But you don’t offer a way to authenticate websockets?!?!? It says use the same as the restful api signature. But that makes no sense since the restful requires a concatenate of the endpoint. So in Swift what is the method for making a authenticated request? Keep in mind your Coinbase account NO LONGER offers users passphrases for their keys. From where I sit, a user can’t authenticate a websocket.

@coinsensei

For Coinbase Exchange and Coinbase Pro (not to be confused with Retail Advanced Trading), here are the authentication instructions: Exchange WebSocket Authentication | Coinbase Cloud

The API key, secrets, and passphrase can all be found when generating the API key within the Exchange or Pro UI. Here is a quick sample in python which illustrates how you can create the auth signature.

def generate_auth_params(msg: dict):
    key = 'api key'
    secret = 'secret'
    passphrase = 'passphrase'

    timestamp = str(time.time())
    message = timestamp + 'GET' + '/users/self/verify'
    message = message.encode('ascii')
    hmac_key = base64.b64decode(secret)
    signature = hmac.new(hmac_key, message, hashlib.sha256)
    signature_b64 = base64.b64encode(signature.digest())
    signature_b64 = signature_b64.decode('utf-8').rstrip('\n')

    msg = {
        "type": "subscribe",
        "channels": ["level2"],
        "product_ids": ["BTC-USD"],
        "signature": signature_b64,
        "key": key,
        "passphrase": passphrase,
        "timestamp": timestamp
    }

    return json.dumps(msg).encode('utf8')

I’ve been saying this a while, there are no passphrases any more for new keys. Signing into Coinbase Pro forces you to the new Coinbase. Create a key and see there is no passphrase any more. That is why the docs are terrible. They need to be updated and in more detail. Instead of saying just like for Restful, which is not true, give examples, just like Binance does.

You already have your answer in your own post… You told:

Signing into Coinbase Pro forces you to the new Coinbase.

Apparently for you Coinbase Pro is no longer available. In Coinbase you are creating API key for Advanced Trade / Sign in with Coinbase. Coinbase API key will not work with Coinbase Pro API.

Yes, but regardless of which endpoint I try for the websocket, they all require authentication now and all the docs reference a passphrase which doesn’t exist any more. I’ve tried every websocket “platform”. None of them can authenticate for a new user.

I don’t see any mention of passphrase here… Carefully re-read documentation and make sure you are not mixing Advanced Trade with Coinbase Pro.

Also try to read other topics that are related to Advanced Trade. I don’t remember but I think I have seen/read that new API keys have some waiting time before they work…