FigShare Java API

A Java API to interface with the FigShare API

Categories

Categories

Java Languages
GroupId

GroupId

org.biouno
ArtifactId

ArtifactId

figshare-java-api
Last Version

Last Version

0.1
Release Date

Release Date

Type

Type

jar
Description

Description

FigShare Java API
A Java API to interface with the FigShare API
Project URL

Project URL

https://github.com/biouno/figshare-java-api
Project Organization

Project Organization

TupiLabs
Source Code Management

Source Code Management

https://github.com/biouno/figshare-java-api

Download figshare-java-api

How to add to project

<!-- https://jarcasting.com/artifacts/org.biouno/figshare-java-api/ -->
<dependency>
    <groupId>org.biouno</groupId>
    <artifactId>figshare-java-api</artifactId>
    <version>0.1</version>
</dependency>
// https://jarcasting.com/artifacts/org.biouno/figshare-java-api/
implementation 'org.biouno:figshare-java-api:0.1'
// https://jarcasting.com/artifacts/org.biouno/figshare-java-api/
implementation ("org.biouno:figshare-java-api:0.1")
'org.biouno:figshare-java-api:jar:0.1'
<dependency org="org.biouno" name="figshare-java-api" rev="0.1">
  <artifact name="figshare-java-api" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.biouno', module='figshare-java-api', version='0.1')
)
libraryDependencies += "org.biouno" % "figshare-java-api" % "0.1"
[org.biouno/figshare-java-api "0.1"]

Dependencies

compile (6)

Group / Artifact Type Version
oauth.signpost : signpost-core jar 1.2
oauth.signpost : signpost-commonshttp4 jar 1.2
org.apache.httpcomponents : httpclient jar 4.4.1
org.apache.httpcomponents : httpcore jar 4.4.1
org.apache.httpcomponents : httpmime jar 4.4.1
com.google.code.gson : gson jar 2.3.1

test (2)

Group / Artifact Type Version
commons-io : commons-io jar 2.3
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

FigShare Java API

A Java API to interface with the FigShare API.

Currently supporting the following operations:

  • Retrieve all articles
  • Create an article
  • Upload a file to an article

Basic usage

String clientKey = "1234";
String clientSecret = "1234";
String tokenKey = "1234";
String tokenSecret = "1234";

FigShareClient figshare = FigShareClient.to(
        "http://api.figshare.com/", 
        1, 
        clientKey, 
        clientSecret, 
        tokenKey, 
        tokenSecret)
;

Retrieve all articles

List<Article> articles = figshare.articles();
System.out.println(articles);

Should print something similar to:

[Article [articleId=123456789, title=Violão, masterPublisherId=0, definedType=figure, status=Private, version=1, publishedDate=09:27, Jun 03, 2015, description=<p>A test guitar</p>, descriptionNohtml=A test guitar, totalSize=116.88 KB, authors=[Author [firstName=Bruno, lastName=Kinoshita, id=123, fullName=Bruno Kinoshita]], tags=[Tag [id=456, name=guitar]], files=[File [size=120 KB, thumb=http://figshare.com/read/private/23232/3232.jpg, id=567, mimeType=image/jpeg, name=IMG-87878-WA0002.jpg]], links=[Link [id=124, link=http://google.com], Link [id=5454, link=http://github.com]]]]

Create an article

String clientKey = "1234";
String clientSecret = "1234";
String tokenKey = "1234";
String tokenSecret = "1234";

Article article = figshare.createArticle(
        "Test_" + Thread.currentThread().getName() + "_" + System.nanoTime(), 
        "A test article...", 
        "dataset");
System.out.println(article);

Should print something similar to:

Article [articleId=1234, title=Test_main_6851933204498, masterPublisherId=null, definedType=dataset, status=Drafts, version=1, publishedDate=06:25, May 31, 2015, description=A test article..., descriptionNohtml=A test article..., totalSize=false, authors=[Author [firstName=Bruno, lastName=Kinoshita, id=2131, fullName=Bruno Kinoshita]], tags=[], categories=[], files=[], links=null, doi=http://dx.doi.org/3234/m9.figshare.1323181, downloads=0, owners=null, shares=0, views=0]

Upload a file to an article

File attachment = new File("/home/kinow/Desktop/images/gDv6mJS.gif");
org.biouno.figshare.v1.model.File uploaded = figshare.uploadFile(article.getArticleId(), attachment);
System.out.println(uploaded);

Should print something similar to:

File [size=1.90 MB, thumb=null, id=31432, mimeType=image/gif, name=gDv6mJS.gif]
org.biouno

BioUno

Continuous Integration tools and techniques applied in Bioinformatics

Versions

Version
0.1