Announcement
$410.23
import requests
import json
# Replace 'ACCESS_TOKEN' with a valid Instagram API access token
ACCESS_TOKEN = 'ACCESS_TOKEN'
# Set the URL for the Instagram API endpoint for retrieving user information
url = 'https://api.instagram.com/v1/users/self/?access_token=' + ACCESS_TOKEN
# Send a GET request to the API endpoint
response = requests.get(url)
# Check the status code of the response
if response.status_code == 200:
# Load the user data from the response
user_data = json.loads(response.text)
# Get the user's username
username = user_data['data']['username']
# Print the user's username
print(f"Username: @{username}")
else:
# Print an error message if the request fails
print("Error retrieving user data")
info about the product