instagram 1.0.0-beta+1 copy "instagram: ^1.0.0-beta+1" to clipboard
instagram: ^1.0.0-beta+1 copied to clipboard

outdated

Dart Instagram client library.

instagram #

Pub

Dart Instagram client library. This library includes support for authentication, as well as all of the Instagram API v1 endpoints.

The API is entirely documented, for convenience. 👍

Users of Angel can use package:angel_auth_instagram to authenticate users with Instagram.

Coming soon: Subscriptions

Authentication #

Via Access Token #

If you already have an access token, you can authenticate a client.

Note: The user property of the InstagramClient will be null.

var client = InstagramApiAuth.authorizeViaAccessToken('<access-token>');
var me = await client.users.self.get();

InstagramApiAuth #

To perform authentication, use the InstagramApiAuth class. All API scopes are included as InstagramApiScope constants for convenience.

var auth = new InstagramApiAuth('<client-id>', '<client-secret>',
  redirectUri: Uri.parse('<redirect-uri>'),
  scopes: [
    InstagramApiScope.basic,
    InstagramApiScope.publicContent,
    // ...
  ]
);

Implicit Auth #

Applications with no server-side component can implement implicit auth.

To get a redirect URI:

var redirectUri = auth.getImplicitRedirectUri();
window.location.href = redirectUri.toString();

Explicit Auth #

This library also supports traditional OAuth2 authentication.

To obtain a redirect URI:

var redirectUri = auth.getRedirectUri();
var redirectUri = auth.getRedirectUri(state: 'foo.bar=baz');
res.redirect(redirectUri.toString());

After you have obtained an authorization code, you can exchange it for an access token, and receive an InstagramClient.

This example is an Angel handler:

app.get('/auth/instagram/callback', (RequestContext req, InstagramApiAuth instaAuth) async {
  var client = await instaAuth.handleAuthorizationCode(req.query['code'], new http.Client());
  var me = await client.users.self.get();
  
  // Do something with the authenticated user...
});

Endpoints #

The InstagramClient contains several getters that correspond to endpoints. Each is an abstraction over a specific Instagram API.

Here is an example with the relationships API:

Future<bool> userFollowsMe(String userId, InstagramClient instagram) async {
  var relationship = await instagram.relationships.toUser(userId).get();
  return relationship.incomingStatus == IncomingStatus.followedBy;
}

Constants #

This API includes several classes containing helpful constants:

  • InstagramApiScope
  • IncomingStatus
  • OutgoingStatus
  • RelationshipAction
7
likes
0
pub points
8%
popularity

Publisher

unverified uploader

Dart Instagram client library.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

oauth2, owl

More

Packages that depend on instagram