Redlink SDK Documentation

General

Introduction

The Redlink SDK gives you a group of APIs along with client libraries, language-specific examples, and documentation to help you develop awesome applications that integrate with Redlink. If you're a new Redlink developer, we recommend you download the SDK bundle to quickly start developing against our API. The SDKs are provided for a limited set of languages; so if it does not covers your particular, needs, please contact us for further information.

Note: With the SDK, you'll use the same key-based model to access the API. So you also need to register your API key in advance.

Each artifact of the different official SDK keeps align the version with the API; i.e., SDK version x.y.z implements x.y version of the API, whatever programming language. The minor version (z is reserved for minor updates or bug fixes in the concrete SDK, so may be different on each implementation.

Model

The SDK tries to keep homogeneus the model across the different languages which is implemented, with of course the small style details are different for each one. So, for instance, for content analysis the same data model is followed in all implementations.

License

All official Redlink SDK are avaiable under the business-friendly license Apache License, Version 2.0. Therefore, you are completely free to use the software for any purpose, to distribute it, to modify it, and to distribute modified versions of the software, including closed-source, under the terms of the license, without concern for royalties.

Issues

Bug reports or features requests should go directly reported to the issue tracker of each implementation in GitHub. For further support, please contact us.

Java SDK

Installation

The Java SDK uses Maven as build system, and it's available from Maven Central. So if you want to use it, just add the following dependency to your Maven project:

<project>
  ...
  <dependencies>
    ...
    <dependency>
      <groupId>io.redlink</groupId>
      <artifactId>redlink-sdk-java</artifactId>
      <version>1.0.3</version>
    </dependency>
  </dependencies>
  ...
</project>

You can take a look to the javadoc. Or, if you want to know some more implementations detail, the source code is available at github:

git clone git@github.com:redlink-gmbh/redlink-java-sdk.git

Usage

The main entry point is provided by an abstract factory (io.redlink.sdk.RedLinkFactory) that allows you to create specific clients for each part of the API:

String api_key = "...";
RedLink.Analysis analysis = RedLinkFactory.createAnalysisClient(api_key);
RedLink.Data data = RedLinkFactory.createDataClient(api_key);

Basically the SDK provides a native version in Java of features provided by the API. So, for instance, for enhancing content, the SDK provides a simple DSL to build enhancement request:

AnalysisRequest request = AnalysisRequest.builder()
    .setAnalysis("example")
    .setContent("David Alaba is an Austrian footballer who plays for Bayern Munich (...)")
    .setOutputFormat(OutputFormat.TURTLE)
    .build();
for (Enhancement e : analysis.enhance(request)) {
    // do something with each enhancement returned
}

You can find further details about the enhancements returned at its javadoc.

Moving to the data part, the SDK also provide native Java methods for each feature. For example, RDF data can be imported from different sources (File, InputStream or Model) with this snippet of code:

boolean imported = data.importDataset(source, "example");

As well as performing SPARQL queries over the dataset you just imported:

SPARQLResult results = data.sparqlSelect("SELECT * WHERE { ?s ?p ?o }", "example");
for (Map<String, RDFNode> result: results) {
    System.out.println(" (" + result.get("s") + ","  + result.get("p") + "," + result.get("o") + ")");
}

Or update the dataset via SPARQL Update queries:

data.sparqlUpdate("INSERT DATA " + 
  "{ <http://example.org/test> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/Thing> }", 
  "example");

Further details about the methods supported in the javadoc.

PHP SDK

Installation

The PHP SDK uses Composer as management system. But these initial versions are not being yet deployed in public repositories. So you would need to manually download the redlink-sdk-php-1.0.0.phar and put it the right location:

wget http://dev.redlink.io/sdk/php/redlink-sdk-php-1.0.0.phar

Then you can define the dependecy as normal:

{
    "require": {
        "redlink/sdk-php": "1.0.0"
    }
}

If you want to know some more implementations detail, the source code is available at github:

git clone git@github.com:redlink-gmbh/redlink-php-sdk.git

Usage

The PHP SDK provide a Factory (\RedLink\RedLinkFactory) that provides how to create the different clients for each part of the API:

String api_key = "...";
$analysisClient = \RedLink\RedLinkFactory::getInstance()->createAnalysisClient($api_key);
$request = \RedLink\Analysis\AnalysisRequestBuilder::builder()->setAnalysis("example")->setContent("David Alaba is an Austrian footballer who plays for Bayern Munich (...)")->setOutputFormat("json")->build();
$enhancements = $analysisClient->enhance($request);

Its usage is actually quite similar than the Java SDK, so feel free to inspect the methods.

Python SDK

The Python SDK is available from PyPI, so it can be easily installed:

sudo pip install redlink

The source code is available from github:

git clone git@github.com:redlink-gmbh/redlink-python-sdk.git

Usage

As for other languages, the Python SDK provides a factory to create the different clients for each part of the API:

import redlink
api_key = "..."
analysis = redlink.create_analysis_client(api_key)
data = redlink.create_data_client(api_key)

Then its usage is actually quite similar than other languages, for instance enhancing a text:

enhancements = analysis.enhance("Lorem Ipsum is simply dummy text of the printing and typesetting industry.")
print("extracted %s entities:" % len(enhancements["entities"])
print("\n - %s" % "\n - ".join(["%s (%s)" % (e["reference"], e["confidence"]) for e in enhancements["entities"]]))

Or importing and querying data:

data.import_dataset(open("example.ttl"), "text/turtle", "example")
results = data.sparql_tuple_query("select * where { ?s ?p ?o }", "example")

for result in results["results"]["bindings"]:
    print(" - (%s, %s, %s)" % (result["s"]["value"], result["p"]["value"], result["o"]["value"]))

Further details about the methods supported in the api docs.

Javascript SDK

Comming soon...