Violence Detection API

Violence Detection API

Classifies images as violent or not. It predicts if images are depicting killing, shooting, blood and gore.
Free Plan $0.00 Monthly Subscribe
300 Requests / Monthly
Free for Lifetime
No Credit Card Required
MOST POPULAR
Starter Plan $24.99 Monthly Subscribe
10,000 Requests / Monthly
Standard Support
Pre-trained model
Ability to work on cartoons and hand drawings
Predicts if a gun is in shooting position or not
Fast and efficient
Pro Plan $69.99 Monthly Subscribe
30,000 Requests / Monthly
Standard Support
Pre-trained model
Ability to work on cartoons and hand drawings
Predicts if a gun is in shooting position or not
Fast and efficient
Custom Plan Volume Monthly Contact Us
Any requests volume you need
Pre-trained model
Ability to work on cartoons and hand drawings
Predicts if a gun is in shooting position or not
Fast and efficient
Violence Detection API Code Sample

Classifier computes a score on a 1 to 5 scale for the content passed to it. A score of 5 would mean that the content is most likely violence while a score close to 1 would imply the content is safe to be published. In most cases, value of 4 is safe to go.

Examples

Take the following example, with a kitchen knife. It is sharp and can be misused, but if you are not the onion on the table, it seems 100% harmless and our API is intelligent enough to differentiate this situation from opposite.

Knife on Table
Photo by Tree of Life Seeds on Unsplash

The response from the API is as expected.

{
  "description": "Very unlikely contains violence",
  "value": 1
}

Now, there is a lady holding a cleaver for a show or a similar occasion. She is laughing so we get the idea that she is joking. It shouldn't be taken that serious.

Joking with a knife
Image by Juergen_G from Pixabay

The response from the API is as expected. Still no violence, but value = 2 means, there may be some chance of a crime.

{
  "description": "Unlikely contains violence",
  "value": 2
}

Lastly, things are getting serious. The model wearing a pirate suite, is pointing the knife to the shutter with a shadowy face. So, this can be a sign for violence.

Pirate holding a knife
Image by Felix Lichtenfeld from Pixabay

The response from the API notes that this may be a possible violent picture.

{
  "description": "Possible violence",
  "value": 3
}

For obvious reasons, we can't give examples from more violent scenes; such as zombies, killings, blood and gore. You can subscribe to the service and try for yourself in the Live Demo section.

Use cases

This API is useful for apps containing direct messaging features, as they often monitor content as it comes in. Rather than reviewing all content manually, Violence Detection API lets you automate the content approval process.

This API also works for cartoon images containining violence

Violence Detection API Reference

This API is organized around REST. Our API has predictable resource-oriented URLs, accepts form-encoded request bodies, returns JSON-encoded responses, and uses standard HTTP response codes, authentication, and verbs.

Just Getting Started?

Check out our development quickstart guide.

Authentication

Violence Detection API uses API keys to authenticate requests. You can view and manage your API keys in the Accounts page.

Your API keys carry many privileges, so be sure to keep them secure! Do not share your secret API keys in publicly accessible areas such as GitHub, client-side code, and so forth.

All requests made to the API must hold a custom HTTP header named "apikey". Implementation differs with each programming language. Below are some samples.

All API requests must be made over HTTPS. Calls made over plain HTTP will fail. API requests without authentication will also fail.

Endpoints

Classifies the image on the URL as violence or not.

Parameters

url (required)

Location: Query, Data Type: string

** A word enclosed with curly brackets "{ }" in the code means that it is a parameter and it should be replaced with your own values when executing. (also overwriting the curly brackets).
Returns

Below is a sample response from the endpoint


If you wish to play around interactively with real values and run code, see...

Classifies the uploaded image as violence or not.

Parameters

body (required)

Location: Body, Data Type: file

** A word enclosed with curly brackets "{ }" in the code means that it is a parameter and it should be replaced with your own values when executing. (also overwriting the curly brackets).
Returns

Below is a sample response from the endpoint


If you wish to play around interactively with real values and run code, see...

Rate Limiting

Each subscription has its own rate limit. When you become a member, you start by choosing a rate limit that suits your usage needs. Do not worry; You can upgrade or downgrade your plan at any time. For this reason, instead of starting with a larger plan that you do not need, we can offer you to upgrade your plan after you start with "free" or "gold plan" options and start using the API.

When you reach a rate limit (both daily and monthly), the service will stop responding and returning the HTTP 429 response status code (Too many requests) for each request with the following JSON string body text.

{
"message":"You have exceeded your daily\/monthly API rate limit. Please review and upgrade your subscription plan at https:\/\/apilayer.com\/subscriptions to continue."
}

A reminder email will be sent to you when your API usage reaches both 80% and 90%, so that you can take immediate actions such as upgrading your plan in order to prevent your application using the API from being interrupted.

You can also programmatically check your rate limit yourself. As a result of each request made to the APILayer, the following 4 fields provide you with all the necessary information within the HTTP Headers.

x-ratelimit-limit-month: Request limit per month
x-ratelimit-remaining-month: Request limit remaining this month
x-ratelimit-limit-day: Request limit per day
x-ratelimit-remaining-day: Request limit remaining today

You can contact our support unit if you need any assistance with your application regarding to handle the returned result by looking at the header information.

Error Codes

APILayer uses standard HTTP response codes to indicate the success or failure of an API request. In general: Codes in the 2xx range indicate success. Codes in the 4xx range indicate a clientside error, which means that failed given the information provided (e.g., a missing parameter, unauthorized access etc.). Codes in the 5xx range indicate an error with APILayer's servers (normally this should'nt happen at all).

If the response code is not 200, it means the operation failed somehow and you may need to take an action accordingly. You can check the response (which will be in JSON format) for a field called 'message' that briefly explains the error reported.

Status Code Explanation
400 - Bad Request The request was unacceptable, often due to missing a required parameter.
401 - Unauthorized No valid API key provided.
404 - Not Found The requested resource doesn't exist.
429 - Too many requests API request limit exceeded. See section Rate Limiting for more info.
5xx - Server Error We have failed to process your request. (You can contact us anytime)

You can always contact for support and ask for more assistance. We'll be glad to assist you with building your product.