API snake_case camelCase confusion

Square’s API Reference site is a little bit confusing as everything is listed in snake_case, but the API’s (node.js specifically) actually use camelCase. Is there a reason for this?

Also, there is one example in the node.js API where it fails on camelCase and expects snake_case.

try {
  const response = await client.loyaltyApi.searchLoyaltyAccounts({
    query: {
        customer_ids : ['abcde'] // Only works with snake_case, not camelCase
    },
    limit: 5
  });

  console.log(response.result);
} catch(error) {
  console.log(error);

All the SDKs are in camelCase. Testing the above to try and replicate. :slightly_smiling_face:

Yep, it’s just that the API Reference site shows things in snake_case, which is a little confusing.

That’s the JSON for the curl responses. If you change the language switcher it will show the correct case. :slightly_smiling_face:

Changing the language to node.js doesn’t change the response JSON to camelCase on my end. :frowning:

Sorry yes, the responses in our reference are all in JSON. We’re constantly working to improve our features based on feedback like this, so I’ll be sure to share your request to the API product team. :slightly_smiling_face:

The Square webhooks API returns things in snake case, but the SDK is in camel case. I can’t use the Square SDK with your own Webhooks API.

is this known?

Yes, this has been brought up. There currently isn’t a wrapper in the SDK that can parse webhook payloads and transform them to camel case. We’re constantly working to improve our features based on feedback like this, so I’ll be sure to share your request to the API product team. :slightly_smiling_face: