Ninjapay API Docs
  • Namaste
    • ℹ️Welcome to Ninjapay!
    • 🏆Benefits of NinjapayAPI
    • 🛠️Fees & Limit
  • How to
    • ❓How Plugins Work
    • 👨‍💻Getting Started
    • 🔐Authentication
    • 💻API Reference (UPI)
      • 🧩Plugins
        • 🔗Realtime Payment Links
          • Create Realtime Payment Link
          • Create Template
          • List Payment Links
          • Multi super order Id list
          • Get templates
          • Single order Id trx list
          • Generate Upi payment link
          • Record payment
          • Expiry List
          • Delete Payment Link
          • Delete Template
          • Check Payment
        • 🛡️Paywalls
          • Create Paywall
          • Create Paywall QR
          • List Paywalls
          • Detail Paywall
          • Check Paywall
          • Remove Paywall
        • 📄Invoice
          • Add Client
          • Edit Client
          • Get Client
          • Remove Client
          • Add Product
          • Edit Product
          • Get Products
          • Remove Product
          • Upload Attachment
          • Add/Edit Template
          • Create Invoice
          • Get Invoice by ID
          • Add Tracking Details
          • Remove Invoice
        • 🖥️Point of Sale - POS
          • Create POS
          • Create Paywall QR
          • List Paywalls
          • Detail Paywall
          • Check Paywall
          • Remove POS
        • 👨‍💻Build Your Own Plugin
          • Ninjapay Plugin Development Guide
      • Error Handling
      • Limits on API Requests
    • 💻API Reference (P2P)
      • 🧩Plugins
        • 🔗Payment Links (P2P)
          • Dashboard Stats
          • Create Payment Link
          • Submit UTR for Approval
          • List Payment Links
          • Transactions
          • Approve/Decline
          • Check Payment
        • 🛡️Paywalls
          • Create Paywall
          • Create Paywall QR
          • List Paywalls
          • Detail Paywall
          • Check Paywall
          • Remove Paywall
        • 👨‍💻Build Your Own Plugin
          • Ninjapay Plugin Development Guide
      • Error Handling
      • Limits on API Requests
    • 💻API Reference (BTC⚡️)
      • Wallet Info
      • Send Payment
      • Request Payment
      • NinjaAuth
      • Ninjapay URI Intent
      • Check Payment
      • Transactions
      • Get Prices
      • Decode Invoice
      • Error Handling
      • Limits on API Requests
      • 🎁Withdraw Vouchers
        • Request Voucher
        • Check Voucher
        • Revoke Voucher Request
        • Redeem Voucher
      • 📈Spot Trade
        • Asset Balances
        • Asset Prices
        • Buy/Sell
        • Check Order
        • Revoke Order Request
  • other
    • 🤝Partnerships
    • 📓Helpful references
  • Use Cases
    • Game Developers
      • Implementing BTC Points
  • Coming Soon
    • 💻API Reference (Pro)
      • Wallet Info
      • Send Payment
      • Request Payment
      • NinjaAuth
      • Ninjapay URI Intent
      • Check Payment
      • Transactions
      • Get Prices
      • Decode Invoice
      • Error Handling
      • Limits on API Requests
    • 🧩Widget Integration
      • Widget (Onramp)
      • Widget (Offramp)
      • Request Token
      • Check Token
  • Fiat x Web3 Bridge
    • ℹ️Intro to NinjaUPI
    • 👩‍💻Get Started
      • Request Quote ID (BTC<>INR)
      • Request Quote ID (USDT<>INR)
      • Request Invoice for Quote
      • Check Payment
    • 🦸Upgrades
  • Protocols
    • Commerce Onchain Protocol
Powered by GitBook
On this page
  1. How to
  2. API Reference (BTC⚡️)

NinjaAuth

Request the user's Ninjapay account verification. This can be used for authentication or linking of user's wallet. Using NinjaAuth is an easy and convenient way for users to log into and grant data access to your apps and games across multiple platforms.

Step1: Method


POST https://api.ninjapay.me/api/v1/auth

Parameters


Body (application/json)
 {
  ninjatag: <string>; // sends a six digit OTP to the linked account email
  kyc?: <bool> // Add <true> if you want the user's kyc in response (only given if user approves)
}

Response


{
    "status": <bool>,
    "data": {
        "secret": <string> // Use this secret along with OTP sent to user's email/phone to verify in the next step, this secret is expires after 60 seconds
    },
    "message": <string>
}

Step2: Method


POST https://api.ninjapay.me/api/v1/auth/verify

Parameters


{
  "secret": <string>, // secret from previous response
  "otp": <int> // OTP is sent to user's linked account email 
}

Response

{
    "status": true, //bool
       "data": {
        "user_id": "Mlsqm72edi9NOMnMDSpMKactuRw49",
        "ninjatag": "ninja",
        "profile": {
            "full_name": "satoshi nakamoto",
            "email": "sample@sample.com",
            "phone": "+917995232267",
            "country": "INDIA"
        },
        "kyc_level": 1,
        "kyc_status": "",
        "is_verified": true,
        "id_type": "",
        "personal_kyc": {
            "id1": "https://useridfile.com",
            "id2": "https://useridfile.com",
            "id3": "https://useridfile.com"
        },   
        "company_kyc": {
            "company_name": "satoshi nakamoto",
            "email": "sample@sample.com",
            "company_phone": "+917995232267",
            "country": "UAE",
            "doc1": "https://userdocfile.com",
            "doc2": "https://userdocfile.com",
            "doc3": "https://userdocfile.com",
            "doc4": "https://userdocfile.com"
        },
       "message": "Here is user data"
}

Code Example

// Declare a function for the first step
async function initiateVerification(ninjatag) {
  const accountVerificationOptions = {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'x-api-key': 'API_KEY'
    },
    body: JSON.stringify({
      "ninjatag": ninjatag,
      "kyc": true
    })
  };

  const response = await fetch('https://prod.ninjapay.me/api/v1/auth', accountVerificationOptions);
  const data = await response.json();

  return data.secret;
}

// Declare a function for the second step
async function verifyAccount(secret, OTP) {
  const verifyOptions = {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'x-api-key': 'API_KEY'
    },
    body: JSON.stringify({
      "secret": secret,
      "otp": OTP
    })
  };

  const response = await fetch('https://api.ninjapay.me/api/v1/auth/verify', verifyOptions);
  const data = await response.json();

  return data;
}

// Example of how to use these functions
async function authenticateUser(ninjatag) {
  try {
    const secret = await initiateVerification(ninjatag);

    // Here you would pause and wait for the user to provide the OTP from their email
    const OTP = prompt("Please enter the OTP you received via email");

    const verificationResult = await verifyAccount(secret, OTP);

    console.log(verificationResult);
  } catch (error) {
    console.error(error);
  }
}

// Call the function
authenticateUser("nakamoto");

PreviousRequest PaymentNextNinjapay URI Intent

Last updated 1 year ago

💻