-
-
Save witchfindertr/d662ee148e82feb31e708f5aa61daedd to your computer and use it in GitHub Desktop.
| def get_user_id(username): | |
| headers = { | |
| 'authority': 'i.instagram.com', | |
| 'accept': '*/*', | |
| 'accept-language': 'en-GB,en-US;q=0.9,en;q=0.8', | |
| 'origin': 'https://www.instagram.com', | |
| 'referer': 'https://www.instagram.com/', | |
| 'sec-ch-ua': '"Google Chrome";v="105", "Not)A;Brand";v="8", "Chromium";v="105"', | |
| 'sec-ch-ua-mobile': '?0', | |
| 'sec-ch-ua-platform': '"Windows"', | |
| 'sec-fetch-dest': 'empty', | |
| 'sec-fetch-mode': 'cors', | |
| 'sec-fetch-site': 'same-site', | |
| 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36', | |
| 'x-csrftoken': '2SAvFYoHgS8GwleiP7j5vTLPqRJX4IFL', | |
| 'x-ig-app-id': '936619743392459', | |
| } | |
| params = { | |
| 'username': username, | |
| } | |
| r = requests.get('https://i.instagram.com/api/v1/users/web_profile_info/', params=params, headers=headers) | |
| id = r.text.split('"id":"')[2].split('"')[0] | |
| return | |
| https://github.com/Hazza3100/Instagram-Aio/blob/main/main.py |
Verify Linkedin Token
https://api.linkedin.com/v2/me?oauth2_access_token=${token}
Verify Instagram Token
https://graph.instagram.com/me?access_token=${token}
Verify Google Token
https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=${token}
Verify Facebook Token
https://graph.facebook.com/me?access_token=${token}
Good Practices
Microsoft REST API Guidelines
Learn REST: A RESTful Tutorial и книга по мотивам сайта
How to design a REST API
Best Practices for Designing a Pragmatic RESTful API
White House Web API Standards
10 Best Practices for Better RESTful API
API design best practices
Создание RESTful API
Шпаргалка по созданию RESTful API
Errors and statuses
API Best Practices: Response Handling
RESTful API Design: what about errors?
Error handling considerations and best practices
Pagination
API pagination best practices
Examples
twitter
github
instagram
facebook
vk
pinterest
Tools
Swagger Framework for APIs
apiDoc
Testing in a browser
Postman для google chrome
public static final String FEED = "https://i.instagram.com/api/v1/feed/user/%s/";
public static final String FOLLOW = "https://i.instagram.com/api/v1/friendships/create/%s/";
public static final String FOLLOWERS = "https://i.instagram.com/api/v1/friendships/%s/followers/";
public static final String FOLLOWING = "https://i.instagram.com/api/v1/friendships/%s/following/";
public static final String GET_POST = "https://i.instagram.com/api/v1/media/%s/info/";
public static final String LIKE = "https://i.instagram.com/api/v1/media/%s/like/?d=0&src=%s";
public static final String LOGIN = "https://i.instagram.com/api/v1/accounts/login/";
public static final String MEDIA_CONFIG = "https://i.instagram.com/api/v1/media/configure/";
public static final String POPULAR = "https://i.instagram.com/api/v1/feed/popular/";
public static final String SERVER_URL = "https://i.instagram.com/api/v1/";
public static final String SET_PROFILE = "https://i.instagram.com/api/v1/accounts/edit_profile/";
public static final String SHOW_MANY = "https://i.instagram.com/api/v1/friendships/show_many/";
public static final String SINGUP = "https://i.instagram.com/api/v1/accounts/create/";
public static final String TAGLINE = "https://i.instagram.com/api/v1/feed/tag/%s/";
public static final String TAG_SEARCH = "https://i.instagram.com/api/v1/tags/search/?q=%s";
public static final String TIMELINE = "https://i.instagram.com/api/v1/feed/timeline/";
public static final String UPLOAD = "https://i.instagram.com/api/v1/upload/photo/";
public static final String USERLIKED = "https://i.instagram.com/api/v1/feed/liked/";
public static final String USER_INFO = "https://i.instagram.com/api/v1/users/%s/info/";
public static final String USER_SEARCH = "https://i.instagram.com/api/v1/users/search/?query=%s";
public function get_user_posts($username = null){
$cache = $this->cache('users/'.$username.'-posts');
if($cache === false){
$post_hashquery = $this->get_post_queryhash();
$user_id = $this->functions->user->get_user_id($username);
$url = 'https://www.instagram.com/graphql/query/?query_hash='.$post_hashquery.'&variables={"id":"'.$user_id.'","first":500}';
$json = $this->get($url);
$json = json_decode($json['body'])->data->user;
$this->cache('users/'.$username.'-posts', $json);
$result = $json;
}
else{
$result = $cache;
}
return $result;
}
public function get_stories($username = null){
$username = $this->functions->user->get_user_id($username ?? $this->username);
$url = 'https://i.instagram.com/api/v1/feed/user/'.$username.'/story/?supported_capabilities_new=%5B%7B%22name%22%3A%22SUPPORTED_SDK_VERSIONS%22%2C%22value%22%3A%22114.0%2C115.0%2C116.0%2C117.0%2C118.0%2C119.0%2C120.0%2C121.0%2C122.0%2C123.0%2C124.0%2C125.0%2C126.0%2C127.0%2C128.0%2C129.0%2C130.0%22%7D%2C%7B%22name%22%3A%22FACE_TRACKER_VERSION%22%2C%22value%22%3A%2214%22%7D%2C%7B%22name%22%3A%22segmentation%22%2C%22value%22%3A%22segmentation_enabled%22%7D%2C%7B%22name%22%3A%22COMPRESSION%22%2C%22value%22%3A%22ETC2_COMPRESSION%22%7D%2C%7B%22name%22%3A%22world_tracker%22%2C%22value%22%3A%22world_tracker_enabled%22%7D%2C%7B%22name%22%3A%22gyroscope%22%2C%22value%22%3A%22gyroscope_enabled%22%7D%5D';
$json = $this->get($url);
$json = json_decode($json['body']);
return $json;
}
public function get_my_story_seen_list($media_id = null){
if($media_id != null){
$url = 'https://i.instagram.com/api/v1/media/'.$media_id.'/list_reel_media_viewer/?supported_capabilities_new=[{"name":"SUPPORTED_SDK_VERSIONS","value":"114.0,115.0,116.0,117.0,118.0,119.0,120.0,121.0,122.0,123.0,124.0,125.0,126.0,127.0,128.0,129.0,130.0"},{"name":"FACE_TRACKER_VERSION","value":"14"},{"name":"segmentation","value":"segmentation_enabled"},{"name":"COMPRESSION","value":"ETC2_COMPRESSION"},{"name":"world_tracker","value":"world_tracker_enabled"},{"name":"gyroscope","value":"gyroscope_enabled"}]';
$json = $this->get($url);
$json = json_decode($json['body']);
return $json;
}
return false;
}
static const baseUrl = 'https://i.instagram.com/api/v1';
static String getAccountInfoById(String igUserId) => '$baseUrl/users/$igUserId/info';
static String getAccountInfoByUsername(String username) => '$baseUrl/users/web_profile_info/?username=$username';
//'https://i.instagram.com/api/v1/friendships/$friendIgUserId/following/?order=date_followed_latest$maxIdString'); //?max_id=$i&order=date_followed_latest
static String getFollowings(String igUserId, String maxId) =>
'$baseUrl/friendships/$igUserId/following/?order=date_followed_latest$maxId';
//'https://i.instagram.com/api/v1/friendships/55299305811/followers/?order=date_followed_latest'); //?max_id=$i&order=date_followed_latest
static String getFollowers(String igUserId, String maxId) =>
'$baseUrl/friendships/$igUserId/followers/?order=date_followed_latest$maxId';
//https://i.instagram.com/api/v1/feed/reels_tray/
static String getUserStories() => '$baseUrl/feed/reels_tray/';
//https://i.instagram.com/api/v1/feed/reels_media/?reel_ids=3139331705
static String getStories({required userId}) => '$baseUrl/feed/reels_media/?reel_ids=$userId';
// https://i.instagram.com/api/v1/web/friendships/3923655548/follow/
static String followUser(String userId) => '$baseUrl/web/friendships/$userId/follow/';
// https://i.instagram.com/api/v1/web/friendships/3923655548/unfollow/
static String unfollowUser(String userId) => '$baseUrl/web/friendships/$userId/unfollow/';
$url = 'https://i.instagram.com/api/v1/feed/user/'.$username.'/story/';
$json = $this->request($url, 'GET');
$json = json_decode($json['body']);
return $json;
public function get_user_id($username = null){
$username = $username ?? $this->username;
if($username != null){
$cache = $this->cache($username.'-id');
if($cache === false){
$url = 'https://www.instagram.com/web/search/topsearch/?query='.$username;
$json = $this->request($url);
$json = json_decode($json['body']);
$user_id = 0;
foreach($json->users as $user){
if($username == $user->user->username){
$user_id = $user->user->pk;
}
}
$this->cache($username.'-id', $user_id);
}else{
$user_id = $cache;
}
return $user_id;
}
return false;
}
function searchUser(query) {
return new Promise((resolve, reject) => {
Axios.get('https://www.instagram.com/web/search/topsearch/?query=' + query , {
headers: {
Cookie: sessionid=${sesid}
}
}).then(({ data }) => {
const all = data.users
const result = []
for (let i = 0; i < all.length; i++) {
result.push({
number: all[i].position + 1,
pk_id: all[i].user.pk,
username: all[i].user.username,
name: all[i].user.full_name,
latest_reel: all[i].user.latest_reel_media,
is_private: all[i].user.is_private,
is_verified: all[i].user.is_verified,
pic: all[i].user.profile_pic_url
})
}
resolve(result)
}).catch(reject)
})
}
const GENERAL_SEARCH = 'https://www.instagram.com/web/search/topsearch/?query={query}&count={count}';
def search_for_user(user, username)
rank_token = IgApi::Http.generate_rank_token user.session.scan(/ds_user_id=([\d]+);/)[0][0]
endpoint = 'https://i.instagram.com/api/v1/users/search/'
param = format('?is_typehead=true&q=%s&rank_token=%s', username, rank_token)
result = api.get(endpoint + param)
.with(session: user.session, ua: user.useragent).exec
result = JSON.parse result.body, object_class: OpenStruct
if result.num_results > 0
user_result = result.users[0]
user_object = IgApi::User.new username: username
user_object.data = user_result
user_object.session = user.session
user_object
end
const getStories = module.exports.getStories = (userId) => {
return new Bluebird((resolve, reject) => {
agent
.get(util.format('https://i.instagram.com/api/v1/feed/user/%s/story/', userId))
.set('User-Agent','Instagram 10.26.0 (iPhone7,2; iOS 10_1_1; en_US; en-US; scale=2.00; gamut=normal; 750x1334) AppleWebKit/420+')
.set('Accept', '/')
.set('Referer', 'https://www.instagram.com/')
.set('Accept-Encoding', 'gzip, deflate, br')
.set('Accept-Language', 'en-US,en;q=0.8')
.set('Cookie', util.format(
'sessionid=%s; ds_user_id=%s; csrftoken=%s',
webCookies.sessionid, webCookies.ds_user_id, webCookies.csrftoken
))
.withCredentials()
.end(function(err, res){
if (err || !res.ok) {
return reject(err);
} else {
if(_.isUndefined(res.body.reel) || .isNull(res.body.reel)){
return resolve([]);
}
return resolve(.map(res.body.reel.items, (item) => {
return {
type: item.media_type == 1 ? 'image' : 'video',
originalContentUrl: item.media_type == 1 ?
_.head(item.image_versions2.candidates).url :
_.head(item.video_versions).url,
previewImageUrl: _.last(item.image_versions2.candidates).url
};
}));
function getUserId($username){
$response = instagramRequest("https://i.instagram.com/api/v1/users/web_profile_info/?username={$username}");
$response_obj = json_decode($response);
$user_id = $response_obj -> data -> user -> id;
return $user_id;
}
//Returns if the user account is private or not
function isPrivate($username){
$response = instagramRequest("https://i.instagram.com/api/v1/users/web_profile_info/?username={$username}");
$response_obj = json_decode($response);
$is_private = $response_obj -> data -> user -> is_private;
return $is_private;
}
//Returns an array of Instagram stories for the provided user id
function getStories($user_id){
$response = instagramRequest("https://i.instagram.com/api/v1/feed/user/{$user_id}/reel_media/");
$response_obj = json_decode($response);
"https://i.instagram.com/api/v1/users/web_profile_info/?username=" +
username,
{
headers: {
"x-ig-app-id": "936619743392459",
},
from requests import get
sessions = open('sessions.txt','r').read().splitlines()
def check(session):
url = 'https://i.instagram.com/api/v1/users/search/?timezone_offset=10800&q=zyl7&count=10&rank_token=0'
headers={
"User-Agent": "Instagram 9.7.0 Android (24/7.0; 420dpi; 1080x1920; samsung; SM-N920P; nobleltespr; samsungexynos7420; ar_IQ)",
"Cookie": f"sessionid={session}"
}
resp = get(url,headers=headers).text
return resp
work = 0
notwork = 0
for session in sessions:
resp = check(session)
if '"status":"ok"' in resp:
print(session)
work +=1
with open('sessions working.txt', 'a', encoding='utf-8', errors='ignore') as p:
p.writelines(session + '\n')
else:
notwork+=1
print(f'Working : {str(work)}')
$search = curl_init();
curl_setopt($search, CURLOPT_URL, "https://www.instagram.com/web/search/topsearch/?query=$word1");
curl_setopt($search, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($search, CURLOPT_ENCODING , "");
curl_setopt($search, CURLOPT_HTTPHEADER, [
'accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3;q=0.9',
'accept-language: en-US,en;q=0.9',
'cache-control: max-age=0',
'cookie: '.$accounts[$file]['cookies'],
'user-agent: '.$accounts[$file]['useragent']
]);
$search = curl_exec($search);
$search = json_decode($search);
public function get_stories($username = null){
$username = $this->functions->user->get_user_id($username ?? $this->username);
$url = 'https://i.instagram.com/api/v1/feed/user/'.$username.'/story/?supported_capabilities_new=%5B%7B%22name%22%3A%22SUPPORTED_SDK_VERSIONS%22%2C%22value%22%3A%22114.0%2C115.0%2C116.0%2C117.0%2C118.0%2C119.0%2C120.0%2C121.0%2C122.0%2C123.0%2C124.0%2C125.0%2C126.0%2C127.0%2C128.0%2C129.0%2C130.0%22%7D%2C%7B%22name%22%3A%22FACE_TRACKER_VERSION%22%2C%22value%22%3A%2214%22%7D%2C%7B%22name%22%3A%22segmentation%22%2C%22value%22%3A%22segmentation_enabled%22%7D%2C%7B%22name%22%3A%22COMPRESSION%22%2C%22value%22%3A%22ETC2_COMPRESSION%22%7D%2C%7B%22name%22%3A%22world_tracker%22%2C%22value%22%3A%22world_tracker_enabled%22%7D%2C%7B%22name%22%3A%22gyroscope%22%2C%22value%22%3A%22gyroscope_enabled%22%7D%5D';
$json = $this->get($url);
$json = json_decode($json['body']);
return $json;
}
public function get_my_story_seen_list($media_id = null){
if($media_id != null){
$url = 'https://i.instagram.com/api/v1/media/'.$media_id.'/list_reel_media_viewer/?supported_capabilities_new=[{"name":"SUPPORTED_SDK_VERSIONS","value":"114.0,115.0,116.0,117.0,118.0,119.0,120.0,121.0,122.0,123.0,124.0,125.0,126.0,127.0,128.0,129.0,130.0"},{"name":"FACE_TRACKER_VERSION","value":"14"},{"name":"segmentation","value":"segmentation_enabled"},{"name":"COMPRESSION","value":"ETC2_COMPRESSION"},{"name":"world_tracker","value":"world_tracker_enabled"},{"name":"gyroscope","value":"gyroscope_enabled"}]';
$json = $this->get($url);
$json = json_decode($json['body']);
return $json;
}
return false;
}
// avoid 429 Rate limit from Instagram
sleep(1);
function getUserId(username)
{
return new Promise(function(resolve) {
var xhr = new XMLHttpRequest();
xhr.open("GET", "https://www.instagram.com/" + username + "/?__a=1");
xhr.withCredentials = true;
xhr.addEventListener("load", function() {
var response = JSON.parse(xhr.responseText);
resolve(response.graphql.user.id);
});
xhr.send();
});
}