Float being returned as String

I am requesting data from an entity using the SG REST API, and our fields that were configured to be “float” fields are returning their data as string. This is inconsistent with the Python API, which returns the target data from the field-in-question as a Float.

I am requesting data from


where some_field_name is of type Float in SG.

When reviewing the JSON response, data.attributes.some_field_name is formatted as a JSON string.

Is this a bug or a feature?
Is this because JSON does not have a true float representation?

I would like to point out that this design is inconsistent with how the Python API operates

response = sg.find_one("<EntityType>", [["id", "is", <EntityId>]], ["some_field_name"])
some_field = data["some_field_name"]
print(some_field, type(some_field))
# Result: 1.0 <type 'float'>

Just chiming in to confirm this behavior. Via the REST API I’m currently de-serializing floats as string type, and then additionally parsing them to get their actual float value.

Not ideal, but here we are. :man_shrugging:

Edit: Worth noting that depending on your preferred language and framework, libraries like Newtsonsoft.Json will happily de-serialize a string-float like the above to both float and double without complaining.

All HTTP parameters arrive as strings, so I suppose the REST API does not do any conversion on them? Can you confirm this is the case with fields other than floats?
The Python API has knowledge of each entity’s fields and types, which REST probably does not.
You could possibly read the entity’s schema and decide what needs to be converted.
The API should probably do this, but does not.

If I understood @bzenker correctly, he’s referring to the JSON payload returned by the REST endpoint in question. The data is sent as plaintext, specifying encoding application/json; charset=utf-8.

This is a sample shot I pulled out to demonstrate:

    "data": [
            "type": "Shot",
            "attributes": {
                "sg_test_float2": "3.14",
                "sg_test_int": 3,
                "sg_test_bool": false,
                "code": "Test shot"
            "relationships": {},
            "id": 3616,
            "links": {
                "self": "/api/v1/entity/shots/3616"
    "links": {
        "self": "/api/v1/entity/shots?fields=sg_test_float2%2Csg_test_int%2Csg_test_bool%2Ccode&filter%5Bproject.Project.id%5D=617",
        "next": "/api/v1/entity/shots?fields=sg_test_float2%2Csg_test_int%2Csg_test_bool%2Ccode&filter%5Bproject.Project.id%5D=617&page%5Bnumber%5D=2&page%5Bsize%5D=500"

Ok so indeed the int is passed as is, but the float is quoted. This should actually be working for floats - they are allowed in json. Might be a bug in the api.

Correct. Thank you for clarifying for me @danielskovli. I was conflating JSON decoding with what gets communicated over HTTP.

And to @mmoshev’s point, I was previously incorrect in stating that JSON does not have a float representation. After re-reading the spec and then checking https://jsonlint.com/ it would appear that it should be totally valid for the SG REST API to return "sg_test_float2": 3.14,.

So, I would agree that this appears to be a bug.

I am also currently parsing floats after receiving their string value as @danielskovli suggested, as an interim solution.