> ## Documentation Index
> Fetch the complete documentation index at: https://jigsaw-13.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# NSFW

> Quickly detect nudity, violence, hentai, porn and more NSFW content in images.

### Body

**url** `string`

The image url.

**file\_store\_key** `string`

The key used to store the image on Jigsawstack file. Learn more about how to handle files in Jigsawstack's [Handling Files](https://jigsaw-13.mintlify.site/docs/api-reference/handling-files.md) section.

<Snippet file="header.mdx" />

### Response

**success** `boolean`

Indicates whether the call was successful.

**\_usage** `object`

Usage information for the API call.

**\_usage**

**input\_tokens** `number`

Number of input tokens processed.

**output\_tokens** `number`

Number of output tokens generated.

**inference\_time\_tokens** `number`

Number of tokens processed during inference time.

**total\_tokens** `number`

Total number of tokens used (input + output).

**log\_id** `string`

A unique identifier for the request

**nsfw** `boolean`

Indicates whether NSFW content was detected in the image.

**nudity** `boolean`

Indicates whether nudity was detected in the image.

**gore** `boolean`

Indicates whether gore/violence was detected in the image.

**nsfw\_score** `number`

Confidence score for NSFW content detection (0-1 scale).

**nudity\_score** `number`

Confidence score for nudity detection (0-1 scale).

**gore\_score** `number`

Confidence score for gore/violence detection (0-1 scale).

```javascript Javascript theme={null}
import { JigsawStack } from "jigsawstack";

const jigsaw = JigsawStack({ apiKey: "your-api-key" });

const response = await jigsaw.validate.nsfw({
  "url": "https://jigsawstack.com/preview/nsfw-example.jpg"
})
```

```python Python theme={null}
from jigsawstack import JigsawStack

jigsaw = JigsawStack(api_key="your-api-key")

response = jigsaw.validate.nsfw({
  "url": "https://jigsawstack.com/preview/nsfw-example.jpg"
})
```

```bash Curl theme={null}
curl https://api.jigsawstack.com/v1/validate/nsfw \
-X POST \
-H 'Content-Type: application/json' \
-H 'x-api-key: your-api-key' \
-d '{"url":"https://jigsawstack.com/preview/nsfw-example.jpg"}'
```

```php PHP theme={null}
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.jigsawstack.com/v1/validate/nsfw');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'x-api-key: your-api-key',
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, '{"url":"https://jigsawstack.com/preview/nsfw-example.jpg"}');

$response = curl_exec($ch);

curl_close($ch);

```

```ruby Ruby theme={null}
require 'net/http'
require 'json'

uri = URI('https://api.jigsawstack.com/v1/validate/nsfw')
req = Net::HTTP::Post.new(uri)
req.content_type = 'application/json'
req['x-api-key'] = 'your-api-key'

req.body = {
'url' => 'https://jigsawstack.com/preview/nsfw-example.jpg'
}.to_json

req_options = {
use_ssl: uri.scheme == 'https'
}
res = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
http.request(req)
end

```

```go Go theme={null}
package main

import (
"fmt"
"io"
"log"
"net/http"
"strings"
)

func main() {
client := &http.Client{}
var data = strings.NewReader(`{"url":"https://jigsawstack.com/preview/nsfw-example.jpg"}`)
req, err := http.NewRequest("POST", "https://api.jigsawstack.com/v1/validate/nsfw", data)
if err != nil {
	log.Fatal(err)
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("x-api-key", "your-api-key")
resp, err := client.Do(req)
if err != nil {
	log.Fatal(err)
}
defer resp.Body.Close()
bodyText, err := io.ReadAll(resp.Body)
if err != nil {
	log.Fatal(err)
}
fmt.Printf("%s\n", bodyText)
}

```

```java Java theme={null}
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpRequest.BodyPublishers;
import java.net.http.HttpResponse;

HttpClient client = HttpClient.newHttpClient();

HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.jigsawstack.com/v1/validate/nsfw"))
.POST(BodyPublishers.ofString("{\"url\":\"https://jigsawstack.com/preview/nsfw-example.jpg\"}"))
.setHeader("Content-Type", "application/json")
.setHeader("x-api-key", "your-api-key")
.build();

HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());

```

```swift Swift theme={null}
import Foundation

let jsonData = [
"url": "https://jigsawstack.com/preview/nsfw-example.jpg"
] as [String : Any]
let data = try! JSONSerialization.data(withJSONObject: jsonData, options: [])

let url = URL(string: "https://api.jigsawstack.com/v1/validate/nsfw")!
let headers = [
"Content-Type": "application/json",
"x-api-key": "your-api-key"
]

var request = URLRequest(url: url)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = data as Data

let task = URLSession.shared.dataTask(with: request) { (data, response, error) in
if let error = error {
    print(error)
} else if let data = data {
    let str = String(data: data, encoding: .utf8)
    print(str ?? "")
}
}

task.resume()

```

```dart Dart theme={null}
import 'package:http/http.dart' as http;

void main() async {
final headers = {
'Content-Type': 'application/json',
'x-api-key': 'your-api-key',
};

final data = '{"url":"https://jigsawstack.com/preview/nsfw-example.jpg"}';

final url = Uri.parse('https://api.jigsawstack.com/v1/validate/nsfw');

final res = await http.post(url, headers: headers, body: data);
final status = res.statusCode;
if (status != 200) throw Exception('http.post error: statusCode= $status');

print(res.body);
}

```

```kotlin Kotlin theme={null}
import java.io.IOException
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.RequestBody.Companion.toRequestBody

val client = OkHttpClient()

val MEDIA_TYPE = "application/json".toMediaType()

val requestBody = "{\"url\":\"https://jigsawstack.com/preview/nsfw-example.jpg\"}"

val request = Request.Builder()
.url("https://api.jigsawstack.com/v1/validate/nsfw")
.post(requestBody.toRequestBody(MEDIA_TYPE))
.header("Content-Type", "application/json")
.header("x-api-key", "your-api-key")
.build()

client.newCall(request).execute().use { response ->
if (!response.isSuccessful) throw IOException("Unexpected code $response")
response.body!!.string()
}

```

```csharp C# theme={null}
using System.Net.Http.Headers;
using System.Net.Http.Json;

HttpClient client = new HttpClient();

HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "https://api.jigsawstack.com/v1/validate/nsfw");
request.Headers.Add("x-api-key", "your-api-key");
request.Content = JsonContent.Create(new
{
url = "https://jigsawstack.com/preview/nsfw-example.jpg"
});
request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");

HttpResponseMessage response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();

Console.WriteLine(responseBody);
```

```json Response theme={null}
{
  "success": true,
  "nsfw": false,
  "nudity": false,
  "gore": false,
  "nsfw_score": 0.8223792436143141,
  "nudity_score": 0.08542560786008835,
  "gore_score": 0.0015945120248943567,
  "_usage": {
        "input_tokens": 15,
        "output_tokens": 60,
        "inference_time_tokens": 275,
        "total_tokens": 350
  }
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.