Int too big to fit in my API

Int too big to fit in my API

1 0 1

Int too big to fit in my API

Hello, I am having an issue upon receiving webhooks in my NodeJs API (v12.14 NestJS - Express (*)). IDs in the Integer format are incorrectly parsed. Indeed, since shopify IDs are 64-bit and NodeJS only handles up to 53 bit ints, we cannot properly read them.

Indeed, I am hooked to product creation and when I check ``, I get, for instance, the following id 788032119674292900 instead of 788032119674292922.

This poses several issues. I could not properly validate the HMAC by some mysterious reason, and could not reuse the ID when doing calls to Shopify's REST API (ID would not be found). After a lot of debugging, I found that the real ID was, in this example, "788032119674292922". (I stringified the raw buffer of the request body in order to get it).

This can easily get worked around for the HMAC validation (by directly using the raw buffer), but still poses a huge issue when the body is normally parsed and one wants to store the product ID. Indeed, the number is too large for being stored in a 32-bit int / 52-bit number (being normal representation for ints in JS) and precision is then dropped, thus leading to incorrect data received with no error triggered.

I would like to be able to use the body as in a normal API, with no buffer stringifying hacks or number to String casting. Would you have a solution for this ? 


(*) : This is almost surely related to : , but still there is no real solution for now.

Replies 4 (4)

2 0 1

I face the same issue....

How can we handle that ?

Shopify Staff (Retired)
61 7 13

Hi @jacobo 

Would it be possible to use a BigInt? 





To learn more visit the Shopify Help Center or the Community Blog.

2 0 1

Hello @mikedasilva ,

thanks for your answer, unfortunately we cannot use this with the shopify response.

As you can see in this issue, bigInt are not yet supported in JSON.parse. This prevent us from having precise enough parsing of the shopify response.

Indeed this code:

{ "value" : 9223372036854775807}

 would then be parsed as :

{ value: 9223372036854776000 }


There is some libs than can help us avoid this issue like,, but as you can see there is still some limitations (no round trips in this case)

Yes JS has a new primitive BigInt but its not quite well supported.

Is there another way you'll recommend us to use to face this problem ?

Thanks again,


1 0 0

Hello! I have the same problem on Fastify. Does someone solved this without custom body parsers? Using json-bigint affect all other routes.