Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage of the REST API #176

Open
bodiroga opened this issue Mar 3, 2022 · 5 comments
Open

Usage of the REST API #176

bodiroga opened this issue Mar 3, 2022 · 5 comments

Comments

@bodiroga
Copy link

bodiroga commented Mar 3, 2022

Hi @anderspitman!

First of all, let me thank you for the work you have done with boringproxy! I've been testing it for the last hours and it is awesome! Thank you very much!

Anyway, I have a doubt about the REST API of the platform. How can I find the documentation of the expected results from the GET methods or the accepted parameters for the POST methods? Making a simple GET call to the /users endpoint returns an HTML page, while I was expecting an XML or JSON formated response. Is this correct? Or am I doing the wrong request? Is there any plan to improve the REST API?

Thanks again for your help and keep up with the fantastic job! Best regards!

@anderspitman
Copy link
Member

Hi @bodiroga, currently the API is mostly for internal use, since we're pre-1.0. That's why there's no documentation. That said, you might get pretty far by using /api/ endpoints, which return JSON. Everything else is for the web UI which is what you hit with/users. You can look in this file to get a feel for the available /api/ endpoints:

https://github.com/boringproxy/boringproxy/blob/2e0ff06c33a0d94172242adcea708058dde1aeb6/api.go

The plan is to improve the JSON API eventually (note that it isn't designed to be RESTful), but that's a fairly low priority.

May I ask what you're trying to accomplish with it? It might not be too much trouble to add specific features if needed.

@bodiroga
Copy link
Author

bodiroga commented Mar 4, 2022

Hi @anderspitman!

Thanks for your fast response! 👍🏻

I've tried what you suggested, but I'm only getting results for the /api/tunnels endpoint. Is there any way, using the admin access token, to list all available users? And what about clients and tokens? If I try to load https://<my_domain>.takingnames.live/api/users in my web browser, I get the following image:

image

Anyway, don't worry, I have achieved to parse the HTML response from the direct endpoints (/users, /tokens, /clients) to get the information I want, and, even if it is really ugly, it works 😉

Thanks again for your hard work!

@anderspitman
Copy link
Member

Ah yeah I just checked the code and a lot of the functionality isn't actually implemented yet. But it didn't take very long at add GET support for /api/users and /api/tokens. You can use the master builds if you want to switch to JSON:

https://gemdrive.io/apps/delver/?drive=https://files.apitman.com&path=/public/boringproxy/master

Clients is currently a special case, since clients are scoped under users. You can get all the clients from /api/users, but you'll need to do a little extra work to extract them. May potentially add a separate GET /api/clients if there's a need.

@bodiroga
Copy link
Author

bodiroga commented Mar 9, 2022

Hi again @anderspitman!

Sorry for the late response, I didn't see the notification for the new message 😢

Sadly, I have create a small python library to easily interact with boringproxy's rest api (https://github.com/bodiroga/boringproxy-python-api), but I'm not using your newly created endpoints. I will try to update it once a new boringproxy version is released 👍🏻

Thank you very much for your support!

@anderspitman
Copy link
Member

Sounds good 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants