snake_case


snake_case

One of the common mistakes people make when building an API is mixing up the way they represent multiple words in their JSON payloads -- you need to pick some sort of a format for your field names and stick with it.

There are a few common ways RESTful APIs format fieldnames – there's TitleCase, camelCase, and snake_case. All of these are solving the problem of multiple words in a fieldname where you can’t have spaces.

Title Case looks like the title of a book where every word is upper case. Camel case is named after the camel because the 1st letter is lowercase, but every word after that is uppercase, which gives a “hump” in the middle -- you could have one hump or more if you have multiple words.  Finally, there’s snake case – all the words are lower case, but they are separated by an underscore, kind of like the waviness of a snake.

So why did we choose snake_case at SVB? Pretty simply there were a lot of existing APIs that were already using snake_case and we didn't want to have to go back and refactor old APIs. Of course there is the second point -- it works. Yes, there are other ways to format, but it works and doesn’t break other things and that's a really good reason to use something.

So, we picked snake_case.