Tutorial💻

Integrating Amaalsense API: A Developer's Guide

Developer RelationsDecember 28, 202512 min read
APIIntegrationDevelopment

Getting Started with AmalSense API

This comprehensive guide will walk you through integrating AmalSense's emotion analysis capabilities into your applications.

Prerequisites

  • API key (available in your dashboard)
  • Basic knowledge of REST APIs
  • Your preferred programming language

    Authentication

    All API requests require authentication via Bearer token:

    curl -H "Authorization: Bearer YOUR_API_KEY" \

  • https://api.amalsense.com/v1/analyze

    Core Endpoints

    1. Analyze Text
    POST /v1/analyze
    

    Request body:

    {
      "text": "Your text to analyze",
      "language": "en",
      "include_emotions": true
    }
    

    Response:

    {
      "gmi": 45.2,
      "cfi": 23.1,
      "hri": 67.8,
      "emotions": {
        "joy": 0.3,
        "fear": 0.1,
        "anger": 0.05,
        "sadness": 0.1,
        "hope": 0.35,
        "curiosity": 0.1
      }
    }
    

    2. Get Country Data
    GET /v1/countries/{country_code}
    

    3. Historical Data
    GET /v1/history?country={code}&days={n}
    

    Rate Limits

    Plan Requests/minute Requests/day








    -



    -- Free 10 1,000 Pro 100 50,000 Enterprise Unlimited Unlimited

    Code Examples

    Python
    import requests

    response = requests.post( "https://api.amalsense.com/v1/analyze", headers={"Authorization": "Bearer YOUR_KEY"}, json={"text": "Great news today!"} ) print(response.json())

    JavaScript
    const response = await fetch(
      "https://api.amalsense.com/v1/analyze",
      {
        method: "POST",
        headers: {
          "Authorization": "Bearer YOUR_KEY",
          "Content-Type": "application/json"
        },
        body: JSON.stringify({ text: "Great news today!" })
      }
    );
    const data = await response.json();
    

    Best Practices

    1. Cache responses

  • Emotion data doesn't change rapidly
  • 2. Batch requests
  • Use bulk endpoints for multiple texts
  • 3. Handle errors gracefully
  • Implement retry logic
  • 4. Respect rate limits
  • Use exponential backoff

    Support

    - Documentation: docs.amalsense.com

  • Support: [email protected]
  • Discord: discord.gg/amalsense


    *Happy coding! We can't wait to see what you build.*