{
  "openapi": "3.1.0",
  "info": {
    "title": "Sentiment Analysis API",
    "version": "1.0.0",
    "description": "Positive or negative with a confidence score for any text, from a model that runs on the platform.\n\nClassify any text as positive or negative with a confidence score, using a DistilBERT model that runs on the platform. Send a short string with GET or a longer body with POST. No third-party keys and nothing leaves the platform.",
    "contact": {
      "name": "Data and APIs",
      "url": "https://dataandapis.com/contact"
    },
    "termsOfService": "https://dataandapis.com/terms-of-service",
    "license": {
      "name": "Data and APIs Terms of Service",
      "url": "https://dataandapis.com/terms-of-service"
    },
    "x-logo": {
      "url": "https://dataandapis.com/images/sentiment.webp"
    }
  },
  "externalDocs": {
    "description": "Documentation, live tester and pricing",
    "url": "https://dataandapis.com/apis/sentiment-analysis"
  },
  "servers": [
    {
      "url": "https://api-sentiment.dataandapis.com"
    }
  ],
  "tags": [
    {
      "name": "AI",
      "description": "Sentiment Analysis API belongs to the AI category of the Data and APIs catalog."
    }
  ],
  "paths": {
    "/v1/sentiment": {
      "get": {
        "operationId": "analyzeSentiment",
        "summary": "Analyze Sentiment",
        "description": "Analyze Sentiment endpoint of the Sentiment Analysis API. Costs 10 tokens per call.",
        "externalDocs": {
          "url": "https://dataandapis.com/apis/sentiment-analysis/analyze-sentiment"
        },
        "parameters": [
          {
            "name": "text",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "I love this product"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "text": "I love this product",
                  "sentiment": "positive",
                  "confidence": 0.9998,
                  "scores": [
                    {
                      "label": "POSITIVE",
                      "score": 0.9998
                    },
                    {
                      "label": "NEGATIVE",
                      "score": 0.0002
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key"
          },
          "402": {
            "description": "Subscription past due; the response carries a payment_url"
          },
          "429": {
            "description": "Monthly token allowance exhausted"
          }
        },
        "security": [
          {
            "ApiKey": []
          }
        ]
      },
      "post": {
        "operationId": "analyzeSentimentPost",
        "summary": "Analyze Sentiment (POST)",
        "description": "Analyze Sentiment (POST) endpoint of the Sentiment Analysis API. Costs 10 tokens per call.",
        "externalDocs": {
          "url": "https://dataandapis.com/apis/sentiment-analysis/analyze-sentiment-post"
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "example": {
                "text": "I love this product"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "text": "I love this product",
                  "sentiment": "positive",
                  "confidence": 0.9999,
                  "scores": [
                    {
                      "score": 0.000121056436910294,
                      "label": "NEGATIVE"
                    },
                    {
                      "score": 0.9998788833618164,
                      "label": "POSITIVE"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key"
          },
          "402": {
            "description": "Subscription past due; the response carries a payment_url"
          },
          "429": {
            "description": "Monthly token allowance exhausted"
          }
        },
        "security": [
          {
            "ApiKey": []
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-Api-Key",
        "description": "Create a free key at https://dataandapis.com/sign-up. 500 tokens a month on the Free plan; this API costs 10 tokens per call."
      }
    }
  },
  "security": [
    {
      "ApiKey": []
    }
  ]
}