OneSky Java API Library

Java wrapper for OneSky API.

License

License

Categories

Categories

Java Languages Data
GroupId

GroupId

info.datamuse
ArtifactId

ArtifactId

onesky-java
Last Version

Last Version

1.0.0-alpha
Release Date

Release Date

Type

Type

jar
Description

Description

OneSky Java API Library
Java wrapper for OneSky API.
Project URL

Project URL

https://github.com/vovkss/onesky-java
Project Organization

Project Organization

DataMuse
Source Code Management

Source Code Management

https://github.com/vovkss/onesky-java

Download onesky-java

How to add to project

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

Dependencies

compile (4)

Group / Artifact Type Version
com.google.code.findbugs : jsr305 jar 3.0.2
org.slf4j : slf4j-api jar 1.7.25
org.json : json jar 20180130
commons-codec : commons-codec jar 1.11

test (5)

Group / Artifact Type Version
org.junit.jupiter : junit-jupiter-api jar 5.2.0
org.junit.jupiter : junit-jupiter-engine jar 5.2.0
org.hamcrest : java-hamcrest jar 2.0.0.0
com.google.guava : guava-testlib jar 25.1-jre
ch.qos.logback : logback-classic jar 1.2.3

Project Modules

There are no modules declared in this project.

OneSky Java API Library

Java 11+ License Build Status

Java wrapper for OneSky API.

For the list of API wrappers in other programming languages, see the OneSky Platform API documentation.

Dependency Information

The library is available in Maven Central Repository, the coordinates are:

info.datamuse:onesky-java:1.0.0

For example, Apache Maven dependency would be:

<dependency>
  <groupId>info.datamuse</groupId>
  <artifactId>onesky-java</artifactId>
  <version>1.0.0-alpha</version>
</dependency>

How to use

Create a client instance:

// Create the HttpClient and configure it as needed
var httpClient = HttpClient.newHttpClient();

var oneSkyClient = new OneSkyClient(
    "<api-key>", "<api-secret>", httpClient
);

Asynchronous vs synchronous usage:

Every API call returns a CompletableFuture which allows asynchronous API usage, e.g.:

oneSkyClient.locales().list().whenComplete(
    (locales, throwable) -> {
        if (locales != null) {
            final String localesString = locales.stream().map(Locale::toString).collect(Collectors.joining(", "));
            System.out.println("OneSky locales: " + localesString);
        } else if (throwable != null) {
            System.out.println("OneSky API call failed: " + throwable.getMessage());
        }
    }
);

To use the API synchronously, just invoke CompletableFuture.join(), e.g.:

List<Locale> locales = oneSkyClient.locales().list().join();

Project Groups API example:

OneSkyProjectGroupsApi.ProjectGroup javaGroup = oneSkyClient.projectGroups().create("Java", Locale.CHINESE).join();

Page<OneSkyProjectGroupsApi.ProjectGroup> groups = oneSkyClient.projectGroups().pagedList(1, 50).join();

OneSkyProjectGroupsApi.ProjectGroup group4711 = oneSkyClient.projectGroups().retrieve(4711).join();

oneSkyClient.projectGroups().delete(1147).join();

Project Types API example:

List<OneSkyProjectTypesApi.ProjectType> projectTypes = oneSkyClient.projectTypes().list().join();
projectTypes.forEach(projectType -> 
    System.out.println(projectType.getCode() + ": " + projectType.getName())
);

Locales API example:

List<Locale> oneSkyLocales = oneSkyClient.locales().list().join();

Authors and contributors

Versions

Version
1.0.0-alpha