Getting started overview
This guide details the steps required to begin using the Tisane API for text analysis. It covers account creation, obtaining API credentials, and executing a foundational API request. Tisane provides a free tier for up to 500,000 requests per month, allowing developers to test the service without an initial financial commitment. The API supports various natural language processing tasks, including profanity filtering, hate speech detection, and sentiment analysis, as outlined in the Tisane API reference documentation.
The process is structured into three main phases:
- Account Creation and Key Retrieval: Register for a Tisane account and locate your unique API key.
- Environment Setup: Prepare your development environment, including installing any necessary SDKs or libraries.
- First API Request: Construct and execute a basic API call to verify connectivity and functionality.
Tisane offers documentation with examples across several programming languages, including Python, Node.js, and Java, to facilitate integration. The API utilizes standard HTTP methods for communication, typically requiring an API key for authentication.
Quick reference table
| Step | What to do | Where |
|---|---|---|
| 1. Sign Up | Create a new Tisane account. | Tisane homepage |
| 2. Get API Key | Access your dashboard to find your API key. | Tisane dashboard (after login) |
| 3. Install SDK (Optional) | Install the relevant Tisane SDK for your preferred language. | Tisane documentation |
| 4. Make First Request | Use your API key to send a text analysis request. | Your development environment |
Create an account and get keys
To access the Tisane API, you must first register for an account and obtain an API key. This key serves as your authentication credential for all API calls.
Step 1: Sign up for a Tisane account
Navigate to the Tisane homepage and locate the sign-up or registration option. Complete the registration form, providing the required information such as your email address and a password. After submitting the form, you may need to verify your email address by clicking a link sent to your inbox.
Step 2: Locate your API key
Once your account is active and you have logged into the Tisane platform, proceed to your developer dashboard or account settings. The exact location may vary, but typically API keys are found under sections labeled "API Keys," "Credentials," or "Settings." Your API key is a unique string that authenticates your requests. Keep this key secure and do not expose it in client-side code or public repositories. For security best practices regarding API keys, refer to general guidelines for securing API credentials, such as those provided by Google Cloud's API key security documentation.
Your first request
After obtaining your API key, you can make your first request to the Tisane API. This example uses Python, one of the languages for which Tisane provides SDKs. Ensure you have Python installed on your system. You can verify your Python installation by running python --version in your terminal.
Step 1: Install the Python SDK
Open your terminal or command prompt and install the Tisane Python SDK using pip:
pip install tisane
Step 2: Write the code
Create a new Python file (e.g., tisane_test.py) and add the following code. Replace YOUR_API_KEY with the actual API key you obtained from your Tisane dashboard.
import tisane as ts
# Replace with your actual API key
api_key = "YOUR_API_KEY"
# Initialize the Tisane client
client = ts.Tisane(api_key)
# Define the text to analyze
text_to_analyze = "This is a test sentence to check for sentiment and potential issues."
# Define the analysis request
# For a basic analysis, you might request sentiment, entities, or other detections.
# Refer to Tisane documentation for specific analysis types: https://tisane.ai/docs/api-reference
analysis_request = {
"language": "en",
"text": text_to_analyze,
"settings": {
"sentiment": True,
"profanity": True
}
}
try:
# Send the request to the Tisane API
response = client.analyze(analysis_request)
# Print the full JSON response
print("API Response:")
print(response)
# Example of accessing specific parts of the response
if "sentiment" in response:
print(f"\nSentiment: {response['sentiment']}")
if "profanity" in response and response["profanity"]:
print("Profanity detected!")
elif "profanity" in response and not response["profanity"]:
print("No profanity detected.")
except ts.TisaneError as e:
print(f"An API error occurred: {e}")
except Exception as e:
print(f"An unexpected error occurred: {e}")
Step 3: Run the code
Execute the Python script from your terminal:
python tisane_test.py
A successful response will print the JSON output from the Tisane API, indicating the detected sentiment and profanity status based on the provided text. This confirms that your API key is correctly configured and that you can communicate with the Tisane service.
Common next steps
After successfully making your first API call, consider these common next steps to further integrate Tisane into your applications:
- Explore diverse analysis types: Review the Tisane API reference to understand the full range of supported text analysis capabilities, such as hate speech detection, named entity recognition, and topic extraction.
- Integrate with other SDKs: If Python is not your primary development language, explore the SDKs available for Node.js, Java, PHP, Ruby, Go, C#, and Rust to integrate Tisane into your preferred environment.
- Handle rate limits and errors: Implement robust error handling and consider Tisane's rate limit policies to ensure your application behaves predictably under various load conditions.
- Secure your API key: Implement environment variables or a secure configuration management system to store your API key, rather than hardcoding it directly in your application code.
- Monitor usage: Utilize the Tisane dashboard to monitor your API usage and stay within your free tier or paid plan limits.
- Advanced configurations: Experiment with advanced API parameters, such as custom dictionaries or rule sets, to tailor Tisane's analysis to specific domain requirements.
Troubleshooting the first call
If your first API call to Tisane encounters issues, consider the following troubleshooting steps:
- API Key Verification: Double-check that the API key in your code precisely matches the key provided in your Tisane dashboard. Typos or leading/trailing spaces can cause authentication failures.
- Network Connectivity: Ensure your development environment has an active internet connection and is not blocked by a firewall or proxy from accessing
api.tisane.ai. You can test basic connectivity using tools likeping api.tisane.aiorcurl -v https://api.tisane.ai. - SDK Installation: Confirm that the Tisane SDK for your chosen language is correctly installed. For Python, re-run
pip install tisaneto ensure all dependencies are met. - JSON Request Format: Review the structure of your JSON request payload. The Tisane API expects a specific JSON format, and any deviations can lead to parsing errors. Ensure all required fields, such as
languageandtext, are present and correctly formatted. - Error Messages: Pay close attention to any error messages returned by the API or the SDK. These messages often provide specific details about what went wrong, such as "Invalid API Key" (HTTP 401 Unauthorized) or "Bad Request" (HTTP 400).
- Rate Limits: If you are making numerous requests in a short period, you might encounter rate limiting. The Tisane API will typically return an HTTP 429 "Too Many Requests" status code in such cases. Implement exponential backoff for retries if you anticipate hitting rate limits.
- Official Documentation: Consult the official Tisane documentation for the most up-to-date information on API endpoints, request formats, and troubleshooting common issues.