├── .gitignore ├── .npmignore ├── LICENSE-MIT ├── README.md ├── index.js ├── lib └── instagram.js └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | -------------------------------------------------------------------------------- /LICENSE-MIT: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 Guilherme Farias 2 | 3 | Permission is hereby granted, free of charge, to any person 4 | obtaining a copy of this software and associated documentation 5 | files (the "Software"), to deal in the Software without 6 | restriction, including without limitation the rights to use, 7 | copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the 9 | Software is furnished to do so, subject to the following 10 | conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 17 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 20 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # instagram-api 2 | 3 | NodeJS Library for Instagram. 4 | 5 | ## Installation 6 | 7 | `npm install instagram-api` 8 | 9 | ## Setting up a connection 10 | 11 | ```javascript 12 | var accessToken = '23612221.3fcb46b.348431486f3a4fb85081d5242db9ca1c'; 13 | var InstagramAPI = require('instagram-api'); 14 | var instagramAPI = new InstagramAPI(accessToken); 15 | ``` 16 | ## Promises 17 | 18 | This package uses promises to control async control-flow. If you are unfamiliar with how promises work, now might be a good time to brush up on them, [here](https://github.com/wbinnssmith/awesome-promises) and [here](http://bluebirdjs.com/docs/why-promises.html) 19 | 20 | Basically a promise represents a value which will be present at some point - "I promise you I will give you a result or an error at some point". This means that 21 | 22 | ```javascript 23 | // DON'T DO THIS 24 | user = instagramAPI.userSelf() 25 | console.log(user); 26 | ``` 27 | 28 | will never work! This is because user is a promise object, not a data from Instagram. The right way to do it is: 29 | 30 | ```javascript 31 | instagramAPI.userSelf().then(function(result) { 32 | console.log(result.data); // user info 33 | console.log(result.limit); // api limit 34 | console.log(result.remaining) // api request remaining 35 | }, function(err){ 36 | console.log(err); // error info 37 | }); 38 | ``` 39 | 40 | ## API Methods 41 | 42 | ### userSelf([requestOptions]) 43 | Get information about the owner of the access_token. 44 | 45 | __Permission Requirements:__ `basic` 46 | 47 | ### user(userId[, requestOptions]) 48 | Get information about a user. This endpoint requires the public_content scope if the user-id is not the owner of the access_token. 49 | 50 | __Permission Requirements:__ `public_content` 51 | 52 | ### userSelfMedia(params[, requestOptions]) 53 | Get the most recent media published by the owner of the access_token. 54 | 55 | __Permission Requirements:__ `basic` 56 | 57 | ### userMedia(userId, options[, requestOptions]) 58 | Get the most recent media published by a user. This endpoint requires the public_content scope if the user-id is not the owner of the access_token. 59 | 60 | __Permission Requirements:__ `public_content` 61 | 62 | ### userSelfMediaLiked(options[, requestOptions]) 63 | Get the list of recent media liked by the owner of the access_token. 64 | 65 | __Permission Requirements:__ `public_content` 66 | 67 | ### userSearch(term, options[, requestOptions]) 68 | Get a list of users matching the query. 69 | 70 | __Permission Requirements:__ `public_content` 71 | 72 | ### userSelfFollows(options[, requestOptions]) 73 | Get the list of users this user follows. 74 | 75 | __Permission Requirements:__ `follower_list` 76 | 77 | ### userSelfFollowedBy(options[, requestOptions]) 78 | Get the list of users this user is followed by. 79 | 80 | __Permission Requirements:__ `follower_list` 81 | 82 | ### userSelfRequestedBy([requestOptions]) 83 | List the users who have requested this user's permission to follow. 84 | 85 | __Permission Requirements:__ `follower_list` 86 | 87 | ### userRelationship(userId[, requestOptions]) 88 | Get information about a relationship to another user. Relationships are expressed using the following terms in the response: 89 | * __outgoing_status:__ Your relationship to the user. Can be 'follows', 'requested', 'none'. 90 | * __incoming_status:__ A user's relationship to you. Can be 'followed_by', 'requested_by', 'blocked_by_you', 'none'. 91 | 92 | __Permission Requirements:__ `follower_list` 93 | 94 | ### setUserRelationship(userId, action[, requestOptions]) 95 | Modify the relationship between the current user and the target user. You need to include an action parameter to specify the relationship action you want to perform. Valid actions are: 'follow', 'unfollow' 'approve' or 'ignore'. Relationships are expressed using the following terms in the response: 96 | * __outgoing_status:__ Your relationship to the user. Can be 'follows', 'requested', 'none'. 97 | * __incoming_status:__ A user's relationship to you. Can be 'followed_by', 'requested_by', 'blocked_by_you', 'none'. 98 | 99 | __Permission Requirements:__ `relationships` 100 | 101 | ### media(mediaId[, requestOptions]) 102 | Get information about a media object. Use the type field to differentiate between image and video media in the response. You will also receive the user_has_liked field which tells you whether the owner of the access_token has liked this media. 103 | The public_content permission scope is required to get a media that does not belong to the owner of the access_token. 104 | 105 | __Permission Requirements:__ `basic, public_content` 106 | 107 | ### mediaByShortcode(shortcode[, requestOptions]) 108 | This endpoint returns the same response as GET /media/media-id. 109 | A media object's shortcode can be found in its shortlink URL. An example shortlink is http://instagram.com/p/tsxp1hhQTG/. Its corresponding shortcode is tsxp1hhQTG. 110 | 111 | __Permission Requirements:__ `basic, public_content` 112 | 113 | ### mediaSearch(params[, requestOptions]) 114 | Search for recent media in a given area. 115 | 116 | __Permission Requirements:__ `public_content` 117 | 118 | ### mediaComments(mediaId[, requestOptions]) 119 | Get a list of recent comments on a media object. The public_content permission scope is required to get comments for a media that does not belong to the owner of the access_token. 120 | 121 | __Permission Requirements:__ `basic, public_content` 122 | 123 | ### postMediaComment(mediaId, text[, requestOptions]) 124 | Create a comment on a media object with the following rules: 125 | * The total length of the comment cannot exceed 300 characters. 126 | * The comment cannot contain more than 4 hashtags. 127 | * The comment cannot contain more than 1 URL. 128 | * The comment cannot consist of all capital letters. 129 | 130 | The public_content permission scope is required to create comments on a media that does not belong to the owner of the access_token. 131 | 132 | __Permission Requirements:__ `comments` 133 | 134 | ### removeMediaComment(mediaId, commentId[, requestOptions]) 135 | Remove a comment either on the authenticated user's media object or authored by the authenticated user. 136 | 137 | __Permission Requirements:__ `comments` 138 | 139 | ### mediaLikes(mediaId[, requestOptions]) 140 | Get a list of users who have liked this media. 141 | 142 | __Permission Requirements:__ `basic, public_content` 143 | 144 | ### postMediaLike(mediaId[, requestOptions]) 145 | Set a like on this media by the currently authenticated user. The public_content permission scope is required to create likes on a media that does not belong to the owner of the access_token. 146 | 147 | __Permission Requirements:__ `likes` 148 | 149 | ### removeMediaLike(mediaId[, requestOptions]) 150 | Remove a like on this media by the currently authenticated user. The public_content permission scope is required to delete likes on a media that does not belong to the owner of the access_token. 151 | 152 | __Permission Requirements:__ `likes` 153 | 154 | ### getTag(tagName[, requestOptions]) 155 | Get information about a tag object. 156 | 157 | __Permission Requirements:__ `public_content` 158 | 159 | ### getMediasByTag(tagName, params[, requestOptions]) 160 | Get a list of recently tagged media. 161 | 162 | __Permission Requirements:__ `public_content` 163 | 164 | ### searchTags(tagName[, requestOptions]) 165 | Search for tags by name. 166 | 167 | __Permission Requirements:__ `public_content` 168 | 169 | ### getLocation(locationId[, requestOptions]) 170 | Get information about a location. 171 | 172 | __Permission Requirements:__ `public_content` 173 | 174 | ### getMediasByLocation(locationId, params[, requestOptions]) 175 | Get a list of recent media objects from a given location. 176 | 177 | __Permission Requirements:__ `public_content` 178 | 179 | ### searchLocations(params[, requestOptions]) 180 | Search for a location by geographic coordinate. 181 | 182 | __Permission Requirements:__ `public_content` 183 | 184 | ## Details 185 | 186 | * __requestOptions__ parameter is optional and almost ever should be ignored. 187 | 188 | 189 | ## Changelog 190 | * Version 1.0.3 - 14/10/2016 191 | * Small fixes 192 | * Version 1.0.2 - 27/05/2016 193 | * Pagination fix 194 | * Documentation enhacement 195 | * Version 1.0.1 - 18/05/2016 196 | * Adding docs in README 197 | * Version 1.0.0 - 17/05/2016 198 | * Library working. 199 | 200 | ## License 201 | MIT. 202 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | // Copyright Guilherme Farias. and other Contributors 2 | // 3 | // Permission is hereby granted, free of charge, to any person 4 | // obtaining a copy of this software and associated documentation 5 | // files (the "Software"), to deal in the Software without 6 | // restriction, including without limitation the rights to use, 7 | // copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the 9 | // Software is furnished to do so, subject to the following 10 | // conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be 13 | // included in all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 17 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 20 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | // OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | module.exports = require('./lib/instagram'); 25 | -------------------------------------------------------------------------------- /lib/instagram.js: -------------------------------------------------------------------------------- 1 | // Copyright Guilherme Farias. and other Contributors 2 | // 3 | // Permission is hereby granted, free of charge, to any person 4 | // obtaining a copy of this software and associated documentation 5 | // files (the "Software"), to deal in the Software without 6 | // restriction, including without limitation the rights to use, 7 | // copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the 9 | // Software is furnished to do so, subject to the following 10 | // conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be 13 | // included in all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 17 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 20 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | // OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | module.exports = function(accessToken) { 25 | var q = require('q'); 26 | var https = require('https'); 27 | var query = require('querystring'); 28 | var host = 'api.instagram.com'; 29 | var port = 443; 30 | 31 | function call(method, path, params, requestOptions, callback) { 32 | var req; 33 | var data = null; 34 | 35 | if (!params) { 36 | params = {}; 37 | } 38 | 39 | if (!requestOptions) { 40 | requestOptions = {}; 41 | } 42 | 43 | params.access_token = accessToken; 44 | 45 | requestOptions.host = host; 46 | requestOptions.port = port; 47 | requestOptions.method = method; 48 | requestOptions.path = '/v1' + path + (method === 'GET' || method === 'DELETE' ? '?' + query.stringify(params) : ''); 49 | requestOptions.headers = requestOptions.headers || {}; 50 | 51 | if (method !== 'GET' && method !== 'DELETE') { 52 | data = query.stringify(params); 53 | requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded'; 54 | requestOptions.headers['Content-Length'] = data.length; 55 | } 56 | 57 | req = https.request(requestOptions, function(res) { 58 | var body = ''; 59 | 60 | res.setEncoding('utf8'); 61 | 62 | res.on('data', function(chunk) { 63 | body += chunk; 64 | }); 65 | 66 | res.on('end', function() { 67 | var result; 68 | var limit = parseInt(res.headers['x-ratelimit-limit'], 10) || 0; 69 | var remaining = parseInt(res.headers['x-ratelimit-remaining'], 10) || 0; 70 | 71 | try { 72 | result = JSON.parse(body); 73 | } catch (err) { 74 | err.details = body; 75 | callback(err); 76 | return; 77 | } 78 | 79 | callback(null, result, remaining, limit); 80 | }); 81 | }); 82 | 83 | req.on('error', function(err) { 84 | return callback(err); 85 | }); 86 | 87 | if (data !== null) { 88 | req.write(data); 89 | } 90 | 91 | req.end(); 92 | }; 93 | 94 | function requestHandler(deferred) { 95 | return function(err, result, remaining, limit) { 96 | if (err) { 97 | deferred.reject(err); 98 | return; 99 | } 100 | 101 | if (result && result.meta && result.meta.code === 200) { 102 | return deferred.resolve({ 103 | data: result.data, 104 | pagination: result.pagination, 105 | limit: limit, 106 | remaining: remaining 107 | }); 108 | } else if (result && result.meta) { 109 | deferred.reject(result.meta); 110 | } else { 111 | deferred.reject(result); 112 | } 113 | } 114 | }; 115 | 116 | function userSelf(requestOptions) { 117 | var deferred = q.defer(); 118 | var params = {}; 119 | 120 | call('GET', '/users/self', params, requestOptions, requestHandler(deferred)); 121 | 122 | return deferred.promise; 123 | }; 124 | 125 | function user(userId, requestOptions) { 126 | var deferred = q.defer(); 127 | var params = {}; 128 | 129 | call('GET', '/users/' + userId, params, requestOptions, requestHandler(deferred)); 130 | 131 | return deferred.promise; 132 | }; 133 | 134 | function userSelfMedia(options, requestOptions) { 135 | var deferred = q.defer(); 136 | var params = { 137 | count: 50 138 | }; 139 | 140 | if(options && options.count){ 141 | params.count = options.count; 142 | } 143 | 144 | if(options && options.min_id){ 145 | params.min_id = options.min_id; 146 | } 147 | 148 | if(options && options.max_id){ 149 | params.max_id = options.max_id; 150 | } 151 | 152 | call('GET', '/users/self/media/recent/', params, requestOptions, requestHandler(deferred)); 153 | 154 | return deferred.promise; 155 | }; 156 | 157 | function userMedia(userId, options, requestOptions) { 158 | var deferred = q.defer(); 159 | var params = { 160 | count: 50 161 | }; 162 | 163 | if(options && options.count){ 164 | params.count = options.count; 165 | } 166 | 167 | if(options && options.min_id){ 168 | params.min_id = options.min_id; 169 | } 170 | 171 | if(options && options.max_id){ 172 | params.max_id = options.max_id; 173 | } 174 | 175 | call('GET', '/users/' + userId + '/media/recent/', params, requestOptions, requestHandler(deferred)); 176 | 177 | return deferred.promise; 178 | }; 179 | 180 | function userSelfMediaLiked(options, requestOptions) { 181 | var deferred = q.defer(); 182 | var params = { 183 | count: 50 184 | }; 185 | 186 | if(options && options.count){ 187 | params.count = options.count; 188 | } 189 | 190 | if(options && options.max_like_id){ 191 | params.max_like_id = options.max_like_id; 192 | } 193 | 194 | call('GET', '/users/self/media/liked/', params, requestOptions, requestHandler(deferred)); 195 | 196 | return deferred.promise; 197 | }; 198 | 199 | function userSearch(term, options, requestOptions) { 200 | var deferred = q.defer(); 201 | var params = { 202 | q: term, 203 | count: 50 204 | }; 205 | 206 | if(options && options.count){ 207 | params.count = options.count; 208 | } 209 | 210 | call('GET', '/users/search', params, requestOptions, requestHandler(deferred)); 211 | 212 | return deferred.promise; 213 | }; 214 | 215 | function userSelfFollows(options, requestOptions) { 216 | var deferred = q.defer(); 217 | var params = {}; 218 | 219 | if(options && options.cursor){ 220 | params.cursor = options.cursor; 221 | } 222 | 223 | call('GET', '/users/self/follows/', params, requestOptions, requestHandler(deferred)); 224 | 225 | return deferred.promise; 226 | }; 227 | 228 | function userSelfFollowedBy(options, requestOptions) { 229 | var deferred = q.defer(); 230 | var params = {}; 231 | 232 | if(options && options.cursor){ 233 | params.cursor = options.cursor; 234 | } 235 | 236 | call('GET', '/users/self/followed-by/', params, requestOptions, requestHandler(deferred)); 237 | return deferred.promise; 238 | }; 239 | 240 | function userSelfRequestedBy(requestOptions) { 241 | var deferred = q.defer(); 242 | var params = {}; 243 | 244 | call('GET', '/users/self/requested-by/', params, requestOptions, requestHandler(deferred)); 245 | 246 | return deferred.promise; 247 | }; 248 | 249 | function userRelationship(userId, requestOptions) { 250 | var deferred = q.defer(); 251 | var params = {}; 252 | 253 | call('GET', '/users/' + userId + '/relationship', params, requestOptions, requestHandler(deferred)); 254 | 255 | return deferred.promise; 256 | }; 257 | 258 | function setUserRelationship(userId, action, requestOptions) { 259 | var deferred = q.defer(); 260 | var params = { 261 | action: action 262 | }; 263 | 264 | call('POST', '/users/' + userId + '/relationship', params, requestOptions, requestHandler(deferred)); 265 | 266 | return deferred.promise; 267 | }; 268 | 269 | function media(mediaId, requestOptions) { 270 | var deferred = q.defer(); 271 | var params = {}; 272 | 273 | call('GET', '/media/' + mediaId, params, requestOptions, requestHandler(deferred)); 274 | 275 | return deferred.promise; 276 | }; 277 | 278 | function mediaByShortcode(shortcode, requestOptions) { 279 | var deferred = q.defer(); 280 | var params = {}; 281 | 282 | call('GET', '/media/shortcode/' + shortcode, params, requestOptions, requestHandler(deferred)); 283 | 284 | return deferred.promise; 285 | }; 286 | 287 | function mediaSearch(options, requestOptions) { 288 | var deferred = q.defer(); 289 | var params = { 290 | lat: options.lat, 291 | lng: options.lng, 292 | distance: options.distance 293 | }; 294 | 295 | call('GET', '/media/search', params, requestOptions, requestHandler(deferred)); 296 | 297 | return deferred.promise; 298 | }; 299 | 300 | function mediaComments(mediaId, requestOptions) { 301 | var deferred = q.defer(); 302 | var params = {}; 303 | 304 | call('GET', '/media/' + mediaId + '/comments', params, requestOptions, requestHandler(deferred)); 305 | 306 | return deferred.promise; 307 | }; 308 | 309 | function postMediaComment(mediaId, text, requestOptions) { 310 | var deferred = q.defer(); 311 | var params = { 312 | text: text 313 | }; 314 | 315 | call('POST', '/media/' + mediaId + '/comments', params, requestOptions, requestHandler(deferred)); 316 | 317 | return deferred.promise; 318 | }; 319 | 320 | function removeMediaComment(mediaId, commentId, requestOptions) { 321 | var deferred = q.defer(); 322 | var params = {}; 323 | 324 | call('DELETE', '/media/' + mediaId + '/comments/' + commentId, params, requestOptions, requestHandler(deferred)); 325 | 326 | return deferred.promise; 327 | }; 328 | 329 | function mediaLikes(mediaId, requestOptions) { 330 | var deferred = q.defer(); 331 | var params = {}; 332 | 333 | call('GET', '/media/' + mediaId + '/likes', params, requestOptions, requestHandler(deferred)); 334 | 335 | return deferred.promise; 336 | }; 337 | 338 | function postMediaLike(mediaId, requestOptions) { 339 | var deferred = q.defer(); 340 | var params = {}; 341 | 342 | call('POST', '/media/' + mediaId + '/likes', params, requestOptions, requestHandler(deferred)); 343 | 344 | return deferred.promise; 345 | }; 346 | 347 | function removeMediaLike(mediaId, requestOptions) { 348 | var deferred = q.defer(); 349 | var params = {}; 350 | 351 | call('DELETE', '/media/' + mediaId + '/likes', params, requestOptions, requestHandler(deferred)); 352 | 353 | return deferred.promise; 354 | }; 355 | 356 | function getTag(tagName, requestOptions) { 357 | var deferred = q.defer(); 358 | var params = {}; 359 | 360 | call('GET', '/tags/' + tagName, params, requestOptions, requestHandler(deferred)); 361 | 362 | return deferred.promise; 363 | }; 364 | 365 | function getMediasByTag(tagName, options, requestOptions) { 366 | var deferred = q.defer(); 367 | var params = { 368 | count: 50 369 | }; 370 | 371 | if(options && options.count){ 372 | params.count = options.count; 373 | } 374 | 375 | if(options && options.min_tag_id){ 376 | params.min_tag_id = options.min_tag_id; 377 | } 378 | 379 | if(options && options.max_tag_id){ 380 | params.max_tag_id = options.max_tag_id; 381 | } 382 | 383 | call('GET', '/tags/' + tagName + '/media/recent', params, requestOptions, requestHandler(deferred)); 384 | 385 | return deferred.promise; 386 | }; 387 | 388 | function searchTags(tagName, requestOptions) { 389 | var deferred = q.defer(); 390 | var params = { 391 | q: tagName 392 | }; 393 | 394 | call('GET', '/tags/search', params, requestOptions, requestHandler(deferred)); 395 | 396 | return deferred.promise; 397 | }; 398 | 399 | function getLocation(locationId, requestOptions) { 400 | var deferred = q.defer(); 401 | var params = {}; 402 | 403 | call('GET', '/locations/' + locationId, params, requestOptions, requestHandler(deferred)); 404 | 405 | return deferred.promise; 406 | }; 407 | 408 | function getMediasByLocation(locationId, options, requestOptions) { 409 | var deferred = q.defer(); 410 | 411 | var params = {}; 412 | 413 | if(options && options.min_id){ 414 | params.min_id = options.min_id; 415 | } 416 | 417 | if(options && options.max_id){ 418 | params.max_id = options.max_id; 419 | } 420 | 421 | call('GET', '/locations/' + locationId + '/media/recent', params, requestOptions, requestHandler(deferred)); 422 | 423 | return deferred.promise; 424 | }; 425 | 426 | function searchLocations(options, requestOptions) { 427 | var deferred = q.defer(); 428 | var params = {}; 429 | 430 | if(options && options.lat){ 431 | params.lat = options.lat; 432 | } 433 | 434 | if(options && options.lng){ 435 | params.lng = options.lng; 436 | } 437 | 438 | if(options && options.distance){ 439 | params.distance = options.distance; 440 | } 441 | 442 | if(options && options.facebook_places_id){ 443 | params.facebook_places_id = options.facebook_places_id; 444 | } 445 | 446 | call('GET', '/locations/search', params, requestOptions, requestHandler(deferred)); 447 | 448 | return deferred.promise; 449 | }; 450 | 451 | return { 452 | userSelf: userSelf, 453 | user: user, 454 | userSelfMedia: userSelfMedia, 455 | userMedia: userMedia, 456 | userSelfMediaLiked: userSelfMediaLiked, 457 | userSearch: userSearch, 458 | userSelfFollows: userSelfFollows, 459 | userSelfFollowedBy: userSelfFollowedBy, 460 | userSelfRequestedBy: userSelfRequestedBy, 461 | userRelationship: userRelationship, 462 | setUserRelationship: setUserRelationship, 463 | media: media, 464 | mediaByShortcode: mediaByShortcode, 465 | mediaSearch: mediaSearch, 466 | mediaComments: mediaComments, 467 | postMediaComment: postMediaComment, 468 | removeMediaComment: removeMediaComment, 469 | mediaLikes: mediaLikes, 470 | postMediaLike: postMediaLike, 471 | removeMediaLike: removeMediaLike, 472 | getTag: getTag, 473 | getMediasByTag: getMediasByTag, 474 | searchTags: searchTags, 475 | getLocation: getLocation, 476 | getMediasByLocation: getMediasByLocation, 477 | searchLocations: searchLocations 478 | }; 479 | }; 480 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "instagram-api", 3 | "description": "New Instagram API 2016 for Node.js", 4 | "version": "1.0.3", 5 | "homepage": "https://github.com/guilhermefarias/instagram-api", 6 | "author": "Guilherme Farias (https://github.com/guilhermefarias)", 7 | "repository": { 8 | "type": "git", 9 | "url": "git+https://github.com/guilhermefarias/instagram-api.git" 10 | }, 11 | "bugs": { 12 | "url": "https://github.com/guilhermefarias/instagram-api/issues" 13 | }, 14 | "main": "./lib/instagram", 15 | "engines": { 16 | "node": ">=v0.6.0" 17 | }, 18 | "keywords": [ 19 | "instagram", 20 | "instagram api 2016", 21 | "wrapper" 22 | ], 23 | "license": "MIT", 24 | "dependencies": { 25 | "q": "^1.4.1" 26 | } 27 | } 28 | --------------------------------------------------------------------------------