Get Your API Credentials

If you haven't already done so, you will need to sign up.

Sign up to our free plan here:

The Free plan allows you to make 1,000 calls/day for free. For further information on paid plans please visit our plans page.

Getting Started with AYLIEN Text Analysis API Using PHP


  • PHP >= 5.3.0

Getting the SDK

The easisest way to get the PHP SDK is to use Composer. Please read the Composer Getting Started guide to learn how to get everything set up.

After installing Composer, you need to add aylien/textapi as a requirement. For example:

  "require": {
    "aylien/textapi": "0.3.*"

Alternatively, clone the source from GitHub repository or download a release from GitHub releases page.

Using the SDK

The following example demonstrates how to calculate the sentiment of a simple sentence, and determine the language it's written in.

# To use the SDK either use Composer's autoload
require __DIR__ . "/vendor/autoload.php";

# Or manually
# require_once("aylien_textapi_php/src/AYLIEN/TextAPI.php");

$text = "John is a very good football player!";

$textapi = new AYLIEN\TextAPI("YourApplicationId", "YourApplicationKey");
$sentiment = $textapi->Sentiment(array("text" => $text));
$language = $textapi->Language(array("text" => $text));

echo 'Sentiment: ', $sentiment->polarity, ' (', $sentiment->polarity_confidence, ')' . PHP_EOL;
echo 'Language: ', $language->lang, ' (', $language->confidence, ')' . PHP_EOL;