Need help in creating frontend from Swagger API

Sangh.M7 years ago

Hello Anton and all,
First of all, Merry Christmas!

I need help in creating my own custom GUI/web app via the swagger.json. I'm still very new to web development and have been learning HTML, JS and CSS and have hosted traccar 4.2 on my server. I can access the device details from <myserverIP>/api/devices from the browser URL and similarly after reading the API docs here, but I didn't understand the statement "There are a lot of tools available to automatically generate client from Swagger format"
Can somebody give examples of such tools? I've been running around in circles from swagger.io to postman api tools, but no success on how to access entire server api from my HTML/JS pages and what does it mean by "to automatically generate client" ? Basically I need to access everything like devices, calendar, position information, live location update from my own web pages and have buttons for report creation. I'm using PostgreSQL

Please please share some examples and details

Anton Tananaev7 years ago

You can use tools like this one to generate client SDK:

https://swagger.io/tools/swagger-codegen/

Or you can just write requests yourself by hand if you want.

Sangh.M7 years ago

Okay thanks Anton.
By "client SDK", what should I expect as the output? Will I get code to embed in my HTML?

Will this also hold true for the Websocket live location updates via /api/socket/?

Anton Tananaev7 years ago

You will get code to call API. It won't generate any code for WebSocket.