Cilenisapi API client

cilenisapi, cilenis
pip install python-cilenisapi==0.0.1



A Python 2 client for the Cilenisapi REST APIs


pip install python-cilenisapi


  • None

Cilenisapi API REST

Cilenis developer site documents all the Cilenis REST APIs.

Data Retrieval:

Init Module

from cilenisapi.client import Cilenis



See the endpoints docs for more on these methods:

get_language_identifier from text or url

lang = cilenisApi.get_language_identifier(text=u"some text")
lang = cilenisApi.get_language_identifier(url=u"")

get_sentiment from text or url (with optional lang parameter)

sentiment_name, sentiment_weight = cilenisApi.get_sentiment(text=u"some text")
sentiment_name, sentiment_weight = cilenisApi.get_sentiment(url=u"")
sentiment_name, sentiment_weight = cilenisApi.get_sentiment(text=u"some text", lang="es")

get_keywords from text or url (with optional lang parameter)

keywords, html = cilenisApi.get_keywords(text=u"some text", lang="es")
keywords, html = cilenisApi.get_keywords(url=u"")

get_multiwords from text or url (with optional lang parameter)

keywords, html = cilenisApi.get_multiwords(text=u"some text", lang="es")
keywords, html = cilenisApi.get_multiwords(url=u"")

get_entities (people, organizations, places) from text or url (with optional lang and entity parameters)

entities, html = cilenisApi.get_entities(text=u"some text", lang="es", entity="all")
entities, html = cilenisApi.get_entities(text=u"some text")
entities, html = cilenisApi.get_entities(text=u"some text", entity="people")
entities, html = cilenisApi.get_entities(text=u"some text", entity="organizations")
entities, html = cilenisApi.get_entities(text=u"some text", entity="places")

get_people from text or url (with optional lang parameter)

people = cilenisApi.get_people(text=u"some text", lang="es")
people = cilenisApi.get_people(url="")

get_organizations from text or url (with optional lang parameter)

organizations = cilenisApi.get_organizations(text=u"some text", lang="es")
organizations = cilenisApi.get_organizations(url="")

get_places from text or url (with optional lang parameter)

places = cilenisApi.get_places(text=u"some text", lang="es")
places = cilenisApi.get_places(url="")

split text or text from url (with optional lang parameter)

splitted_text = cilenisApi.split(text=u"some text", lang="es")
splitted_text = cilenisApi.split(url="")

get_keyword_context url (with optional lang parameter)

contexts = cilenisApi.get_keyword_context(keyword="aprobada", url="")
contexts = cilenisApi.get_keyword_context(keyword="aprobada", url="", lang="es")

conjugate verb from infinitive (with optional lang parameter)

conjugations, lang = cilenisApi.conjugate(text="comer", lang="es")
conjugations, lang = cilenisApi.conjugate(text="comer")

is_infinitive (a word) (with optional lang parameter)

isInfinitive = cilenisApi.is_infinitive(text=u"comer", lang="es")
isInfinitive = cilenisApi.is_infinitive(text=u"palabra")

get_text_from_web (url) (with optional lang parameter)

text = cilenisApi.get_text_from_web(url=u"", lang="es")
text = cilenisApi.get_text_from_web(url=u"")

raw_endpoint (call api with raw endpoint and params and get raw response)

raw_response = cilenisApi.raw_endpoint( endpoint=u"language_identifier", params={
  "text": u"texto de ejemplo",
  "format": "xml",
  "app_id": CILENIS_APP_ID,
  "app_key": CILENIS_APP_KEY

Error handling

Importing the exceptions module allows handling of specific error status codes. An example is provided below:

from cilenisapi.exceptions import CilenisApiException, CilenisValidationException

  # your code goes here
except CilenisValidationException as e:
  print "Validation error %s" % unicode(e)
except CilenisApiException as e:
  print "API error %s" % unicode(e)


>>> conjugations, lang = cilenisApi.conjugate(text=u"palabra", lang="es")

Traceback (most recent call last):
  File "", line 28, in <module>
    conjugations, lang = cilenisApi.conjugate(text=u"palabra", lang="es")
  File ".../python-cilenisapi/cilenisapi/", line 97, in wrapped_f
    return f(self, *args, **kwargs)
  File ".../python-cilenisapi/cilenisapi/", line 147, in conjugate
    raise CilenisApiException(msg=unicode(result_json['conjugations'][0]['conjugation'][0]['code_tense']))
cilenisapi.exceptions.CilenisApiException: palabra no es un verbo en infinitivo

Sample app

This repository includes a one-file sample app. Fill your cilenisapi credentials.