instagram-private-api icon indicating copy to clipboard operation
instagram-private-api copied to clipboard

Support for "Hide Like and View Counts" Option When Posting

Open tihhgoncalves opened this issue 6 months ago • 2 comments

Hi! First of all, thank you for your work on this library, it’s been very helpful in my projects.

I would like to know if there is any way to create a post with the "Hide Like and View Counts" option enabled, similar to what is available in the official Instagram app. I’ve searched the documentation and issues, but couldn’t find any reference to this feature.

Is there an endpoint or workaround to set this option via the API? If not, is it something planned for future updates, or is there any technical limitation that prevents this?

Thanks in advance!

tihhgoncalves avatar Jun 10 '25 12:06 tihhgoncalves

You have to modify in source code. After get API using mitm proxy

sunmasters avatar Jul 19 '25 03:07 sunmasters

import { IgApiClient } from 'instagram-private-api';
import fs from 'fs';

async function postPhotoWithSettings() {
  const ig = new IgApiClient();
  ig.state.generateDevice('username');
  await ig.account.login('username', 'password');

  const photoPath = './photo.jpg';
  const fileBuffer = fs.readFileSync(photoPath);

  const likeAndViewCountsDisabled = true;  // Hide like/view counts
  const disableComments = true;            // Turn off comments
  const coAuthorUserId = '1234567890';     // Optional co-author user ID
  const caption = '🚀 Testing hidden likes, disabled comments, and co-author!';

  const uploadResult = await ig.publish.photo({
    file: fileBuffer,
    caption: caption,
    like_and_view_counts_disabled: likeAndViewCountsDisabled ? '1' : '0',
    disable_comments: disableComments ? '1' : '0',
    invite_coauthor_user_id: coAuthorUserId || undefined,
  });

  console.log('✅ Photo posted successfully:', uploadResult.media.code);
}

postPhotoWithSettings().catch(console.error);

mjohnsoncode avatar Nov 04 '25 17:11 mjohnsoncode