API تبدیل عدد به کلمات فارسی

با استفاده از این API میتوانید اعداد را به معادل فارسی آنها تبدیل کنید. برای مثال:

5 -> پنج
63.5 -> شصت و سه و نیم
-25 -> منفی بیست و پنج
0.001 -> یک هزارم
10009 -> ده هزار و نه
6895 -> شش هزار و هشتصد و نود و پنج

هزینه هر درخواست: 0.01 توکن

نمونه خروجی:

{'ok': True, 'result': {'converted_word': 'دوازده هزار و سیصد و چهل و پنج', 'cost': 0.01}}

راهنما

  1. ابتدا اطلاعات احراز هویت خود را در لینک زیر، ایجاد کنید.
  2. با استفاده از مستندات زیر، API خود را ارسال کنید. می توانید از نمونه کد های ارائه شده نیز استفاده کنید.
  3. در نمونه کد ها، جای your_username و your_password را با اطلاعات احراز هویت واقعی خود جایگزین کنید.
  4. YOUR_BASE64_ENCODED_CREDENTIALS در نمونه cURL باید با رشته base64 شده از username:password جایگزین شود.

آدرس API

https://backendbaz.ir/api/number-to-perisan-words/convert

پارامترهای ورودی

نام نوع ضروری توضیحات
number integer بله عدد ورودی که قرار است به کلمه فارسی تبدیل شود

پارامترهای خروجی

نام نوع توضیحات
converted_word string متن خروجی و یا کلمه invalid در صورت بروز خطا
cost integer هزینه اجرای درخواست بر حسب توکن

نمونه کدها

curl

curl -X POST 
  https://backendbaz.ir/api/number-to-perisan-words/convert 
  -H 'Authorization: Basic YOUR_BASE64_ENCODED_CREDENTIALS' 
  -H 'Content-Type: application/json' 
  -d '{"number": 12345}'

php

<?php
$url = 'https://backendbaz.ir/api/number-to-perisan-words/convert';
$data = ['number' => 12345];
$username = 'your_username';
$password = 'your_password';

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Content-Type: application/json',
    'Authorization: Basic ' . base64_encode("$username:$password")
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
curl_close($ch);

echo $response;
?>

nodejs

const axios = require('axios');

const url = 'https://backendbaz.ir/api/number-to-perisan-words/convert';
const data = { number: 12345 };
const username = 'your_username';
const password = 'your_password';

axios.post(url, data, {
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Basic ' + Buffer.from(username + ':' + password).toString('base64')
  }
})
.then(response => console.log(response.data))
.catch(error => console.error(error));

python

import requests
import base64

url = "https://backendbaz.ir/api/number-to-perisan-words/convert"
data = {"number": 12345}
username = "your_username"
password = "your_password"

auth = base64.b64encode(f"{username}:{password}".encode()).decode()
headers = {
    "Content-Type": "application/json",
    "Authorization": f"Basic {auth}"
}

response = requests.post(url, json=data, headers=headers)
print(response.json())

wordpress

function convert_number_to_persian_words($number) {
    $url = 'https://backendbaz.ir/api/number-to-perisan-words/convert';
    $username = 'your_username';
    $password = 'your_password';
    
    $args = [
        'headers' => [
            'Content-Type' => 'application/json',
            'Authorization' => 'Basic ' . base64_encode($username . ':' . $password)
        ],
        'body' => json_encode(['number' => $number])
    ];
    
    $response = wp_remote_post($url, $args);
    
    if (is_wp_error($response)) {
        return false;
    }
    
    return json_decode(wp_remote_retrieve_body($response), true);
}

// Usage example:
$result = convert_number_to_persian_words(12345);
if ($result) {
    print_r($result);
}