Elixtagram
Provides access to the Instagram API.
Summary
Functions
Returns the url you will need to redirect a user to for them to authorise your app with their Instagram account. When they log in there, you will need to implement a way to catch the code in the request url (they will be redirected back to your INSTAGRAM_REDIRECT_URI
)
Returns the url to redirect a user to when authorising your app to use their account. Takes a list of permissions scopes as atom
to request from Instagram
Returns the url to redirect a user to when authorising your app to use their account. Takes a list of permissions scopes as atom
to request from Instagram, as well as a 'state', this is an optional query param that will be passed back to your application's callback url
Initialises Elixtagram with system environment variables. For this to work, set INSTAGRAM_CLIENT_ID
, INSTAGRAM_CLIENT_SECRET
and INSTAGRAM_REDIRECT_URI
Sets a global user authentication token, this is useful for scenarios where your app will only ever make requests on behalf of one user at a time
Initialises and configures Elixtagram with a client_id
, client_secret
and redirect_uri
. If you're not doing anything particularly interesting here, it's better to set them as environment variables and use Elixtagram.configure/0
Takes a keyword list
containing the code returned from Instagram in the redirect after login and returns a %OAuth2.AccessToken
with an access token to store with the user or use for making authenticated requests
Takes a location id and returns a %Elixtagram.Model.Location
Takes a location id and an access token. Returns a %Elixtagram.Model.Location
Takes a location id and a Map of params. Returns a List of recent media (as %Elixtagram.Model.Media
)
Takes a location id a Map of params and an access token. Returns a List of recent media (as %Elixtagram.Model.Media
)
Takes a Map of search params. Returns a List of locations (as %Elixtagram.Model.Location
)
Takes a Map of search params and an access token. Returns a List of locations (as %Elixtagram.Model.Location
)
Takes a media id and returns a %Elixtagram.Model.Media
Takes a media id and an access token, returns a %Elixtagram.Model.Media
Note: To use this you must have access to the comments
scope, which is not by accessable without special permission [(more info)][request_scope].
Note: To use this you must have access to the comments
scope, which is not by accessable without special permission [(more info)][request_scope].
Takes a media id and returns a List of comments as %Elixtagram.Model.Comment
Takes a media id and a token (or :global
if it's been configured). Returns a List of comments as %Elixtagram.Model.Comment
Note: To use this you must have access to the likes
scope, which is not by accessable without special permission [(more info)][request_like_scope].
Takes a media id and returns a List of users who liked the media as %Elixtagram.Model.UserSearchResult
Takes a media id and an access token (or :global
, if configured). Returns a List of users who liked the media as %Elixtagram.Model.UserSearchResult
Takes a number of items to get, returns a List of n popular media items (as %Elixtagram.Model.Media
)
Takes a number of items to get and an access token. Returns a List of n popular media items (as %Elixtagram.Model.Media
)
Searches for media based on the location params Map provided, returns a list of media (as %Elixtagram.Model.Media
)
Searches for media based on the location params Map provided, returns a list of media (as %Elixtagram.Model.Media
). Takes a Map of location params and an access token
Takes a media shortcode and returns a %Elixtagram.Model.Media
Takes a media shortcode and an access token, returns a %Elixtagram.Model.Media
Note: To use this you must have access to the likes
scope, which is not by accessable without special permission [(more info)][request_like_scope].
Takes a tag name and an optional access token, returns a %Elixtagram.Model.Tag
Same as Elixtagram.tag/1
, except takes an explicit access token
Takes a tag name, and a Map of params Returns the n latest items in that tag
Takes a tag name, a Map of params and an access token Returns the n latest items in that tag
Takes a query string and returns a list of tags as %Elixtagram.Model.Tag
Takes a query string and an access token, returns a list of tags
Takes a user id and returns a %Elixtagram.Model.User
Takes a user id or :self
and an access token (or :global
, if a global access token has been set with Elixtagram.configure(:global, token)
) and returns a %Elixtagram.Model.User
Takes a Map of params and a token (or :global
if a global token has been configured). Returns a List of media as %Elixtagram.Model.Media
Takes a user id, returns a List of the user's followers as %Elixtagram.Model.UserSearchResult
Takes a user id and an access token (or :global
, if configured). Returns a List of the user's followers as %Elixtagram.Model.UserSearchResult
Takes a user id, count and returns a List of users they follow as %Elixtagram.Model.UserSearchResult
Takes a user id, count and an access token (or :global
, if configured). Returns a List of users they follow as %Elixtagram.Model.UserSearchResult
Takes a Map of params and a token (or ':global' if a global token has been configured). Returns a List of media as %Elixtagram.Model.Media
Takes a user id and a params Map, returns a List of media as %Elixtagram.Model.Media
Takes a user id (or :self
, to get media for the user associated with the token) a params Map and access token (or :global
if a global token has been configured). Returns a List of media as %Elixtagram.Model.Media
Takes a user id and an access token, returns the relationship of that user in relation to the current user as a %Elixtagram.Model.Relationship
Note: To use this you must have access to the relationships
scope, which is not by accessable without special permission [(more info)][request_scope].
Takes an access token and returns a List of users who have requested to follow the user (but haven't yet been accepted) as %Elixtagram.Model.UserSearchResult
Search for users by username. Takes a Map of search params: q
(query) and optionally, count
. Returns a List of users as %Elixtagram.Model.UserSearchResult
Search for users by username. Takes a Map of search params (q
(query) and optionally, count
) and an access token (or :global if set)
Functions
Returns the url you will need to redirect a user to for them to authorise your app with their Instagram account. When they log in there, you will need to implement a way to catch the code in the request url (they will be redirected back to your INSTAGRAM_REDIRECT_URI
).
Note: This method authorises only 'basic' scoped permissions (more on this).
Example
iex(8)> Elixtagram.authorize_url!
"https://api.instagram.com/oauth/authorize/?client_id=XXX&redirect_uri=localhost%3A4000&response_type=code"
Returns the url to redirect a user to when authorising your app to use their account. Takes a list of permissions scopes as atom
to request from Instagram.
Available options: :comments
, :relationships
and :likes
Example
iex(1)> Elixtagram.authorize_url!([:comments, :relationships])
"https://api.instagram.com/oauth/authorize/?client_id=XXX&redirect_uri=localhost%3A4000&response_type=code&scope=comments+relationships"
Returns the url to redirect a user to when authorising your app to use their account. Takes a list of permissions scopes as atom
to request from Instagram, as well as a 'state', this is an optional query param that will be passed back to your application's callback url.
Available scopes: :comments
, :relationships
and :likes
Example
iex(1)> Elixtagram.authorize_url!([:comments, :relationships], "somevalue")
"https://api.instagram.com/oauth/authorize/?client_id=XXX&redirect_uri=localhost%3A4000&response_type=code&scope=comments+relationships&state=somevalue"
Initialises Elixtagram with system environment variables. For this to work, set INSTAGRAM_CLIENT_ID
, INSTAGRAM_CLIENT_SECRET
and INSTAGRAM_REDIRECT_URI
.
Example
INSTAGRAM_CLIENT_ID=XXXX INSTAGRAM_CLIENT_SECRET=XXXX INSTAGRAM_REDIRECT_URI=localhost iex
iex(1)> Elixtagram.configure
{:ok, []}
Sets a global user authentication token, this is useful for scenarios where your app will only ever make requests on behalf of one user at a time.
Example
iex(1)> Elixtagram.configure(:global, "MY-TOKEN")
:ok
Initialises and configures Elixtagram with a client_id
, client_secret
and redirect_uri
. If you're not doing anything particularly interesting here, it's better to set them as environment variables and use Elixtagram.configure/0
Example
iex(1)> Elixtagram.configure("XXXX", "XXXX", "localhost:4000")
{:ok, []}
Takes a keyword list
containing the code returned from Instagram in the redirect after login and returns a %OAuth2.AccessToken
with an access token to store with the user or use for making authenticated requests.
Example
iex(1)> Elixtagram.get_token!(code: code).access_token
"XXXXXXXXXXXXXXXXXXXX"
Takes a location id and returns a %Elixtagram.Model.Location
Example
iex(1)> Elixtagram.location(1)
%Elixtagram.Model.Location{id: "1", latitude: 37.782492553,
longitude: -122.387785235, name: "Dog Patch Labs"}
Takes a location id and an access token. Returns a %Elixtagram.Model.Location
Example
iex(1)> Elixtagram.location(1, token)
%Elixtagram.Model.Location{id: "1", latitude: 37.782492553,
longitude: -122.387785235, name: "Dog Patch Labs"}
Takes a location id and a Map of params. Returns a List of recent media (as %Elixtagram.Model.Media
)
Search params: * count * min_timestamp * max_timestamp * min_id * max_id
Example
iex(1)> Elixtagram.location_recent_media(1, %{count: 1})
[%Elixtagram.Model.Media{..}]
Takes a location id a Map of params and an access token. Returns a List of recent media (as %Elixtagram.Model.Media
)
Search params:
- count
- min_timestamp
- max_timestamp
- min_id
- max_id
Example
iex(1)> Elixtagram.location_recent_media(1, %{count: 1})
[%Elixtagram.Model.Media{..}]
Takes a Map of search params. Returns a List of locations (as %Elixtagram.Model.Location
)
Search params: * distance (in meters, defaults to 1000) * count * lat and lng (must be used together) * facebook_places_id * foursquare_v2_id * foursquare_id (For IDs from Foursquare's (deprecated) v1 API)
Examples
iex(1)> Elixtagram.location_search(%{lat: "52.5167", lng: "13.3833", count: 3})
[%Elixtagram.Model.Location{id: "1014581914", latitude: 52.516667,
longitude: 13.383333, name: "Alemanha"},
%Elixtagram.Model.Location{id: "1003437077", latitude: 52.516667,
longitude: 13.383333, name: "Njemačka"},
%Elixtagram.Model.Location{id: "1014197989", latitude: 52.516667,
longitude: 13.383333, name: "Γερμανία"}]
iex(2)> Elixtagram.location_search(%{facebook_places_id: 1})
[%Elixtagram.Model.Location{id: "343525978", latitude: 57.9913,
longitude: 56.1355, name: "my home"}]
iex(3)> Elixtagram.location_search(%{foursquare_v2_id: "4c941c0f03413704fb386fef"})
[%Elixtagram.Model.Location{id: "14095316", latitude: 52.5110893,
longitude: 13.4413996, name: "lab.oratory"}]
Takes a Map of search params and an access token. Returns a List of locations (as %Elixtagram.Model.Location
)
Search params:
- distance (in meters, defaults to 1000)
- count
- lat and lng (must be used together)
- facebook_places_id
- foursquare_v2_id
- foursquare_id (For IDs from Foursquare's (deprecated) v1 API)
Examples
iex(1)> Elixtagram.location_search(%{lat: "52.5167", lng: "13.3833", count: 3}, token)
[%Elixtagram.Model.Location{id: "1014581914", latitude: 52.516667,
longitude: 13.383333, name: "Alemanha"},
%Elixtagram.Model.Location{id: "1003437077", latitude: 52.516667,
longitude: 13.383333, name: "Njemačka"},
%Elixtagram.Model.Location{id: "1014197989", latitude: 52.516667,
longitude: 13.383333, name: "Γερμανία"}]
iex(2)> Elixtagram.location_search(%{facebook_places_id: 1}, token)
[%Elixtagram.Model.Location{id: "343525978", latitude: 57.9913,
longitude: 56.1355, name: "my home"}]
iex(3)> Elixtagram.location_search(%{foursquare_v2_id: "4c941c0f03413704fb386fef"}, token)
[%Elixtagram.Model.Location{id: "14095316", latitude: 52.5110893,
longitude: 13.4413996, name: "lab.oratory"}]
Takes a media id and returns a %Elixtagram.Model.Media
Example
iex(1)> Elixtagram.media("XXXXXXXXXXXXXXXXXXXX")
%Elixtagram.Model.Media{...}
Takes a media id and an access token, returns a %Elixtagram.Model.Media
Example
iex(1)> Elixtagram.media("XXXXXXXXXXXXXXXXXXXX", token)
%Elixtagram.Model.Media{...}
Note: To use this you must have access to the comments
scope, which is not by accessable without special permission (more info).
Takes a media id, a comment string and an access token (or :global
, if configured). Returns :ok if everything went as expected, throws an error if you don't have the right scope
Example
iex(1)> Elixtagram.media_comment("XXXXXXXX", "Nice pic m8", :global)
:ok
iex(1)> Elixtagram.media_comment("XXXXXXXX", "Nice pic m8", :global)
** (Elixtagram.Error) OAuthPermissionsException: This request requires scope=comments, but this access token is not authorized with this scope. The user must re-authorize your application with scope=comments to be granted write permissions.
Note: To use this you must have access to the comments
scope, which is not by accessable without special permission (more info).
Takes a media id, comment id and an access token (or :global
, if configured). Returns :ok if everything went as expected, throws an error if you don't have the right scope
Example
iex(1)> Elixtagram.media_comment_delete("XXXXXXXX", "XXXXXXXXXX", :global)
:ok
iex(1)> Elixtagram.media_comment_delete("XXXXXXXX", "XXXXXXXXXX", :global)
** (Elixtagram.Error) OAuthPermissionsException: This request requires scope=comments, but this access token is not authorized with this scope. The user must re-authorize your application with scope=comments to be granted write permissions.
Takes a media id and returns a List of comments as %Elixtagram.Model.Comment
Example
iex(1)> Elixtagram.media_comments("XXXXXXXXXXXXXXXXX")
[%Elixtagram.Model.Comment{created_time: "1442120355",
from: %{full_name: "- D J M Λ K K -", id: "904376079",
profile_picture: "https://scontent.cdninstagram.com/hphotos-xpf1/t51.2885-19/s150x150/10549742_1640334582890085_1510069009_a.jpg",
username: "anthonymarcarella"}, id: "1072905761030153596",
text: "Wow! Like your image!"},
%Elixtagram.Model.Comment{created_time: "1442133337", from: %{full_name: "Richard Stow", id: "20859481", profile_picture: "https://scontent.cdninstagram.com/hphotos-xaf1/t51.2885-19/11899636_1614219182185630_61225165_a.jpg", username: "richardstow"}, id: "1073014667609908273", text: "📷"}, %Elixtagram.Model.Comment{created_time: "1442164089", from: %{full_name: "", id: "2032306568", profile_picture: "https://scontent.cdninstagram.com/hphotos-xfa1/t51.2885-19/s150x150/11356724_884715214954714_781335523_a.jpg", username: "chloeg_creation_de_gateau"}, id: "1073272627716170835", text: "Follow me please ☺️"}, %Elixtagram.Model.Comment{created_time: "1442404459", from: %{full_name: "Carolyn", id: "230289717", profile_picture: "https://igcdn-photos-b-a.akamaihd.net/hphotos-ak-xpa1/t51.2885-19/10691678_628145513973889_94786555_a.jpg", username: "ilivegreen"}, id: "1075289004710831627", text: "@stephanie_hair this reminded me of Forrest 😘"}, %Elixtagram.Model.Comment{created_time: "1442462968", from: %{full_name: "Rafael A. Nieves 🌉🌌", id: "479491821", profile_picture: "https://scontent.cdninstagram.com/hphotos-xaf1/t51.2885-19/s150x150/11910388_129390307408288_53320144_a.jpg", username: "rafael_nieves"}, id: "1075779805656130920", text: "😆"}]
Takes a media id and a token (or :global
if it's been configured). Returns a List of comments as %Elixtagram.Model.Comment
Example
iex(1)> Elixtagram.media_comments("XXXXXXXXXXXXXXXXX", :global)
[%Elixtagram.Model.Comment{created_time: "1442120355",
from: %{full_name: "- D J M Λ K K -", id: "904376079",
profile_picture: "https://scontent.cdninstagram.com/hphotos-xpf1/t51.2885-19/s150x150/10549742_1640334582890085_1510069009_a.jpg",
username: "anthonymarcarella"}, id: "1072905761030153596",
text: "Wow! Like your image!"},
%Elixtagram.Model.Comment{created_time: "1442133337", from: %{full_name: "Richard Stow", id: "20859481", profile_picture: "https://scontent.cdninstagram.com/hphotos-xaf1/t51.2885-19/11899636_1614219182185630_61225165_a.jpg", username: "richardstow"}, id: "1073014667609908273", text: "📷"}, %Elixtagram.Model.Comment{created_time: "1442164089", from: %{full_name: "", id: "2032306568", profile_picture: "https://scontent.cdninstagram.com/hphotos-xfa1/t51.2885-19/s150x150/11356724_884715214954714_781335523_a.jpg", username: "chloeg_creation_de_gateau"}, id: "1073272627716170835", text: "Follow me please ☺️"}, %Elixtagram.Model.Comment{created_time: "1442404459", from: %{full_name: "Carolyn", id: "230289717", profile_picture: "https://igcdn-photos-b-a.akamaihd.net/hphotos-ak-xpa1/t51.2885-19/10691678_628145513973889_94786555_a.jpg", username: "ilivegreen"}, id: "1075289004710831627", text: "@stephanie_hair this reminded me of Forrest 😘"}, %Elixtagram.Model.Comment{created_time: "1442462968", from: %{full_name: "Rafael A. Nieves 🌉🌌", id: "479491821", profile_picture: "https://scontent.cdninstagram.com/hphotos-xaf1/t51.2885-19/s150x150/11910388_129390307408288_53320144_a.jpg", username: "rafael_nieves"}, id: "1075779805656130920", text: "😆"}]
Note: To use this you must have access to the likes
scope, which is not by accessable without special permission (more info).
Takes a media id and an access token (or :global
, if configured). Returns :ok if everything went as expected, throws an error if you don't have the right scope
Example
iex(1)> Elixtagram.media_like("XXXXXXXX", :global)
:ok
iex(1)> Elixtagram.media_like("XXXXXXXX", :global)
** (Elixtagram.Error) OAuthPermissionsException: This request requires scope=likes, but this access token is not authorized with this scope. The user must re-authorize your application with scope=likes to be granted write permissions.
Takes a media id and returns a List of users who liked the media as %Elixtagram.Model.UserSearchResult
Example
iex(1)> Elixtagram.media_likes("1075894327634310197_2183820012")
Takes a media id and an access token (or :global
, if configured). Returns a List of users who liked the media as %Elixtagram.Model.UserSearchResult
Example
iex(1)> Elixtagram.media_likes("1075894327634310197_2183820012", token)
Takes a number of items to get, returns a List of n popular media items (as %Elixtagram.Model.Media
).
Example
iex(1)> Elixtagram.media_popular(1)
[%Elixtagram.Model.Media{...}]
Takes a number of items to get and an access token. Returns a List of n popular media items (as %Elixtagram.Model.Media
).
Example
iex(1)> Elixtagram.media_popular(1, token)
[%Elixtagram.Model.Media{...}]
Searches for media based on the location params Map provided, returns a list of media (as %Elixtagram.Model.Media
)
Search params:
- count
- lat and lng (must be supplied)
- distance (in meters, defaults to 1000)
- min_timestamp
- max_timestamp
Examples
iex(1)> Elixtagram.media_search(%{lat: 1, lng: 2, count: 1})
[%Elixtagram.Model.Media{...}]
Searches for media based on the location params Map provided, returns a list of media (as %Elixtagram.Model.Media
). Takes a Map of location params and an access token.
Search params:
- count
- lat and lng (must be supplied)
- distance (in meters, defaults to 1000)
- min_timestamp
- max_timestamp
Examples
iex(1)> Elixtagram.media_search(%{lat: 1, lng: 2, count: 1}, token)
[%Elixtagram.Model.Media{...}]
Takes a media shortcode and returns a %Elixtagram.Model.Media
Example
iex(1)> Elixtagram.media("D")
%Elixtagram.Model.Media{...}
Takes a media shortcode and an access token, returns a %Elixtagram.Model.Media
Example
iex(1)> Elixtagram.media("D", token)
%Elixtagram.Model.Media{...}
Note: To use this you must have access to the likes
scope, which is not by accessable without special permission (more info).
Takes a media id and an access token (or :global
, if configured). Returns :ok if everything went as expected, throws an error if you don't have the right scope
Example
iex(1)> Elixtagram.media_unlike("XXXXXXXX", :global)
:ok
iex(1)> Elixtagram.media_unlike("XXXXXXXX", :global)
** (Elixtagram.Error) OAuthPermissionsException: This request requires scope=likes, but this access token is not authorized with this scope. The user must re-authorize your application with scope=likes to be granted write permissions.
Takes a tag name and an optional access token, returns a %Elixtagram.Model.Tag
.
If a global access token was set with Elixtagram.configure(:global, token)
, this will be defaulted to, otherwise the client ID is used.
Example
iex(1)> Elixtagram.tag("lifeisaboutdrugs")
%Elixtagram.Model.Tag{media_count: 27, name: "lifeisaboutdrugs"}
Same as Elixtagram.tag/1
, except takes an explicit access token.
The only real benefit to using an access token over a client id here is less rate limiting (in general and per token).
Example
iex(1)> Elixtagram.tag("lifeisaboutdrugs", "XXXXXXXXXXXXXXXXX")
%Elixtagram.Model.Tag{media_count: 27, name: "lifeisaboutdrugs"}
Takes a tag name, and a Map of params Returns the n latest items in that tag
Search params: * count * min_tag_id * max_tag_id
If a global access token was set with Elixtagram.configure(:global, token)
, this will be defaulted to, otherwise the client ID is used.
Example
iex(1)> Elixtagram.tag_recent_media("ts", %{count: 1})
[%Elixtagram.Model.Media{...}]
Takes a tag name, a Map of params and an access token Returns the n latest items in that tag
Search params: * count * min_tag_id * max_tag_id
If a global access token was set with Elixtagram.configure(:global, token)
, this will be defaulted to, otherwise the client ID is used.
Example
iex(1)> Elixtagram.tag_recent_media("ts", %{count: 1}, token)
[%Elixtagram.Model.Media{...}]
Takes a query string and returns a list of tags as %Elixtagram.Model.Tag
.
If a global access token was set with Elixtagram.configure(:global, token)
, this will be defaulted to, otherwise the client ID is used.
Example
iex(1)> Elixtagram.tag_search("mdmazing")
[%Elixtagram.Model.Tag{media_count: 8826.0, name: "mdmazing"},
%Elixtagram.Model.Tag{media_count: 22.0, name: "mdmazingnight"},
%Elixtagram.Model.Tag{media_count: 4.0, name: "mdmazingtime"},
%Elixtagram.Model.Tag{media_count: 3.0, name: "mdmazingjourney"},
%Elixtagram.Model.Tag{media_count: 3.0, name: "mdmazingweekend"},
%Elixtagram.Model.Tag{media_count: 3.0, name: "mdmazinglife"},
%Elixtagram.Model.Tag{media_count: 3.0, name: "mdmazinggggg"},
%Elixtagram.Model.Tag{media_count: 1.0, name: "mdmazing💋💊🎉🍸"},
%Elixtagram.Model.Tag{media_count: 1.0, name: "mdmazinglights"},
%Elixtagram.Model.Tag{media_count: 1.0, name: "mdmazing😈👽👀"}]
Takes a query string and an access token, returns a list of tags
The only real benefit to using an access token over a client id here is less rate limiting (in general and per token).
Example
iex(1)> Elixtagram.tag_search("munted", "XXXXXXXXXXXXXXXXX")
[%Elixtagram.Model.Tag{media_count: 20681.0, name: "munted"},
%Elixtagram.Model.Tag{media_count: 267.0, name: "muntedasfuck"},
%Elixtagram.Model.Tag{media_count: 267.0, name: "muntedheads"},
%Elixtagram.Model.Tag{media_count: 202.0, name: "muntedas"},
%Elixtagram.Model.Tag{media_count: 188.0, name: "muntedshakas"},
%Elixtagram.Model.Tag{media_count: 161.0, name: "muntedmondays"},
%Elixtagram.Model.Tag{media_count: 109.0, name: "muntedselfie"},
%Elixtagram.Model.Tag{media_count: 94.0, name: "muntedeye"},
%Elixtagram.Model.Tag{media_count: 93.0, name: "muntedcunts"},
%Elixtagram.Model.Tag{media_count: 63.0, name: "muntedsmile"},
%Elixtagram.Model.Tag{media_count: 58.0, name: "muntedaf"},
%Elixtagram.Model.Tag{media_count: 57.0, name: "munteddd"}]
Takes a user id and returns a %Elixtagram.Model.User
.
Examples
iex(1)> Elixtagram.user(35822824)
%Elixtagram.Model.User{bio: "🌷 Whole Food Plant Based Nutrition
🏂 Powerful Functional Strength & Fitness 🌏 Digital Nomad 🐈 Animal Lover 😸Berlin♨️Chiang Mai🇦🇺Brisbane", counts: %{followed_by: 3966, follows: 4915, media: 613}, full_name: "Zen Savona", id: "35822824", profile_picture: "https://scontent.cdninstagram.com/hphotos-xaf1/t51.2885-19/s150x150/11856601_1483869585265582_942748740_a.jpg", username: "zenm8", website: "http://zen.id.au"}
Takes a user id or :self
and an access token (or :global
, if a global access token has been set with Elixtagram.configure(:global, token)
) and returns a %Elixtagram.Model.User
.
Examples
iex(1)> Elixtagram.user(35822824, token)
%Elixtagram.Model.User{bio: "🌷 Whole Food Plant Based Nutrition
🏂 Powerful Functional Strength & Fitness 🌏 Digital Nomad 🐈 Animal Lover 😸Berlin♨️Chiang Mai🇦🇺Brisbane", counts: %{followed_by: 3966, follows: 4915, media: 613}, full_name: "Zen Savona", id: "35822824", profile_picture: "https://scontent.cdninstagram.com/hphotos-xaf1/t51.2885-19/s150x150/11856601_1483869585265582_942748740_a.jpg", username: "zenm8", website: "http://zen.id.au"}
iex(2)> Elixtagram.user(:self, token)
%Elixtagram.Model.User{...}
iex(3)> Elixtagram.user(:self, :global)
%Elixtagram.Model.User{...}
Takes a Map of params and a token (or :global
if a global token has been configured). Returns a List of media as %Elixtagram.Model.Media
Search params:
- count
- min_id
- max_id
Examples
iex(1)> Elixtagram.user_feed(%{count: 2}, :global)
[%Elixtagram.Model.Media{...}, %Elixtagram.Model.Media{...}]
iex(2)> Elixtagram.user_feed(%{count: 2}, "XXXXXXXXXXXXXXXXX")
[%Elixtagram.Model.Media{...}, %Elixtagram.Model.Media{...}]
Takes a user id, returns a List of the user's followers as %Elixtagram.Model.UserSearchResult
Example
iex(1)> Elixtagram.user_followed_by("XXXXXXXXXX")
[%Elixtagram.Model.UserSearchResult{full_name: "Dariel 🙈", id: "1782884605",
profile_picture: "https://scontent.cdninstagram.com/hphotos-xfa1/t51.2885-19/s150x150/11296793_1507078476281099_1357579188_a.jpg", username: "dari600"},
%Elixtagram.Model.UserSearchResult{full_name: "Sal / Peri", id: "284767950",
profile_picture: "https://igcdn-photos-d-a.akamaihd.net/hphotos-ak-xaf1/t51.2885-19/s150x150/11349346_422441984620139_1778366224_a.jpg",
username: "peri.fu"}, ...]
Takes a user id and an access token (or :global
, if configured). Returns a List of the user's followers as %Elixtagram.Model.UserSearchResult
Example
iex(1)> Elixtagram.user_followed_by("XXXXXXXXXX", token)
[%Elixtagram.Model.UserSearchResult{full_name: "Dariel 🙈", id: "1782884605",
profile_picture: "https://scontent.cdninstagram.com/hphotos-xfa1/t51.2885-19/s150x150/11296793_1507078476281099_1357579188_a.jpg", username: "dari600"},
%Elixtagram.Model.UserSearchResult{full_name: "Sal / Peri", id: "284767950",
profile_picture: "https://igcdn-photos-d-a.akamaihd.net/hphotos-ak-xaf1/t51.2885-19/s150x150/11349346_422441984620139_1778366224_a.jpg",
username: "peri.fu"}, ...]
Takes a user id, count and returns a List of users they follow as %Elixtagram.Model.UserSearchResult
Example
iex(1)> Elixtagram.user_follows("XXXXXXXXXX", 10)
[%Elixtagram.Model.UserSearchResult{full_name: "Dariel 🙈", id: "1782884605",
profile_picture: "https://scontent.cdninstagram.com/hphotos-xfa1/t51.2885-19/s150x150/11296793_1507078476281099_1357579188_a.jpg", username: "dari600"},
%Elixtagram.Model.UserSearchResult{full_name: "Sal / Peri", id: "284767950",
profile_picture: "https://igcdn-photos-d-a.akamaihd.net/hphotos-ak-xaf1/t51.2885-19/s150x150/11349346_422441984620139_1778366224_a.jpg",
username: "peri.fu"}, ...]
For paginated results, pass a map with a count
and optional cursor
. This will return a map containing results
and next_cursor
.
Example
iex(1)> Elixtagram.user_follows("XXXXXXXXXX", %{count: 3})
%{next_cursor: "XXXXXXXXXX",
results: [%Elixtagram.Model.UserSearchResult{full_name: "meganmayble",
id: "176431650",
profile_picture: "https://igcdn-photos-e-a.akamaihd.net/hphotos-ak-xpa1/t51.2885-19/10522189_1425538584361516_1313020536_a.jpg",
username: "meganmayble"},
%Elixtagram.Model.UserSearchResult{full_name: "Dallas J Stone", id: "14325567", profile_picture: "https://scontent.cdninstagram.com/hphotos-xaf1/t51.2885-19/s150x150/12141839_453007948221534_1037878214_a.jpg", username: "dallasjstone"}, %Elixtagram.Model.UserSearchResult{full_name: "Emma Ferguson", id: "299647278", profile_picture: "https://scontent.cdninstagram.com/hphotos-xfa1/t51.2885-19/11324948_826531150776394_932627239_a.jpg", username: "emferge"}]}
iex(2)> Elixtagram.user_follows("XXXXXXXXXX", %{count: 3, cursor: "XXXXXXXXXX"})
%{next_cursor: "XXXXXXXXXX",
results: [%Elixtagram.Model.UserSearchResult{full_name: "violet arthi",
id: "1154780751",
profile_picture: "https://scontent.cdninstagram.com/hphotos-xaf1/t51.2885-19/s150x150/11849016_1481802675477332_336263373_a.jpg",
username: "prettyinpoc"},
%Elixtagram.Model.UserSearchResult{full_name: "gogogo", id: "1598470944", profile_picture: "https://scontent.cdninstagram.com/hphotos-xfa1/t51.2885-19/10785126_1005518456130807_438807926_a.jpg", username: "ugo.karle"}, %Elixtagram.Model.UserSearchResult{full_name: "Talia Smith", id: "1362121463", profile_picture: "https://scontent.cdninstagram.com/hphotos-xpa1/t51.2885-19/10948784_579906995477967_761832201_a.jpg", username: "teabird"}]}
Takes a user id, count and an access token (or :global
, if configured). Returns a List of users they follow as %Elixtagram.Model.UserSearchResult
Example
iex(1)> Elixtagram.user_follows("XXXXXXXXXX", 10, :global)
[%Elixtagram.Model.UserSearchResult{full_name: "Dariel 🙈", id: "1782884605",
profile_picture: "https://scontent.cdninstagram.com/hphotos-xfa1/t51.2885-19/s150x150/11296793_1507078476281099_1357579188_a.jpg", username: "dari600"},
%Elixtagram.Model.UserSearchResult{full_name: "Sal / Peri", id: "284767950",
profile_picture: "https://igcdn-photos-d-a.akamaihd.net/hphotos-ak-xaf1/t51.2885-19/s150x150/11349346_422441984620139_1778366224_a.jpg",
username: "peri.fu"}, ...]
Takes a Map of params and a token (or ':global' if a global token has been configured). Returns a List of media as %Elixtagram.Model.Media
Search params:
- count
- max_like_id
Examples
iex(1)> Elixtagram.user_media_liked(%{count: 2}, :global)
[%Elixtagram.Model.Media{...}, %Elixtagram.Model.Media{...}]
iex(2)> Elixtagram.user_media_liked(%{count: 2}, "XXXXXXXXXXXXXXXXX")
[%Elixtagram.Model.Media{...}, %Elixtagram.Model.Media{...}]
Takes a user id and a params Map, returns a List of media as %Elixtagram.Model.Media
Search params:
- count
- min_id
- max_id
- min_timestamp
- max_timestamp
Example
iex(1)> Elixtagram.user_recent_media(35822824, %{count: 2})
[%Elixtagram.Model.Media{...}, %Elixtagram.Model.Media{...}]
Takes a user id (or :self
, to get media for the user associated with the token) a params Map and access token (or :global
if a global token has been configured). Returns a List of media as %Elixtagram.Model.Media
.
Search params:
- count
- min_id
- max_id
- min_timestamp
- max_timestamp
Example
iex(1)> Elixtagram.user_recent_media(35822824, %{count: 2}, :global)
[%Elixtagram.Model.Media{...}, %Elixtagram.Model.Media{...}]
Takes a user id and an access token, returns the relationship of that user in relation to the current user as a %Elixtagram.Model.Relationship
.
Example
iex(1)> Elixtagram.user_relationship("XXXXXXXX", token)
%Elixtagram.Model.Relationship{incoming_status: "followed_by",
outgoing_status: "follows", target_user_is_private: false}
Note: To use this you must have access to the relationships
scope, which is not by accessable without special permission (more info).
Takes a user id, a valid action Atom and an access token, returns the updated status.
Valid actions:
- :follow
- :unfollow
- :block
- :unblock
- :approve
- :ignore
Examples
iex(1)> Elixtagram.user_relationship(user_id, :follow, token)
:requested
iex()> Elixtagram.user_relationship(user_id, :unfollow, token)
:ok
iex()> Elixtagram.user_relationship(user_id, :block, token)
:ok
iex()> Elixtagram.user_relationship(user_id, :unblock, token)
:ok
iex()> Elixtagram.user_relationship(user_id, :approve, token)
:follows
iex()> Elixtagram.user_relationship(user_id, :ignore, token)
:ok
Takes an access token and returns a List of users who have requested to follow the user (but haven't yet been accepted) as %Elixtagram.Model.UserSearchResult
Example
iex(1)> Elixtagram.user_requested_by(token)
[%Elixtagram.Model.UserSearchResult{full_name: "Dariel 🙈", id: "1782884605",
profile_picture: "https://scontent.cdninstagram.com/hphotos-xfa1/t51.2885-19/s150x150/11296793_1507078476281099_1357579188_a.jpg", username: "dari600"},
%Elixtagram.Model.UserSearchResult{full_name: "Sal / Peri", id: "284767950",
profile_picture: "https://igcdn-photos-d-a.akamaihd.net/hphotos-ak-xaf1/t51.2885-19/s150x150/11349346_422441984620139_1778366224_a.jpg",
username: "peri.fu"}, ...]
Search for users by username. Takes a Map of search params: q
(query) and optionally, count
. Returns a List of users as %Elixtagram.Model.UserSearchResult
.
Example
iex(1)> Elixtagram.user_search(%{q: "zen", count: 3})
[%Elixtagram.Model.UserSearchResult{full_name: "ZEN", id: "2075537710",
profile_picture:"https://scontent.cdninstagram.com/hphotos-xaf1/t51.2885-19/s150x150/11356890_150363411965324_1581305443_a.jpg", username: "zen_pk_official"},
%Elixtagram.Model.UserSearchResult{full_name: "ZEN", id: "1444000827",
profile_picture: "https://scontent.cdninstagram.com/hphotos-xap1/t51.2885-19/10732008_1658199007759427_555706599_a.jpg", username: "zen____zen"},
%Elixtagram.Model.UserSearchResult{full_name: "Zendaya", id: "215465313",
profile_picture: "https://scontent.cdninstagram.com/hphotos-xaf1/t51.2885-19/11356006_931176226929024_399091265_a.jpg", username: "zendaayamareexox"}]
Search for users by username. Takes a Map of search params (q
(query) and optionally, count
) and an access token (or :global if set).
Returns a List of users as %Elixtagram.Model.UserSearchResult
.
Example
iex(1)> Elixtagram.user_search(%{q: "zen", count: 3})
[%Elixtagram.Model.UserSearchResult{full_name: "ZEN", id: "2075537710",
profile_picture:"https://scontent.cdninstagram.com/hphotos-xaf1/t51.2885-19/s150x150/11356890_150363411965324_1581305443_a.jpg", username: "zen_pk_official"},
%Elixtagram.Model.UserSearchResult{full_name: "ZEN", id: "1444000827",
profile_picture: "https://scontent.cdninstagram.com/hphotos-xap1/t51.2885-19/10732008_1658199007759427_555706599_a.jpg", username: "zen____zen"},
%Elixtagram.Model.UserSearchResult{full_name: "Zendaya", id: "215465313",
profile_picture: "https://scontent.cdninstagram.com/hphotos-xaf1/t51.2885-19/11356006_931176226929024_399091265_a.jpg", username: "zendaayamareexox"}]