Using scalable, real-time media rating APIs, Masala AI offers highly accurate and economical detection of:
To use any of the Masala.AI APIs, choose a subscription plan or try our services for free by signing up.
Upon successful sign-up, you will be directed to your subscription account page where you can locate your API access secret key which you will be using to issue requests to the Media Rating APIs.
Media Rating API endpoints currently accept POST requests with a JSON input payload containing public resource URL, image encoded as string in Base64 format and text segments. For more on the access of the endpoints, refer to the API Documentation.
The first API endpoint request would load necessary resources to be able to handle the successive requests. Particularly for the requests issued to resource intensive image rating endpoints, the initialization process can take up to 40 seconds returning a response which indicates the initialization status.
Status: 202 Accepted Initializing API access...
Below code segment illustrates handling of such initial response:
import json import requests import base64 vrate_api = "https://apisub.masala.one/v2/mediaratingb" vrate_headers = {'X-Masala-APIKey':'XXXXXXXXXXXXX','Content-Type':'application/json'} payload_data = "b'XXXXXXXXXX'" #Binary image data def rate_image(payload_data): vrate_payload = json.dumps({"payload":payload_data}) response = requests.post(vrate_api,headers=vrate_headers,data=vrate_payload) if response.status_code == 202: # If a response code of 202 is returned after 40 seconds, re-issue the request. print("Re-sending request...") result = rate_image(payload_data) else: result = response.content return result