Yeti API Reference


#1

Hello,

I want to develop a Customer Panel on Yeti for the customers to view their Account Balance / Rates and CDR’s.
Is there any API document i can refer to so i can achieve this or is has already been implemented ?


#2

We have JSON API especially for this:

https://demo.yeti-switch.org/doc/api/customer/v1/index.html

Authorization performed on Yeti side, so you can create thin browser-based application on js.


#3

Thank you, i will try this and update.
If i can successfully develop a customer panel then i’ll share the code.
Also any suggestions on creating a reseller ?


#4

Where do i find the Authorization key ?


#5

We are using JWT

https://demo.yeti-switch.org/doc/api/customer/v1/authentication/get_token.html

describes how to get token.


#6

Understood.
Thank you.
Please close this thread.


#7

I am receiving error while fetching the Token from Postman.

as mentioned in the DOC, there is no path " /api/rest/customer/v1/auth" in my yeti-web directory.


#8

/app/controllers…/ is wrong path. You should use /api/rest/customer/v1/auth

as mentioned in the DOC, there is no path " /api/rest/customer/v1/auth" in my yeti-web directory.

URLs are not related to directory structure.


#9

default nginx configuration contains:

server {
        listen 127.0.0.1:6666;

...

     location /api/rest/customer {
                allow 127.0.0.1;
                deny all;

You have to edit this configuration to allow connections from your IPs


#10

Hi,

I have added the IP in the nginx configuration and still cannot get the API token. Am i using the postman post correctly ?


#11

I have added the IP in the nginx configuration

Your nginx configuration still wrong.


#12

post your nginx configuration


#13

Please find the Below Nginx Config

upstream ts {
        server 127.0.0.1:80;
}
upstream ds {
        server 127.0.0.1:80;
}

upstream yeti-unicorn {
        server unix:/run/yeti/yeti-unicorn.sock;
}

#server {
#        listen 80;
#        server_name localhost;
#        root /home/yeti-web;
#        access_log /var/log/nginx/yeti-web.access.log;
#        location / {
#                rewrite ^/(.*) https://localhost$request_uri? permanent;
#        }
#}

server {
	listen 127.0.0.1:6666;
	server_name _;

	proxy_redirect off;
	proxy_set_header Host $host;
	proxy_set_header X-Proxy-Port $proxy_port;
	proxy_set_header X-Real-IP $remote_addr;
	proxy_set_header X-Forwarded-For $remote_addr;
	proxy_set_header HTTP_CLIENT_IP $remote_addr;
	proxy_set_header HTTP_X_FORWARDED_FOR $remote_addr;
	client_max_body_size        100m;
	client_body_buffer_size     128k;
	proxy_connect_timeout       100;
	proxy_send_timeout          20000;
	proxy_read_timeout          20000;
	proxy_buffer_size           32k;
	proxy_buffers               8 32k;
	proxy_busy_buffers_size     64k;
	proxy_temp_file_write_size  640k;

	allow 127.0.0.1;
	deny all;

	location /api/rest/system/jobs {
        	allow 127.0.0.1;
	    	deny all;
		proxy_pass  http://yeti-unicorn;
	}
	
	location /api/rest/system {
 		allow 127.0.0.1;
		deny all;
		proxy_pass  http://yeti-unicorn;
	}

	location /api/rest/admin {
		allow 127.0.0.1;
		deny all;
		proxy_pass  http://yeti-unicorn;

		if ($request_method = 'OPTIONS') {
			add_header 'Access-Control-Allow-Origin' '*';
			add_header 'Access-Control-Allow-Headers' 'Origin, X-Requested-With, Content-Type, Accept, api_key, Authorization';
			add_header 'Access-Control-Allow-Methods' 'GET, POST, DELETE, PUT, PATCH, OPTIONS';
			add_header 'Access-Control-Max-Age' 1728000;
			add_header 'Content-Type' 'text/plain charset=UTF-8';
			add_header 'Content-Length' 0;
			return 204;
		}
		add_header 'Access-Control-Allow-Origin' '*';
		add_header 'Access-Control-Allow-Headers' 'Origin, X-Requested-With, Content-Type, Accept, api_key, Authorization';
		add_header 'Access-Control-Allow-Methods' 'GET, POST, DELETE, PUT, PATCH, OPTIONS';
		add_header 'Access-Control-Allow-Credentials' 'true';

        }

        location /api/rest/customer {
                allow 127.0.0.1;
                allow 122.177.66.69;
		deny all;
                proxy_pass  http://yeti-unicorn;

                if ($request_method = 'OPTIONS') {
                        add_header 'Access-Control-Allow-Origin' '*';
                        add_header 'Access-Control-Allow-Headers' 'Origin, X-Requested-With, Content-Type, Accept, api_key, Authorization';
                        add_header 'Access-Control-Allow-Methods' 'GET, POST, DELETE, PUT, PATCH, OPTIONS';
                        add_header 'Access-Control-Max-Age' 1728000;
                        add_header 'Content-Type' 'text/plain charset=UTF-8';
                        add_header 'Content-Length' 0;
                        return 204;
                }
                add_header 'Access-Control-Allow-Origin' '*';
                add_header 'Access-Control-Allow-Headers' 'Origin, X-Requested-With, Content-Type, Accept, api_key, Authorization';
                add_header 'Access-Control-Allow-Methods' 'GET, POST, DELETE, PUT, PATCH, OPTIONS';
                add_header 'Access-Control-Allow-Credentials' 'true';

        }

}


server {
#       listen 443;
        listen 80;
        server_name _;

#        ssl on;
#        ssl_certificate /etc/nginx/ssl/localhost.crt;
#        ssl_certificate_key /etc/nginx/ssl/localhost.key;
#        ssl_session_timeout 50m;
#        ssl_session_cache builtin:1000;
#        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;# SSLv3;
#        ssl_ciphers  ECDHE-RSA-AES256-SHA384:AES256-SHA256:RC4:HIGH:!MD5:!aNULL:!eNULL:!NULL:!DH:!EDH:!AESGCM;
#        add_header Strict-Transport-Security "max-age=31536000; includeSubdomains";
#        ssl_prefer_server_ciphers   on;


        access_log /var/log/nginx/yeti-web.access.log;

        location ~* /\.ht {
                deny  all;
        }
        location ~ /.svn {
                deny all;
        }
        location ~ /.git {
                deny all;
        }
        location /favicon.ico {
                deny all;
        }
        location /assets {
                root /home/yeti-web/public;
                expires 5h;
        }
	location /swagger {
                expires 5h;
	}

        location /doc {
                root /home/yeti-web;
        	try_files $uri $uri/index.html /doc/index.html;
	}

        location /images {
                root /home/yeti-web/public;
                expires 5h;
        }
        root /home/yeti-web/public;
	
	location /api/ {
		        deny all;
        }


        location / {
                proxy_pass  http://yeti-unicorn;
                proxy_redirect off;
                proxy_set_header Host $host;
                proxy_set_header X-Proxy-Port $proxy_port;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $remote_addr;
                proxy_set_header HTTP_CLIENT_IP $remote_addr;
                proxy_set_header HTTP_X_FORWARDED_FOR $remote_addr;
                client_max_body_size        100m;
                client_body_buffer_size     128k;
                proxy_connect_timeout       100;
                proxy_send_timeout          20000;
                proxy_read_timeout          20000;
                proxy_buffer_size           32k;
                proxy_buffers               8 32k;
                proxy_busy_buffers_size     64k;
                proxy_temp_file_write_size  640k;
        }

        location ~ ^/dump/(.*)$ {
                internal;
                set $filename $1;
                proxy_hide_header Content-Disposition;
                add_header Content-Disposition 'attachment; filename="$filename"';
		root /var/spool/sems;
#                proxy_pass http://ts;
#                proxy_next_upstream http_404;
#                proxy_redirect off;
#                proxy_set_header Host $host;
#                proxy_set_header X-Proxy-Port $proxy_port;
#                proxy_set_header X-Real-IP $remote_addr;
#                proxy_set_header X-Forwarded-For $remote_addr;
#                proxy_set_header HTTP_CLIENT_IP $remote_addr;
#                proxy_set_header HTTP_X_FORWARDED_FOR $remote_addr;
#                client_max_body_size        100m;
#                client_body_buffer_size     128k;
#                proxy_connect_timeout       100;
#                proxy_send_timeout          20000;
#                proxy_read_timeout          20000;
#                proxy_buffer_size           32k;
#                proxy_buffers               8 32k;
#                proxy_busy_buffers_size     64k;
#                proxy_temp_file_write_size  640k;
        }

        location /tmexport/ {
                proxy_pass http://ds;
                proxy_next_upstream http_404;
                proxy_redirect off;
                proxy_set_header Host $host;
                proxy_set_header X-Proxy-Port $proxy_port;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $remote_addr;
                proxy_set_header HTTP_CLIENT_IP $remote_addr;
                proxy_set_header HTTP_X_FORWARDED_FOR $remote_addr;
                client_max_body_size        100m;
                client_body_buffer_size     128k;
                proxy_connect_timeout       100;
                proxy_send_timeout          20000;
                proxy_read_timeout          20000;
                proxy_buffer_size           32k;
                proxy_buffers               8 32k;
                proxy_busy_buffers_size     64k;
                proxy_temp_file_write_size  640k;
        }
}


#14

Your added allow directive for your IP but server still listening on listen 127.0.0.1:6666;

You should do something like this:

server {
	listen 127.0.0.1:6666;
	listen 1.1.1.1:6666;

where 1.1.1.1 is IP of your system. Then you will be able use http://1.1.1.1:6666/api/rest/customer/v1/auth


#15

Hi Dmitry,

I have added the listening IP of the server in the nginx config and restarted the service but i am still unable to access the API’s. Postman is giving me 404 not found.


#16

looks like you have no login iyer at System->API Accesses


#17

Got it, I had added the IP in the API access and that was my other IP.
I have set it to 0.0.0.0/0 and its working now.
Thank you.