instagram 1.0.0

  • README.md
  • Installing
  • Versions
  • 17

instagram

Pub

NOTE: The old Instagram API is now deprecated; this package will now focus on the Instagram Graph API.

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...
});

You can also manage subscriptions:

main() {
  var subscriptions = instaAuth.createSubscriptionManager(new http.Client());
}

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
  • MediaType
  • SubscriptionObject
  • SubscriptionAspect

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  instagram: ^1.0.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:instagram/instagram.dart';
  
Version Uploaded Documentation Archive
1.0.0 Jul 11, 2018 Go to the documentation of instagram 1.0.0 Download instagram 1.0.0 archive
1.0.0-rc.1 Jul 23, 2017 Go to the documentation of instagram 1.0.0-rc.1 Download instagram 1.0.0-rc.1 archive
1.0.0-beta+3 Jul 20, 2017 Go to the documentation of instagram 1.0.0-beta+3 Download instagram 1.0.0-beta+3 archive
1.0.0-beta+2 Jul 18, 2017 Go to the documentation of instagram 1.0.0-beta+2 Download instagram 1.0.0-beta+2 archive
1.0.0-beta+1 Jul 18, 2017 Go to the documentation of instagram 1.0.0-beta+1 Download instagram 1.0.0-beta+1 archive
1.0.0-beta Jul 18, 2017 Go to the documentation of instagram 1.0.0-beta Download instagram 1.0.0-beta archive
Popularity:
Describes how popular the package is relative to other packages. [more]
33
Health:
Code health derived from static analysis. [more]
0
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
0
Overall:
Weighted score of the above. [more]
17
Learn more about scoring.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Analysis issues and suggestions

Fix dependencies in pubspec.yaml.

Running pub upgrade failed with the following output:

ERR: The current Dart SDK version is 2.0.0.
 
 Because owl >=0.1.1 <0.2.3 requires SDK version >=1.20.0 <2.0.0 and owl >=0.2.3 <0.4.0 depends on postgresql ^0.3.4, owl >=0.1.1 <0.4.0 requires postgresql ^0.3.4.
 So, because postgresql >=0.2.1 requires SDK version <2.0.0 and instagram depends on owl ^0.2.1, version solving failed.

Health suggestions

Format lib/instagram.dart.

Run dartfmt to format lib/instagram.dart.

Format lib/src/api/api.dart.

Run dartfmt to format lib/src/api/api.dart.

Format lib/src/api/comment.dart.

Run dartfmt to format lib/src/api/comment.dart.

Fix additional 8 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/src/api/instagram.dart (Run dartfmt to format lib/src/api/instagram.dart.)
  • lib/src/api/like.dart (Run dartfmt to format lib/src/api/like.dart.)
  • lib/src/api/media.dart (Run dartfmt to format lib/src/api/media.dart.)
  • lib/src/api/relationships.dart (Run dartfmt to format lib/src/api/relationships.dart.)
  • lib/src/api/subscription.dart (Run dartfmt to format lib/src/api/subscription.dart.)
  • lib/src/endpoints.dart (Run dartfmt to format lib/src/endpoints.dart.)
  • lib/src/models/models.dart (Run dartfmt to format lib/src/models/models.dart.)
  • lib/src/requestor.dart (Run dartfmt to format lib/src/requestor.dart.)

Maintenance issues and suggestions

Fix platform conflicts. (-20 points)

Error(s) prevent platform classification:

Fix dependencies in pubspec.yaml.

Maintain CHANGELOG.md. (-20 points)

Changelog entries help clients to follow the progress in your code.

The description is too short. (-20 points)

Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use instagram.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.19.0 <3.0.0