instagram 1.0.0

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';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
48
Health:
Code health derived from static analysis. [more]
--
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
--
Overall:
Weighted score of the above. [more]
24
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.6.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.

Make sure dartdoc successfully runs on your package's source files. (-10 points)

Dependencies were not resolved.

Provide a file named CHANGELOG.md. (-20 points)

Changelog entries help developers follow the progress of your package. See the example generated by stagehand.

Package is getting outdated. (-34.79 points)

The package was last published 70 weeks ago.

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and instagram.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

Dependencies

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