user-docs
user-docs copied to clipboard
Fix docs/behaviour for crypto trades API
Hi there! I hope you had a good Christmas and New Year!
Latest crypto trade endpoint
Taken from here:
endpoints:
/v1beta1/crypto/{symbol}/trades/latest:
GET:
title: Returns latest trade for the queried crypto symbol
summary: |
This endpoint returns latest trade for the requested crypto symbol.
params:
path:
- name: symbol
type: string
desc: The symbol to query for
query:
- name: exchange
type: string
required: true
desc: The comma-separated exchanges which can be ERSX, FTX or CBSE. Defaults to All.
returns: |
A Trade response object.
errors:
- status: 400
reason: Invalid query parameters
- status: 403
reason: Unauthorized
- status: 404
reason: Not found
- status: 429
reason: Too many requests
My problem is with the documentation of the 'exchange' query parameter. Assuming the actual behaviour is working as expected, which I suppose might not be the case.
First of all, I don't see how a parameter can be both required, and have a default value. If there's a default value, then surely I don't need to provide it? In this case, I tried leaving it out and the default value was not used. Instead, I received a http status code of 422 - which isn't even documented.
According to Mozilla, a status code of 422 can be described as follows:
The HyperText Transfer Protocol (HTTP) 422 Unprocessable Entity response status code indicates that the server understands the content type of the request entity, and the syntax of the request entity is correct, but it was unable to process the contained instructions.
To that end, I'm not sure 422 is really appropriate (and if it is, it should be documented). If I haven't included a query parameter that's required, then surely that's a bad request?
Next, I tried supplying the value 'All', since that's the default value according the docs, and I wanted the latest trade across all exchanges. Again, I received a status code of 422, with the message invalid exchange: All
.
Next, I tried supplying the value 'ERSX,FTX,CBSE', as the docs do specifically say comma-separated. Again, I received a status code of 422.
The only way I've been able to get this endpoint to work is by supplying exactly 1 exchange.
Crypto trades endpoint
The description for the 'exchanges' query parameter of the /trades endpoint (not latest) appears to be exactly the same as the above, so perhaps there was just a little too much copy and pasting going on. This one is genuinely optional, with the default behaviour being to include results from all exchanges. However, supplying 'All' is still invalid, so I think the description could do with being updated, perhaps to say 'The comma-separated exchanges which can be ERSX, FTX or CBSE. Defaults behaviour is to include trades from all exchanges.'.