SDKs

Our Text Analysis SDKs are the quickest and easiest way to get up & running with our Text Analysis API. Click on the buttons below to see specific instructions for your favorite programming language.

Node.js SDK

Clone the Node.js SDK from our GitHub or use npm to download and install the SDK:

npm install aylien_textapi

You can then import and initiate the SDK easily:

var AYLIENTextAPI = require('aylien_textapi');
var textapi = new AYLIENTextAPI({
  application_id: "YOUR_APP_ID",
  application_key: "YOUR_APP_KEY"
});

The textapi object is now instantiated and contains various methods for calling different API endpoints. For instance to use Sentiment Analysis you can write the following code:

textapi.sentiment({
  'text': 'John is a very good football player!'
}, function(error, response) {
  if (error === null) {
    console.log(response);
  }
});

You can find examples for utilizing other endpoints in Node.js in the Endpoints section of this documentation.

Python SDK

Clone the Python SDK from our GitHub or use pip to download and install the SDK:

pip install --upgrade aylien-apiclient

You can then import and initiate the SDK easily:

from aylienapiclient import textapi

client = textapi.Client("YOUR_APP_ID", "YOUR_APP_KEY")

The client object is now instantiated and contains various methods for calling different API endpoints. For instance to use Sentiment Analysis you can write the following code:

sentiment = client.Sentiment({'text': 'John is a very good football player!'})

You can find examples for utilizing other endpoints in Python in the Endpoints section of this documentation.

PHP SDK

Clone the PHP SDK from our GitHub or use composer to require the SDK as a dependency in your project by adding the following to your composer.json file:

{
  "require": {
    "aylien/textapi": "0.6.*"
  }
}

You can then initiate the SDK easily:

<?php
  $textapi = new AYLIEN\TextAPI("YOUR_APP_ID", "YOUR_APP_KEY");
?>

The $textapi object is now instantiated and contains various methods for calling different API endpoints. For instance to use Sentiment Analysis you can write the following code:

<?php
  $sentiment = $textapi->Sentiment(array(
    'text' => 'John is a very good football player!'
  ));
?>

You can find examples for utilizing other endpoints in PHP in the Endpoints section of this documentation.

Java SDK

Clone the Java SDK from our GitHub or use a published binary release.

The Java SDK is published to The Maven Central Repository, so no additional repositories are required.

Using Maven:

<dependency>
  <groupId>com.aylien.textapi</groupId>
  <artifactId>client</artifactId>
  <version>0.6.0</version>
</dependency>

Using sbt and Scala:

libraryDependencies += "com.aylien.textapi" % "client" % "0.6.0"

Or download directly if you're not using a dependency manager.

Step by Step Guide to Building a Maven Project

1. Create a new directory

mkdir Demo
cd Demo

2. Create the POM file (pom.xml) file in it with following contents:

<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.example</groupId>
  <artifactId>aylien-textapi-sample-app</artifactId>
  <version>0.1.0-SNAPSHOT</version>
  <dependencies>
    <dependency>
      <groupId>com.aylien.textapi</groupId>
      <artifactId>client</artifactId>
      <version>0.6.0</version>
    </dependency>
  </dependencies>
</project>

3. Create the required Java source directories:

mkdir -p src/main/java/com/example/

4. Create a new Java file named SentimentDemo.java with following contents in the newly created directory:

package com.example;

import com.aylien.textapi.TextAPIClient;
import com.aylien.textapi.parameters.*;
import com.aylien.textapi.responses.*;

class SentimentDemo {
  public static void main(String[] args) throws Exception {
    TextAPIClient client = new TextAPIClient("YOUR_APP_ID", "YOUR_APP_KEY");
    SentimentParams.Builder builder = SentimentParams.newBuilder();
    builder.setText("John is a very good football player");
    Sentiment sentiment = client.sentiment(builder.build());
    System.out.println(sentiment);
  }
}

5. Compile and run the project

mvn compile
mvn exec:java -Dexec.mainClass="com.example.SentimentDemo"

You can find examples for utilizing other endpoints in Java in the Endpoints section of this documentation.

Ruby SDK

Clone the Ruby SDK from our GitHub or use gem to download and install the SDK:

gem install aylien_text_api

You can then import and initiate the SDK easily:

require 'aylien_text_api'

textapi = AylienTextApi::Client.new(app_id: "YOUR_APP_ID", app_key: "YOUR_APP_KEY")

The textapi object is now instantiated and contains various methods for calling different API endpoints. For instance to use Sentiment Analysis you can write the following code:

textapi.sentiment text: "John is a very good football player!"

You can find examples for utilizing other endpoints in Ruby in the Endpoints section of this documentation.

Go SDK

Clone the Go SDK from our GitHub or use go get to download and install the SDK:

go get github.com/AYLIEN/aylien_textapi_go

You can then initiate the SDK easily:

package main

import (
  "fmt"
  textapi "github.com/AYLIEN/aylien_textapi_go"
)

func main() {
  auth := textapi.Auth{"YOUR_APP_ID", "YOUR_APP_KEY"}
  client, err := textapi.NewClient(auth, true)
  if err != nil {
      panic(err)
  }
}

The client object is now instantiated and contains various methods for calling different API endpoints. For instance to use Sentiment Analysis you can write the following code:

text := "John is a very good football player!"
sentimentParams := &textapi.SentimentParams{Text: text}
sentiment, err := client.Sentiment(sentimentParams)
if err != nil {
  panic(err)
}
fmt.Printf("%v\n", sentiment)

You can find examples for utilizing other endpoints in Go in the Endpoints section of this documentation.

C# SDK

Clone the C# SDK from our GitHub or use NuGet to download and install the SDK:

PM> Install-Package Aylien.TextApi

You can then initiate the SDK easily:

using Aylien.TextApi;
using System;

namespace ConsoleApplication
{
  class Program
  {
    static void Main(string[] args)
    {
      Client client = new Client("YOUR_APP_ID", "YOUR_APP_KEY");
    }
  }
}

The client object is now instantiated and contains various methods for calling different API endpoints. For instance to use Sentiment Analysis you can write the following code:

Sentiment sentiment = client.Sentiment(text: "John is a very good football player!");

Console.WriteLine("Sentiment: {0} ({1})", sentiment.Polarity, sentiment.PolarityConfidence);

You can find examples for utilizing other endpoints in C# in the Endpoints section of this documentation.