Objective-C client for the Altmetric API.
SZNAltmetric is an Altmetric API client for iOS and Mac OS X. It’s built on top of AFNetworking to deal with network operations, and based on NSURLSession
.
The easiest way to get started is to use CocoaPods to manage your dependencies. Follow the instructions on the CocoaPods site to install the gem, and specify SZNAltmetric as a dependency in your Podfile
:
pod 'SZNAltmetric', '~> 2.1'
We wanted to make it as simple as possible to fetch details about an article from the API, so here is how it looks like:
SZNAltmetricManager *manager = [SZNAltmetricManager sharedManager];
[manager
fetchArticleWithDOI:@"###DOI###"
success:^(SZNAltmetricArticle *article) {
// We have the article,
// we can log the Altmetric score
NSLog(@"%@", [article.score stringValue]);
}
failure:nil];
As you can see, we have just requested an article based on its DOI. What you get is a SZNAltmetricArticle
object, containing all the identifiers, the Altmetric score, and even the URLs to the “donuts” images.
Having a client API key is optional, and it’s easy to configure if you need it:
SZNAltmetricManager *manager = [SZNAltmetricManager sharedManager];
manager.APIKey = @"###key###";
With just a bit of user interface, here’s how it looks like on iOS and OS X:
You can also search articles with different types of identifiers (Altmetric ID, PubMed ID, arXiv ID, and ADS Bibcode), or with a timeframe:
SZNAltmetricManager *manager = [SZNAltmetricManager sharedManager];
[manager
fetchArticlesCitationsWithTimeframe:@"1d"
success:^(NSArray *articles, NSUInteger total, NSUInteger page) {
// We have an array of articles.
NSLog(@"%@", articles);
}
failure:nil];
SZNAltmetric requires Xcode 6.3 with either the iOS 7.0 or OS X 10.9, as well as AFNetworking and ISO 8601 parser unparser. Both SZNAltmetric and AFNetworking use ARC.
If you need to support older OS versions:
- SZNAltmetric 1.x supports iOS 5.0 and OS X 10.7
- SZNAltmetric 2.0 supports iOS 6.0 and OS X 10.8
SZNAltmetric is developed by Shazino.
SZNAltmetric is available under the MIT license. See the LICENSE file for more info.