API Documentation
bitgrit X Virality Prediction API

bitgrit X Virality Prediction API Documentation

Getting Started

The X Virality Prediction API is designed to predict the potential virality of tweets utilizing the winning algorithm from the "Viral Tweets Prediction Challenge" held on the bitgrit competition platform.

This document provides comprehensive guidance on invoking the API through Postman and Python.

How to get access to X Virality Prediction API

  1. Sign up for a developer account. You can sign up for a developer account from the link.
  2. Once your request is approved, you will receive the welcome email with an api key enclosed.
  3. Submit the JSON input to the API via an API tool of your choice (i.e. Postman).

Call X Virality Prediction API from Postman

Call X Virality Prediction API
  1. Download Postman app. (https://www.postman.com/)
  2. Select 'POST' method.
  3. Type in API URL (https://www.bitgritapi.net/x/x-virality-api).
  4. In the “Authorization” pane, set 'Type' to 'API Key' and type in 'x-api-key' to Key and your API Key to 'Value' section.
Call X Virality Prediction API from Postman
  1. In 'Body' pane, choose 'raw' and enter the input in JSON format.
  2. Hit the 'Send' button.

Request and Response

The example input and response from the API are as follows:

    input:
        {
        “followers”: 1000,
        “following”: 300,
        “tweet”: “Today is a good day.”
        }

    output: 
        0.379
    

Call X Virality Prediction API using Python

        import requests
        import json

        # The URL for the API
        api_url = "https://www.bitgritapi.net/x/x-virality-api"

        api_key = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

        headers = {
            'Content-Type': 'application/json',
            "x-api-key": api_key
        }

        data = {
            "followers": 1000,
            "following": 300,
            "tweet": "Today is a good day."
        }
        
        # Convert the input to JSON format.
        json_data = json.dumps(data)
        # Make a POST request
        response = requests.post(api_url, headers=headers, data=json_data)

        # Check if the request was successful
        if response.status_code == 200:
            print("Success:", response.text)
        else:
            print("Error:", response.status_code, response.text)

        

Throttling limit

All API keys have the same level of throttling.

Usage Limit: 1000 calls per month.

Throttling Limit: 10 requests per second

Disclaimer

The algorithm is developed by the dataset provided in the "Viral Tweets Prediction Challenge." Although it contains a good amount of signals to develop a solid algorithm, it doesn't cover the whole population (i.e. gender, ethnicity, race, etc.). Hence, the response from API doesn't guarantee its accuracy.