Skip to content

Rust wrapper around the Instagram Basic Display API to gather metadata and media files

License

Notifications You must be signed in to change notification settings

lem0nez/instapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

InstAPI

Provides abstractions over the Instagram Basic Display API to retrieve tokens and gather user's profile information and media.

Example usage

use instapi::{auth, user};

let secrets = auth::Secrets {
    app_id: /* Instagram app ID */,
    app_secret: /* Instagram app secret */,
    oauth_uri: /* OAuth redirect URI */,
};

// Forward the user to the authorization page and interactively request a code.
let code = auth::request_code(&secrets)?;
// Exchange the authorization code for a short-lived token.
let token = auth::ShortLivedToken::new(&secrets, code.as_str())?;

// Link the token with profile.
let profile = user::Profile::new(token);
// Retrieve the user profile information and print username.
println!("Username: {}", profile.info()?.username());

Modules description

  • The auth module implements authorization related stuff: secrets and tokens. The Secrets structure used to store private information of your Instagram application. Tokens can be of two types: short-lived and long-lived. The first one is only available for 1 hour after retrieving and can't be refreshed. A long-lived token is produced by exchanging a short-lived token and it available for 60 days (or 90 days for private accounts) after retrieving.

  • The user module provides methods to retrieve user's profile information and media, including albums content. Each profile is linked to a token.

Instafetcher

An example utility that provides command-line interface for the library.

To build this tool you need to set INSTAGRAM_APP_ID, INSTAGRAM_APP_SECRET and INSTAGRAM_OAUTH_URI environment variable with the corresponding values. To perform authorization use --log-in option, that will store a long-lived token in the system's configuration directory. After that you can use the following main options:

  • --info. Retrieve and display the basic profile information.
  • --media. Download all media files to the given directory. File names have the following format: <owner's username>_<media ID>_<publish date>. For each album will be created a subdirectory. To exclude albums use --no-albums option.

About

Rust wrapper around the Instagram Basic Display API to gather metadata and media files

Topics

Resources

License

Stars

Watchers

Forks

Languages