Closed goddess1992 closed 1 year ago
Hi, You can use set_config. How to use set_config and other methods is as follows:
POST: /account/login
Request:
{
'username_or_phone_or_email': "uuupppeee",
'password': "xxxxxx",
}
Response (200):
{
'message': "Successfully logged in.",
'user': {
'id': "user's UUID",
'token': "user's auth-token",
'username': "username",
'phone': "989123456789",
'email': "xxxxxx@yyyy.zzz",
'is_staff': bool,
'is_telegram_user': bool,
'nevisa_service_account': {...} // like "Retrieve Account"
}
}
NOTE: The authentication token changes every time the user logs in.
POST: /account/forgot_password
Request:
{
'username': "username",
'phone': "989123456789",
'email': "xxxxxx@yyyy.zzz",
}
NOTE: there should be either ‘phone’ or ‘email’ in request data (never put both pf them!)
Response (200):
{
'message': "Account is successfully verified. Check your phone/email.",
'user': {
'id': "user's UUID",
'username': "username",
'phone': "989123456789",
'email': "xxxxxx@yyyy.zzz",
}
}
NOTE: Then, if everything’s OK, a 6-digit verification code will be sent to user’s phone/email. Then, in the next page user has to enter the verification code and change his password. (see: Change Forgotten Password)
POST: /account/change_forgotten_password
Request:
{
'id': "user's UUID",
'otp': "oooooo",
'password': "xxxxxxxx",
'password_confirmation': "xxxxxxxx",
}
Response (200):
{
'message': "Password successfully changed.",
'user': {
'id': "user's UUID",
'username': "username",
'phone': "989123456789",
'email': "xxxxxx@yyyy.zzz",
'token': "User's auth-token",
}
}
NOTE: Then, if everything’s OK, the password will be changed.
POST: /account/logout
Request:
{
'id': "user's UUID",
}
Response (200):
{
'message': "Logged out successfully.",
}
NOTE: The authentication token changes every time the user logs in.
GET: /account/retrieve
Response (200):
{
'token': "user's auth token",
'id': "user's UUID",
'username': "username",
'phone': "989123456789",
'email: "xxxxxx@yyyyy.zzz",
'date_joined': "datetime",
'last_login': "datetime",
'is_active': bool,
'is_staff': bool,
'is_telegram_user': bool,
'nevisa_service_account': {
'current_charge': 0,
'usage_remained': 0,
'num_service_history': 0,
'has_service': bool,
'configuration': {
'convert_punctuations': bool,
'show_word_confidences': bool,
},
'current_service_record': {
'id': "UUID",
'start_time': datetime,
'end_time': datetime,
'key': "API KEY",
'service': {
'id': "UUID",
'name': "name",
'code': 1,
'deadline': 30,
'price_per_hour' : 10000,
'hour_limit': 30,
'max_users': 2,
'actual_price': 300000,
},
}
},
}
GET: /nevisa/get_services
Response (200): returns a list of all services (packages) available to purchase
[
{
'id': "UUID",
'name': "name",
'code': 1,
'deadline': datetime,
'price_per_hour': 1000,
'hour_limit': 20,
'max_users': 2,
'actual_price': 1000,
'is_for_telegram': bool, # True: the service is for telegram users
},
{
'id': "UUID",
...
},
...
]
GET: /nevisa/transactions/retrieve_all
Response (200): returns a list of all transactions ordered by their creation date; newest first.
[
{
'user': "user's UUID",
'amount': "amount", # Tomans
'description': "description",
'created_at': "creation datetime",
'verified_at': "verification datetime", # nullable
'status': "PENDING / FAILED / SUCCESS",
'is_test': bool, # no need to show this field
},
{
'user': "user's UUID",
...
},
...
]
POST: /nevisa/buy_service
Request:
{
'service_id': "service's UUID",
}
Response (200):
{
'message': "The service is successfully bought.",
'service_record': {
'id': "UUID",
'start_time': datetime,
'end_time': datetime,
'service': {
'id': "UUID",
'name': "name",
'code': 1,
'deadline': datetime,
'price_per_hour': 1000,
'hour_limit': 20,
'max_users': 2,
'actual_price': 1000,
},
}
}
NOTE: if the user’s already got an active service or he doesn’t have enough charge in his wallet, a corresponding error will be returned.
POST: /nevisa/reserve_service
Request:
{
'service_id': "service's UUID",
}
Response (200):
{
'message': "The service is successfully reserved.",
'service_record': {
'id': "UUID",
'start_time': datetime,
'end_time': datetime,
'service': {
'id': "UUID",
'name': "name",
'code': 1,
'deadline': datetime,
'price_per_hour': 1000,
'hour_limit': 20,
'max_users': 2,
'actual_price': 1000,
},
}
}
NOTE: if the user’s doesn’t have an active service or he doesn’t have enough charge in his wallet, a corresponding error will be returned.
PUT: /nevisa/set_config
Request:
{
'add_number_separator': bool,
'convert_numbers': bool,
'convert_punctuations': bool,
'show_digits_in_english': bool,
'show_word_confidences': bool,
}
Response (200):
{
"id": "UUID",
"service_account": int,
"show_word_confidences": bool,
"telegram_english": bool,
"save_transcriptions": bool,
"convert_punctuations": bool,
"convert_numbers": bool,
"show_digits_in_english": bool,
"add_number_separator": bool,
}
POST: /nevisa/check_account
Request:
{
'key': "api-key"
}
Response (200):
{
'usage_remained': 10000, // ms
'has_reserved': bool, // True: the user has a reserved service
'usage_with_reserved': 12000, // ms: the current usage + reserved usage
'configuration': {
'convert_punctuations': bool,
'show_word_confidences': bool,
},
}
NOTE: The response status code will be HTTP_401_UNAUTHORIZED if the token (sent in the header) is not valid; otherwise, the status code will be HTTP_200_OK.
POST: /nevisa/use
Request:
{
'key': "api-key",
'usage_amount': 10000 # in milliseconds (ms)
}
Response (200):
{
'usage_remained': 5000 # in milliseconds (ms)
}
NOTE: The response status code will be HTTP_401_UNAUTHORIZED if the token (sent in the header) is not valid; otherwise, if the usage amount is valid, the status code will be HTTP_200_OK.
URL: /charge/buy_charge
Authentication token: required
Request:
{
'amount': 1000, # in Tomans
}
Response (200):
{
'redirect_url': "url to redirect"
# the url is something like "https://www.zarinpal.com/pg/StartPay/..."
}
NOTE: Then, the user should be redirected to the page where he should pay the price. (Zarinpal) After the payment is done, the user will be redirected to a page where the payment result is shown.
thanks for your response, unfortunately i get 404 error with this command
thanks for your response, unfortunately i get 404 error with this command
Request URL: https://accounting.persianspeech.com/nevisa/set_config Request Method: PUT
PUT: /nevisa/set_config
Request:
{
'add_number_separator': bool,
'convert_numbers': bool,
'convert_punctuations': bool,
'show_digits_in_english': bool,
'show_word_confidences': bool,
}
Response (200):
{
"id": "UUID",
"service_account": int,
"show_word_confidences": bool,
"telegram_english": bool,
"save_transcriptions": bool,
"convert_punctuations": bool,
"convert_numbers": bool,
"show_digits_in_english": bool,
"add_number_separator": bool,
}
thanks for your response, unfortunately i get 404 error with this command
First get token from login method then use token in header of your request as follows:
import requests
LOGIN_API_URL = "https://accounting.persianspeech.com/account/login"
SET_CONFIG_API_URL = "https://accounting.persianspeech.com/nevisa/set_config"
# 1. Login --------------------------------------
json_data = {
'username_or_phone_or_email': "", # Your username
'password': "", # Your password
}
response = requests.post(LOGIN_API_URL, data=json_data)
result = 'Success' if response.status_code == 200 else 'Failure'
print(f"login result: {result}", response.json(), sep='\n')
if result == 'Failure':
exit()
auth_token = response.json()['user']['token']
# 2. Set Configuration --------------------------------------
json_data = {
'add_number_separator': False,
'convert_numbers': True,
'convert_punctuations': False,
'show_digits_in_english': True,
'show_word_confidences': False,
}
headers = {'Authorization': f"Token {auth_token}"}
response = requests.put(SET_CONFIG_API_URL, data=json_data, headers=headers)
result = 'Success' if response.status_code == 200 else 'Failure'
if result == 'Failure':
exit()
print(f"set_config result: {result}", response.json(), sep='\n')
thanks ,it worked. but i don't get numeric result , here is an example: I required for this:
'ميخوام عدد 123 و عدد 5405 نشان بدي'
but this is what I get: 'ميخوام عدد صد و بيست و سه و عدد پنجاه و چهار هزار و پنج نشان بدي'
thanks ,it worked. but i don't get numeric result , here is an example: I required for this:
'ميخوام عدد 123 و عدد 5405 نشان بدي'
but this is what I get: 'ميخوام عدد صد و بيست و سه و عدد پنجاه و چهار هزار و پنج نشان بدي'
The conversion of numerical text is currently implemented on the front side. You can use the following library to convert Persian numbers in Python: https://github.com/nevisa-team/w2ni18n/tree/master/python
thank you, I'll check it.
I am using Nevisa API and need to extract numerical information from persian text. I checked the nevisa-live in persianspeech having this capability,but no information was provided about it for API. would u please help?