Text Summarization API for Objective-C


To use our Text Summarization API in Objective-C, you need install the Unirest for Objective-C client library.

Download the Obejctive-C Unirest Library form Github and import the folder into your project, that's all.

With CocoaPods

You can also install Unirest-obj-c with CocoaPods, create a Podfile file in your project's folder:

$ edit Podfile
platform :ios, '5.0'
pod 'Unirest', '~> 1.1.3'

and then execute pod install. Make sure to always open the Xcode workspace instead of the project file when building your project:

open App.xcworkspace

Now you can import your dependencies:

import <UNIRest.h>


The Unirest-Obj-C client library requires ARC(Automatic Reference Counting) to be enabled in your Xcode project. To enable ARC select your project or target and then go to Build Settings and under the section Apple LLVM compiler 3.0 - Language you will see the option Objective-C Automatic Reference Counting:


For existing projects, fortunately Xcode offers a tool to convert existing code to ARC, which is available at Edit -> Refactor -> Convert to Objective-C ARC.

Creating POST Requests

Now you are probaly wondering how using Unirest to creat requests for the Text Summarization API in Objective-C. Let's start with the previous json rquest body example:

    "url": "http://en.wikipedia.org/wiki/Automatic_summarization",
    "text": "",
    "sentnum": 8

The request created with Unirest Objective-C library like this:

NSDictionary headers = @{@"X-Mashape-Authorization": @"Your Mashape API Key", @"Content-Type": @"application/json"};
NSDictionary parameters = @{};

UNIHttpJsonResponse response = [[UNIRest post:^(UNIBodyRequest request) { [request setUrl:@"https://textanalysis-text-summarization.p.mashape.com/text-summarizer"]; [request setHeaders:headers]; [request setParameters:parameters]; [request setBody:[@"{\"url\":\"http:\/\/en.wikipedia.org\/wiki\/Automatic_summarization\",\"text\":\"\",\"sentnum\":8}" dataUsingEncoding:NSUTF8StringEncoding]]; }] asJson];

Here the Mashape API Key you can find in your Mashape account dashboard, copy it and replace it, now it's time to enjoy our Text Summarization API for your Objective-c Projects.

About Unirest

Unirest is a set of lightweight HTTP libraries available in multiple languages, ideal for most applications:

  • Make GET, POST, PUT, PATCH, DELETE requests
  • Both syncronous and asynchronous (non-blocking) requests
  • It supports form parameters, file uploads and custom body entities
  • Supports gzip
  • Supports Basic Authentication natively
  • Customizable timeout
  • Customizable default headers for every request (DRY)
  • Automatic JSON parsing into a native object for JSON responses


For other languages support by Text Summarization API, you can find the document link below: