Pull a page of NASA's TikTok videos through our API and look at the author fields. author.uid says "7664638705177150477". A little further down, author_user_id says 7664638705177150000. Same account, two different IDs, and the second one is wrong. It lost its last three digits somewhere along the way, and nothing raised an error.
The sound on the same video shows the pattern again: music.id_str is "7665075815390645006", while music.id is 7665075815390645000.
This bug is older than TikTok. JavaScript can't represent integers that long, and 19-digit IDs are now the norm on TikTok, X and Instagram. Here's what goes wrong, which fields to trust, and how to parse JSON without losing digits.
Why 19-digit IDs get rounded
JavaScript stores every number as a 64-bit floating-point value. Those hold integers exactly only up to Number.MAX_SAFE_INTEGER, which is 9,007,199,254,740,991: sixteen digits. TikTok video, user and sound IDs are 19 digits (around 7.7 quintillion), and so are X post IDs (around 2.1 quintillion today). Past that limit, a float can't represent every integer, so JSON.parse quietly rounds to the nearest one it can:
JSON.parse('{"id": 7664638705177150477}').id;
// 7664638705177150000
No exception, no warning. The rounded value still looks like an ID, so it flows straight into your database, your joins and your dedupe logic. You find out weeks later when two creators collapse into one row, or a lookup by ID returns nothing.
Python doesn't have this problem. Its integers have arbitrary precision, so json.loads keeps all 19 digits. The trouble starts when the data passes through JavaScript: a Node service, a browser dashboard, or a no-code tool built on one.
Which TikTok fields are safe
TikTok sends many IDs twice, once as a number and once as a string, for exactly this reason. Read the string.
| What you want | Read this (string) | Don't read this (number) |
|---|---|---|
| Video ID | aweme_id | (always a string) |
| Author ID | author.uid | author_user_id |
| Sound ID | music.id_str or music.mid | music.id |
| Added sound ID | added_sound_music_info.id_str | added_sound_music_info.id |
There's one more thing to know about our TikTok responses. In list responses, such as a creator's videos, those number fields arrive already rounded: the 7664638705177150000 above is exactly what the response contains. A lossless parser can't bring back digits that are already gone, so the only fix is to read the string field next to it. Our single-video endpoint (video-info) returns these IDs as strings.
A few other long numeric fields show up in TikTok responses too, such as music_ugid and the IDs inside caption data (cla_subtitle_id, complaint_id). You'll rarely need them, but don't key anything on them.
X (Twitter) IDs
X post IDs are Snowflake IDs, and they crossed JavaScript's safe limit years ago. A post ID today looks like 2122404409292337592. Twitter's old v1.1 API returned every ID twice, id as a number and id_str as a string, and its docs told developers to use the string for exactly this reason.
In our X responses, IDs arrive as strings: rest_id and id_str for posts, user_id_str for users and conversation_id_str for threads. Keep them as strings all the way into your database and you'll never hit the bug.
Instagram IDs
Instagram media IDs are just as long, which is why our shortcode to media ID converter uses BigInt for the math. If you convert or compare Instagram IDs in JavaScript, do it with BigInt or as strings, never as plain numbers.
How to parse JSON without losing digits
1. Don't call res.json(). It parses with plain JSON.parse before your code gets a chance to step in. Read the body as text and parse it yourself.
2. On a modern runtime, use the reviver's source text. Node.js 21 and later, and Chromium-based browsers, pass the original text of each value to JSON.parse's reviver. You can keep any unsafe integer as a string and leave everything else alone:
function parseKeepingBigIds(text) {
return JSON.parse(text, (key, value, context) =>
Number.isInteger(value) && !Number.isSafeInteger(value) && context?.source
? context.source // keep all the original digits, as a string
: value,
);
}
const res = await fetch(
"https://api.sociavault.com/v1/scrape/tiktok/videos?handle=nasa",
{ headers: { "x-api-key": process.env.SOCIAVAULT_KEY } },
);
const body = parseKeepingBigIds(await res.text());
Small numbers like play counts stay numbers, decimals like 0.5 stay decimals, and only integers past the safe limit become strings. Check other runtimes before relying on this, because support for the third reviver argument is recent.
3. On older runtimes, use a library. json-bigint with storeAsString turns big integers into strings, and lossless-json gives you more control:
const JSONbig = require("json-bigint")({ storeAsString: true });
const res = await fetch(url, { headers });
const body = JSONbig.parse(await res.text());
4. Do math with BigInt, not Number. If you need to compare or sort IDs numerically, convert the strings: BigInt("7664638705177150477") > BigInt("7664638705177150000") is true, while the same comparison on plain numbers can't even tell them apart.
In Python, plain json.loads or requests' .json() is fine. Just remember the rounding comes back the moment you hand the data to a JavaScript front end.
Store IDs as text
- Postgres and BigQuery:
BIGINTandINT64hold up to 9,223,372,036,854,775,807, so TikTok and X IDs fit as integers. But if any step in your pipeline is JavaScript, store them asTEXTand you never have to think about it again. - Spreadsheets: Excel keeps only 15 significant digits, and Google Sheets runs into the same limit as JavaScript. Paste an ID into a number column and it turns into a rounded number or scientific notation. Format the column as text before importing.
- pandas: read ID columns as strings, for example
pd.read_json(path, dtype={"aweme_id": str}). A column of big integers with one missing value silently becomes floats, and the digits go with it.
What this can't do
- Digits that are already gone stay gone. If a field arrives rounded, like
author_user_idin our TikTok list responses, no parser can recover it. Use its string twin, or fetch the item from a single-item endpoint. - Some long numbers have no string twin. A few internal TikTok fields only come as numbers. You rarely need them, but don't build anything on them.
- The reviver trick needs a recent runtime. On anything older, use
json-bigintorlossless-json.
Frequently Asked Questions
Why does my TikTok ID end in 000?
Because it went through a JavaScript number. Integers above 9,007,199,254,740,991 can't be stored exactly, so JSON.parse rounds them, and the last digits usually come out as zeros. Read the string version of the field (aweme_id, author.uid, music.id_str) instead.
Does Python have the same problem?
No. Python integers have arbitrary precision, so json.loads keeps all 19 digits. The problem comes back as soon as the data reaches JavaScript, a spreadsheet, or a dataframe column that turned into floats.
Which TikTok ID fields should I store?
aweme_id for videos, author.uid for creators and music.id_str for sounds. All three are strings. Avoid author_user_id and music.id, which are numbers and can arrive already rounded in list responses.
Do X (Twitter) IDs have the same problem?
Yes. X post IDs are 19 digits and well past JavaScript's safe limit. Use the string fields, rest_id or id_str, and keep them as strings.
How do I parse big numbers in JavaScript?
Read the response with res.text(), then either use JSON.parse with a reviver that returns context.source for unsafe integers (Node.js 21 and later) or a library like json-bigint with storeAsString. Do any numeric comparison with BigInt.
Can I store TikTok IDs as BIGINT?
Yes. Postgres BIGINT and BigQuery INT64 can hold them. If any part of your pipeline is JavaScript, store them as text instead, and never in a spreadsheet number column.
Want to see the string fields in your own responses? Grab 50 free credits, no card needed, and pull a creator's videos. If you're mapping handles to IDs, our guide to finding user IDs on Instagram, TikTok and X covers that step, and parsing dates from social media APIs deals with the other field that breaks pipelines.
Found this helpful?
Share it with others who might benefit
Ready to Try SociaVault?
Start extracting social media data with our powerful API. No credit card required.