3 ms·
Is there a reason parameter names begin with underscore? Or why the page parameter is abbreviated to "p"? Why is a non-standard syntax used for multiple values
by oneeyedpigeon 9y ago
Is there a reason parameter names begin with underscore? Or why the page parameter is abbreviated to "p"? Why is a non-standard syntax used for multiple values rather than just parameter arrays? E.g. instead of:
/api/payments?_fields=customerNumber,checkNumber
why not:
/api/payments?fields[]=customerNumber&fields[]=checkNumber
Kudos for "sort=-{field}" though (I think); any commentary on that design choice? I've used e.g. "sortdir=desc" in the past; not sure which is superior.
- o1lab 9y agoThank you for your input. parameters with underscore: I'd imagined to 've 'where' parameters in query fields like ?columnName=columnValue. Hence started with underscore - however I dropped where clause as I was soon sure that I was only covering small group within where clause and operators. abbreviation of page to _p - I think I picked up that from hackernews where paging query parameter is p :). fields: second one seems easy to use - I think I borrowed it from google youtube apis. They have concept of id,snippet etc which is higher level of abstracting ids, primary-info (respectively) in response sort: may be I extended the concept of fields to sort. Since sort can 've only two directions.
- dalore 9y agoWhy not a standard syntax like this: ``` /api/payments?fields=customerNumber&fields=checkNumber ``` You don't need [] to look for multiples.
- oneeyedpigeon 9y agoAs another commenter mentioned, there isn't really a standard here. I thought "field[]" was a standard, of course — that's the way PHP handles parameter arrays. In contrast, reusing the parameter name without the trailing "[]" does not work (only the last value is provided, as a scalar). I guess I got my answer :)
- userbinator 9y agoOr why the page parameter is abbreviated to "p"? It's probably the most common convention I've seen (at least for those sites that still support pagination, as opposed to that horrible "infinite scroll"...) The underscores are a little unusual, however; I don't think it's a bad thing, unless you're deliberately trying to hide the fact that you're using a specific backend. I've seen other prefices for parameters too with other sites in the past. Why is a non-standard syntax used for multiple values rather than just parameter arrays? There is no standard. I believe [] came from PHP, but I've seen many different ways to express "multiple values" in query strings.