NewConnect Claude, Gemini, ChatGPT, and other AI agents to API Ninjas via our MCP server

Face Detect API

The Face Detect API uses state of the art computer vision algorithms to accurately and efficiently detect faces in images.

(4.7)

From 9,332 users

2,600+

Applications using this API

API Status

Online - All Systems Operational

API Response Times

Average
P50
P75
P90
P95
412ms457ms459ms725ms1228ms

Didn't find what you were looking for? Suggest an improvement


/v1/facedetect POST

https://api.api-ninjas.com/v1/facedetect

Given an input image, returns a list containing all detected faces in the form of bounding boxes.

Files

  • image  required

    Image file containing faces. Must be either JPEG or PNG format.

Headers

  • X-Api-Key  required

    API Key associated with your account.

Response

A JSON array of objects, each containing the following fields, or an error if the request is unsuccessful.

  • x

    The x-coordinate of the top-left corner of the bounding box.

  • y

    The y-coordinate of the top-left corner of the bounding box.

  • width

    Width of the bounding box in pixels.

  • height

    Height of the bounding box in pixels.

Sample Request Live Demo!

Try our APIs in the API playground

Sign up for a free API key to get started — no credit card required.

https://api.api-ninjas.com/v1/facedetect

Headers

X-Api-KeyLog in or sign up to get your API Key

Sample Response

JSON
{}

Code Examples

1 2 3 curl -X POST "https://api.api-ninjas.com/v1/facedetect" \ -H "X-Api-Key: YOUR_API_KEY" \ -F "image=@YOUR_IMAGE.jpeg"

If your programming language is not listed in the Code Example above, you can still make API calls by using a HTTP request library written in your programming language and following the above documentation.

Frequently Asked Questions

  • Yes, but you must have a premium subscription. Commercial use of the Face Detect API is not permitted on the free tier. See our pricing page to choose a plan that fits your needs.
  • Sign up for a free account to instantly get your API key, then pass it in the X-Api-Key header on every request. The documentation above includes ready-to-run examples in cURL, Python, JavaScript, Node.js, and more.
  • Your API requests will simply be denied once you hit your monthly quota — you will never be charged more than the plan you signed up for. To increase your quota, you can upgrade your plan any time on our pricing page.
  • The API responds with a standard HTTP status code and a JSON error message describing the problem. See our error codes reference for the full list of codes and how to resolve each one, or contact support if you need help.
  • The Face Detect API uses state of the art computer vision algorithms to locate faces in images, making it useful for photo tagging, headcount and attendance applications, blurring or redacting faces for privacy, and as a preprocessing step before cropping or recognition. For detecting non-face objects you can pair it with the Object Detection API.
  • Send a POST request to the /v1/facedetect endpoint with the image uploaded as multipart form-data in the image file field, which must be in JPEG or PNG format. See the API documentation for code samples in cURL, Python, and JavaScript.
  • The API returns a JSON array of objects, one per detected face, where each object gives the bounding box with x and y for the top-left corner and width and height in pixels. If the request is unsuccessful you will receive an error instead, as described in the error codes reference.
  • No, the Face Detect API only returns bounding boxes for faces and does not read any text or characters from the image. To extract text from an image, use the Image to Text API instead.