Please follow all the steps above:
- Get Your Free API Key - AlchemyAPI requires an API Key to access their text analysis functions.
- Clone Python SDK from GitHub - To make using AlchemyAPI easier, they've created a software development kit, or
SDK
for short.
Hint:
mkdir -p ~/src/test
cd ~/src/test
git clone https://github.com/AlchemyAPI/alchemyapi_python.git
cd alchemyapi_python/
3. Configure the Python SDK to use your API Key - all you need to do is configure it to use your API key:
python alchemyapi.py YOUR_API_KEY
4. Run a simple Example:
python example.py
At this point you should get lots of output in the terminal window as each function is called and the output is parsed.
Now, to be able to use AlchemyAPI
functionality just copy and paste the alchemyapi.py
file into your project, and in the file that will handle the text analysis include the following lines:
from alchemyapi import AlchemyAPI
alchemyapi = AlchemyAPI()
Now you can use the alchemyapi object to access any of the text analysis functions:
myText = "I'm excited to get started with AlchemyAPI!"
response = alchemyapi.sentiment("text", myText)
print "Sentiment: ", response["docSentiment"]["type"]
Disclaimer: make sure that you follow all these steps in order to be able to access the API.