Input
   
POST https://gateway.appypie.com/distilbert-sst-2-int8/v1/getClassification HTTP/1.1

Content-Type: application/json
Cache-Control: no-cache

{
    "prompt": "I like you. I love you"
}


import urllib.request, json

try:
    url = "https://gateway.appypie.com/distilbert-sst-2-int8/v1/getClassification"

    hdr ={
    # Request headers
    'Content-Type': 'application/json',
    'Cache-Control': 'no-cache',
    }

    # Request body
    data =  
    data = json.dumps(data)
    req = urllib.request.Request(url, headers=hdr, data = bytes(data.encode("utf-8")))

    req.get_method = lambda: 'POST'
    response = urllib.request.urlopen(req)
    print(response.getcode())
    print(response.read())
    except Exception as e:
    print(e)


// Request body
const body = {
    "prompt": "I like you. I love you"
};

fetch('https://gateway.appypie.com/distilbert-sst-2-int8/v1/getClassification', {
        method: 'POST',
        body: JSON.stringify(body),
        // Request headers
        headers: {
            'Content-Type': 'application/json',
            'Cache-Control': 'no-cache',
            }
    })
    .then(response => {
        console.log(response.status);
        console.log(response.text());
    })
    .catch(err => console.error(err));
curl -v -X POST "https://gateway.appypie.com/distilbert-sst-2-int8/v1/getClassification" -H "Content-Type: application/json" -H "Cache-Control: no-cache" -H  --data-raw "{
    \"prompt\": \"I like you. I love you\"
}"
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;
import java.io.UnsupportedEncodingException;
import java.io.DataInputStream;
import java.io.InputStream;
import java.io.FileInputStream;

public class HelloWorld {

  public static void main(String[] args) {
    try {
        String urlString = "https://gateway.appypie.com/distilbert-sst-2-int8/v1/getClassification";
        URL url = new URL(urlString);
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();

        //Request headers
    connection.setRequestProperty("Content-Type", "application/json");
    
    connection.setRequestProperty("Cache-Control", "no-cache");
    
    
        connection.setRequestMethod("POST");

        // Request body
        connection.setDoOutput(true);
        connection
            .getOutputStream()
            .write(
             "{ \"prompt\": \"I like you. I love you\" }".getBytes()
             );
    
        int status = connection.getResponseCode();
        System.out.println(status);

        BufferedReader in = new BufferedReader(
            new InputStreamReader(connection.getInputStream())
        );
        String inputLine;
        StringBuffer content = new StringBuffer();
        while ((inputLine = in.readLine()) != null) {
            content.append(inputLine);
        }
        in.close();
        System.out.println(content);

        connection.disconnect();
    } catch (Exception ex) {
      System.out.print("exception:" + ex.getMessage());
    }
  }
}

$url = "https://gateway.appypie.com/distilbert-sst-2-int8/v1/getClassification";
$curl = curl_init($url);

curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

# Request headers
$headers = array(
    'Content-Type: application/json',
    'Cache-Control: no-cache',
    'Ocp-Apim-Subscription-Key: e79ab03b223f426093ce71414f95fa8b',);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);

# Request body
$request_body = '{
    "prompt": "I like you. I love you"
}';
curl_setopt($curl, CURLOPT_POSTFIELDS, $request_body);

$resp = curl_exec($curl);
curl_close($curl);
var_dump($resp);
Output
DistilBERT SST 2 API

Distilbert SST-2: Accurate Sentiment Analysis for Data-Driven Decisions

meta

DistilBERT-SST-2 is a powerful text classification model designed to provide precise sentiment analysis by leveraging advanced natural language processing capabilities. Built on the DistilBERT architecture, a compact version of the popular BERT (Bidirectional Encoder Representations from Transformers) model, it excels at identifying the sentiment in text data, making it highly valuable for applications like customer feedback, social media analysis, and product reviews. Its ability to accurately classify sentiment as positive or negative helps businesses understand customer emotions and make informed decisions based on real-time sentiment trends.

With DistilBERT-SST-2 API, developers can easily integrate this advanced sentiment analysis tool into their applications, enhancing their ability to monitor customer feedback and sentiment across multiple platforms. The API provides seamless access to the model, ensuring quick and reliable results for a wide range of use cases, from marketing analytics to product development. This API empowers businesses to harness data-driven insights and optimize strategies for improved customer satisfaction.

How to Run DistilBERT-SST-2 with an API?

Running DistilBERT-SST-2 with an API is a straightforward process that allows developers to leverage the model’s sentiment analysis capabilities. Follow this step-by-step guide to get started:

generate_01

Obtain Your API Key

First, sign up on Appy Pie Endpoint which provides access to the DistilBERT-SST-2 API. Once registered, you will receive an API key, which is necessary for authenticating your requests and ensuring secure communication with the API.

generate_02

Set Up Your Development Environment and Parameters

Choose your preferred programming language (e.g., Python, JavaScript, or PHP) and install any necessary libraries for making HTTP requests. Once your environment is ready, you'll need to define essential parameters such as the API key for authentication, the text input for analysis.

generate_03

Send the API Request

After setting up your environment and defining the parameters, it's time to send the API request. Use the programming language of your choice to send an HTTP POST request to the DistilBERT-SST-2 API endpoint. The request should include the API key in the headers for authentication and the text input as the data payload.

generate_04

Handle the API Response

Once the API processes your request, it will return a response containing the sentiment classification (positive or negative) along with any other relevant data, such as confidence scores. You can then parse the response to display, log, or integrate the results into your application.

Use Cases of DistilBERT-SST-2

cases_1

Real-Time Customer Feedback Analysis

With the DistilBERT-SST-2 API, businesses can instantly analyze customer feedback from a wide range of platforms, including surveys, reviews, social media, and emails. By identifying positive or negative sentiments in real-time, companies can gain valuable insights into customer emotions, allowing them to quickly address concerns, enhance products, and leverage positive experiences to foster stronger customer relationships and overall satisfaction.

cases_2

Social Media Sentiment Monitoring

The DistilBERT-SST-2 API enables businesses to monitor sentiment across various social media platforms in real-time. By analyzing user posts, comments, mentions, and reactions, brands can gain deeper insights into public perception, detect emerging trends early, and respond proactively to shifts in customer sentiment. Whether addressing negative feedback or amplifying positive mentions, companies can strategically enhance and protect their brand reputation.

cases_3

Product Review Sentiment Analysis

Using the DistilBERT-SST-2 API, e-commerce platforms can effectively analyze product reviews to gauge customer satisfaction and identify key sentiments. By determining whether customers are satisfied or dissatisfied, businesses can pinpoint areas for product improvement, refine their offerings, and enhance the overall customer experience. This sentiment analysis supports data-driven decisions, helping optimize future sales strategies and improve long-term customer loyalty.

cases_4

Brand Reputation Management

The DistilBERT-SST-2 API enables businesses to track and analyze brand mentions across the web, allowing them to detect shifts in public sentiment and perception. By swiftly addressing negative feedback and reinforcing positive mentions, companies can effectively manage and protect their brand's reputation. This continuous sentiment monitoring allows businesses to adjust marketing and communication strategies, ensuring they maintain a strong, positive public image.

cases_5

Customer Service Optimization

Integrating the DistilBERT-SST-2 API into customer service workflows allows for automatic sentiment detection in support interactions. By analyzing the emotional tone of customer queries, businesses can prioritize urgent or negative cases, offering faster, more personalized responses. This targeted approach enhances the overall customer support experience, leading to higher satisfaction, increased efficiency, and ultimately, improved customer retention and loyalty.

cases_6

Marketing Campaign Effectiveness

The DistilBERT-SST-2 API empowers businesses to analyze sentiment generated by their marketing campaigns, offering key insights into campaign effectiveness. By assessing audience reactions—whether positive or negative—companies can determine how well their messaging connects with target demographics. This data-driven insight allows businesses to fine-tune and adjust their marketing strategies, ensuring deeper audience engagement.

Top Trending Generative AI APIs

 

Maximize the potential of your projects with our Generative AI APIs. From video generation & image creation to text generation, animation, 3D modeling, prompt generation, image restoration, and code generation, our advanced APIs cover all aspects of generative AI to meet your needs.