R: Using IBM Alchemy Language Text API

IBM provides a detailed documentation for using Alchemy API, however it is not language specific. I found one useful blog from google that got me started. If you’re looking to use web API with R, you’ll find your solution at “dreamtolearn: IBM Watson & AlchemyAPI – Making First Contact with R Programming Language“. In this blog post I will share my solution for using Alchemy Language Text API.

I tried the Alchemy Language online demo and found Taxonomy to be a suitable feature for my data.


In the above screenshot, you see 3 output formats. Visual, JSON, API. When you click on API, you are redirected to documentation for using Taxonomy.

NOTE: before proceeding to the code, you need to obtain Alchemy API key.

To test the API, I prepare text as URL, then set parameters and finally execute POST command.

If code runs successfully, you should see the output in following format


Once I confirmed that the API was working I needed to extract the results from JSON and store them in my dataframe. I used jsonlite::fromJSON() function to achieve this.

To try other Alchemy Language features through text API, change value of api_feature parameter. In addition to “TextGetRankedTaxonomy”, I tried “TextGetTextSentiment” which follows the same format. Next I’ll try “TextGetRankedKeywords”. If it requires any further changes I’ll include them in my next post.

Happy Coding 🙂


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s