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
- Sign up for a developer account. You can sign up for a developer account from the link.
- Once your request is approved, you will receive the welcome email with an api key enclosed.
- Submit the JSON input to the API via an API tool of your choice (i.e. Postman).
Call X Virality Prediction API from Postman
- Download Postman app. (https://www.postman.com/)
- Select 'POST' method.
- Type in API URL (https://www.bitgritapi.net/x/x-virality-api).
- In the “Authorization” pane, set 'Type' to 'API Key' and type in 'x-api-key' to Key and your API Key to 'Value' section.
- In 'Body' pane, choose 'raw' and enter the input in JSON format.
- 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.