Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8644113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:12:57+00:00 2026-06-12T12:12:57+00:00

How can I get the user ID with the user name with instagram API

  • 0

How can I get the user ID with the user name with instagram API without user authentication? If I try users/search, it returns multiple research results, so how can I be sure that I get the result of exact user name only?

For example, following requests return multiple users having their usernames similiar to aliciakeys, I want to get only the data of the user with exact user name.

https://api.instagram.com/v1/users/search?q=aliciakeys&access_token=[your token]
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T12:12:58+00:00Added an answer on June 12, 2026 at 12:12 pm

    If you know that the search term will always be the full username and you can simply iterate through the results and stop when the username is an exact match of the search query.

    Also, don’t ever expose your access tokens in public.

    This is how you would do it in PHP

    <?php
    
    
    function getInstaID($username)
    {
    
        $username = strtolower($username); // sanitization
        $token = "InsertThatHere";
        $url = "https://api.instagram.com/v1/users/search?q=".$username."&access_token=".$token;
        $get = file_get_contents($url);
        $json = json_decode($get);
    
        foreach($json->data as $user)
        {
            if($user->username == $username)
            {
                return $user->id;
            }
        }
    
        return '00000000'; // return this if nothing is found
    }
    
    echo getInstaID('aliciakeys'); // this should print 20979117
    
    ?>
    

    Actually, chances are that if you are searching for the full username, almost every time you search for it, the first result will be the one you would be looking for.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anybody know, is it possible and how can I get name of user
How can one get user's location from Google? I can't find any suitable API
Ho can i get user account name, that ran the process with specified id.
How can get in ASP.NET user name and password from URL? https://myUser:myPassword@myServer/ HttpContext.Current.Request.Url is
I can get user inputed name(username) with following code from a form. So my
how can I get the user name that auth by pam_ldap in C/c++? I
How can I get the user name of Windows Login? I used these methods:
I already asked about how to get the user name. How can I get
I can get the user name as User.Identity.Name . How can I get a
users can sign up to my site and get a standard url (username.teamgeisthq.com) from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.