Javascript SDK returns json with camelCase keys while Platform API returns snake_case

Hi guys.
I’ve been using js-sdk for quiet long now and recently I started retrieving the same data with platform API.
As example I am retrieving users channel list.
The issue is that Platform API response is totally different due to snake_case keys and its not easy to consume data from it.

Can someone explain why SDK and Platform have differences in response scheme and how does SDK transform json (caz its retrieved from REST in snake_case but resulting JSON is not) to camelCase so that maybe its possible to get this adapter from sources at least?

Hello @quarryman,

When the SDK receives data, it formats the JSON in a way that is inline with Javascript standards, thus the camelCase.

As our backend API service is built in python, the Platform API returns items in snack_case as it’s inline with Python standards.

Hi @Tyler
I see the reason, thanx for clarification.

However its not possible for single client to consume data from both APIs having different schemas.
In our case we retrieve some data from Endpoint that utilizes platform API and get another response scheme.

Is it possible to somehow get SDK adapter that formats JSON as we dont know exactly what is changed after formating is applied?

Or advice another approach how to format data coming from Platform API to the same format as SDK please

I’m not sure I follow. Can you provide me an example where the schema differs? The same data is returned in both the Platform API and the Object in the JS SDK.

As a note, we don’t recommend using the Platform API in your client application (outside of the calls the SDK makes) as you risk exposing your Api-Token.

@Tyler
Given we have frontend app that retrieves user’s channel list using SDK and processes channels in particular manner and then it retrieves the same channels list using our API endpoint that uses Platform API which proxies it back to frontend transparently, we are not able to process Platform API response as it has snake_case keys which means it has different scheme/types then SDK response.

Processing logic expects to get channel List with CamelCase keys and we get snake_case response, which is not processable within single frontend app.

We dont use platform API in client, we just proxy it through backend API

I was asking for a way to get Platform API response in snake_case and transform it to camelCase (exactly what you told SDK does) so that frontend client can work with both responses.

The same data is returned in both the Platform API and the Object in the JS SDK.
As much as I see its not correct. Platform API json response keys are snake_case and SDK data is CamelCased json, which are very different

Just to clarify.
SDK json

{
  ...
 createdAt: 1642784303000
 }

Platform json for the same channel

"created_at": 1642784303000,

When I say SDK response I mean data that we get in callback/promise of SDK invocation and we can work with. Under the hood SDK retrieves the same snake_case json, but as you told its transformed and we dont have control neither to this transformation nor to pure data before transformation

Hey @quarryman,

There is no way for us to provide you with a method or interface to convert from snake_case to camelCase. You would need to create your own method on the backend to convert the snake_case to camelCase.