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

Password Generator API

The Password Generator API auto-generates random passwords that are incredibly hard to guess.

(4.3)

From 2,203 users

2,100+

Applications using this API

API Status

Online - All Systems Operational

API Response Times

Average
P50
P75
P90
P95
201ms242ms292ms477ms1090ms

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


/v1/passwordgenerator GET

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

Returns a random password string adhering to the specified parameters.

Parameters

  • length  optional

    Length of password in characters. If not set, a default value of 16 is used.

  • exclude_numbers  optionalpremium only

    Whether to exclude numbers from the password. Must be either true or false. If not set, a default value of false will be used.

  • exclude_special_chars  optionalpremium only

    Whether to exclude special characters(!@#$%^&*()) from the password. Must be either true or false. If not set, a default value of false will be used.

Headers

  • X-Api-Key  required

    API Key associated with your account.

Response

A JSON object with the following fields or an error if the request is unsuccessful.

  • random_password

    The generated random password string.

Sample Request Live Demo!

length
exclude_numbers premium
exclude_special_chars premium

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/passwordgenerator?length=16

Headers

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

Sample Response

JSON
{
    random_password:"nYs43u5f1oGK9*g5"
}

Code Examples

1 2 curl -X GET "https://api.api-ninjas.com/v1/passwordgenerator?length=12&uppercase=true&lowercase=true&numbers=true&special=true" \ -H "X-Api-Key: YOUR_API_KEY"

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 Password Generator 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.
  • Pass the length query parameter to the /v1/passwordgenerator endpoint to set the number of characters; if you omit it, a default length of 16 is used. See the full API documentation for details.
  • Yes, set the exclude_numbers and exclude_special_chars parameters to true to remove digits or special characters (!@#$%^&*()) from the output, though both are premium-only features available on a paid plan. By default both are false.
  • A successful request returns a JSON object with a single random_password field containing the generated password string, for example nYs43u5f1oGK9*g5. If a request fails, you instead receive an error.
  • It is ideal for creating strong, hard-to-guess passwords during account sign-up flows, resetting credentials, or seeding test data, and it pairs well with related tools like the Random User API and Random Word API for generating mock accounts.