Admin Senior
asked on
How to get all the API from website?
I know how to get the API link manually from browser plugins such as developer tools or firebug. I have a requirement to get all the APIs for testing. I have to write a script in any language(python, java, perl...) to test all the API links rather than hitting from website UI, but before that I should get all the API links to proceed further.
Does anyone know or have a script to get all the API links of a website?
Does anyone know or have a script to get all the API links of a website?
ASKER
Link checker is nice. But I have GET, POST, PUT methods to send.
I'm new to programming and currently I have taken up a project to check all the API links to validate it's functionality as a process of testing and I have started with the Python Requests scripting. Currently, to get the API link, I use Firebug/Developer tools of the browser and verifying the link along with it's method in Postman/Restclient before using it the python script. Similarly I fetch the each link one by one from the browser plugins.
I'm wondering how to fetch all the API(links) with all it's parameters and headers for the complete website. Can you help me get me started with some examples?
I'm new to programming and currently I have taken up a project to check all the API links to validate it's functionality as a process of testing and I have started with the Python Requests scripting. Currently, to get the API link, I use Firebug/Developer tools of the browser and verifying the link along with it's method in Postman/Restclient before using it the python script. Similarly I fetch the each link one by one from the browser plugins.
I'm wondering how to fetch all the API(links) with all it's parameters and headers for the complete website. Can you help me get me started with some examples?
As far as I know, there is no way to get the information you want. However, I may be wrong as I haven't done much web programming in 5-10 years.
You can't.
ASKER
@wilcoxon & @gurpsbassi: Thanks for replying!. I long back worked on selenium webdriver and jmeter. Can we do anything with selenium ide/jmeter workbench like recording the manual navigation of pages, any thoughts on this if it can help anything in getting the links with any of selenium/jmeter jars programatically?.
is the API a Java API?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
@gurpsbassi:
Yes, it's Java API. I can just give an hint saying that I remember developers using swagger UI to do something with rest api, i'm not exactly sure.
I have gone through swagger codegen and installed it on my mac. I ran the following,
It generated some directory structure under /tmp/mysite with some python scripts. I don't know how to proceed further. I need some more help from you on this codegen if you tried it before!. What all it can do and what I can do with it, i'm not exactly sure.
Yes, it's Java API. I can just give an hint saying that I remember developers using swagger UI to do something with rest api, i'm not exactly sure.
I have gone through swagger codegen and installed it on my mac. I ran the following,
swagger-codegen generate -i http://my-site-domain/api/v2/api-docs.json -l python -o /tmp/mysite/
It generated some directory structure under /tmp/mysite with some python scripts. I don't know how to proceed further. I need some more help from you on this codegen if you tried it before!. What all it can do and what I can do with it, i'm not exactly sure.
ASKER
ls /tmp/mysite
LICENSE build docs npm-debug.log setup.py swagger_client.egg-info test-requirements.txt
README.md dist git_push.sh requirements.txt swagger_client test tox.ini
I did `python setup.py install` in /tmp/mysite and run a file
cd /tmp/mysite
python test/test_group.py
.
----------------------------------------------------------------------
Ran 1 test in 0.000s
OK
I really don't know how to use in my case. Any idea?. Nothing very specific to python, any language is ok but I need all APIs to be collected to test them.
ASKER
I have access to the code and also I know the swagger api-docs json link(eg: http://my-site-domain/api/v2/api-docs.json ) for our site. I checked Swagger-UI locally which lists all apis in Web UI. Still have no idea how to easily extract API link with their parameters...
ASKER
Thanks for introducing me to swagger codegen
If you really want to write a script, jsoup is a good package to build on. It will GET web pages and you can write rules to extract data, in your case all the href values.