Text Summarization API for Ruby


To use our Text Summarization API in Ruby, you need install the Unirest for Ruby client library first.

Requirements: Ruby >= 2.0 To utilize unirest for ruby, install the unirest gem:

gem install unirest

After installing the gem package, you can now begin to simplifying requests by requiring unirest:

require 'unirest'

Creating POST Requests

Now you are probaly wondering how using Unirest to creat requests for the Text Summarization API in Ruby. 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 Ruby library like this:

response = Unirest::post "https://textanalysis-text-summarization.p.mashape.com/text-summarizer",
    headers: {
        "X-Mashape-Authorization" => "Your Mashape API Key",
        "Content-Type" => "application/json"
    parameters: "{\"url\":\"http:\/\/en.wikipedia.org\/wiki\/Automatic_summarization\",\"text\":\"\",\"sentnum\":8}"

Here the Mashape API Key you can find in your Mashape account dashboard, copy it and replace it, and than excute it by the ruby interpreter, finally, you can get the response like this:

response.code # Status code
response.headers # Response headers
response.body # Parsed body
response.raw_body # Unparsed body

Now it's time to enjoy our Text Summarization API for your Ruby 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: