Now we're going to show you how to automatically generate an OpenAPI 3 specification on the client side, for any AJAX website (or really, any service you can generate HAR files for.) You can then use the API for documentation, diffs, and more.
Akita is currently in private beta. If you are not part of the private beta, you will need to request an invite before continuing. Get an invite.
You'll need the following things in order to follow along with this tutorial:
- Akita Client - If you don't already have the Akita Client installed, follow this guide to get set up.
- API Service - You will need a service that provides an HTTP API that you can access either through a browser or a proxy (for instance, Charles).
Now we'll show you how to use Akita to:
To build API models from traffic, you first need to create a ‘Service’ to associate the model with.
You can name your new service whatever you like, but it will be easier to find it again later if the name reflects the name of the API whose model you're learning.
The next step is to fire up your web browser, connect to your service, and start recording some API traffic. To do that, you'll need to use your browser to record a HAR file. For this example, we'll walk through how to record traffic with Google Chrome, but other browsers have similar mechanisms.
Note: an alternative to this step is to generate a HAR file using a proxy tool like Charles.
Navigate to the website you want to test and right click -> inspect to bring up the developer console.
Network tab and you should see that it's currently recording.
As you click around and type on the website, Chrome collects all the network requests in the background.
Once you're satisfied with the set of data collected, click on the download button to download the HAR file.
No Download Button?
If you don't see download button shown in the previous screenshot, it might be because you have the Chrome Developer Tools window to the right (or left) of your screen, rather than on the bottom. That sometimes causes the download button to be hidden.
Either try expanding the width of the Chrome Developer Tools window, or click the "Settings" icon (the gray widget in the top right of the window) and change the orientation.
You can use the apispec command to transform a trace (the HAR file) into an API model.
akita apispec --traces path/to/yourTraceFile.har \ --out akita://myService:spec:mySpec
This will read the HAR file from your file system (use the location where you saved the HAR file instead of
path/to/yourTraceFile.har) and create a model in the Akita Cloud. Use your service name instead of
myService in the AkitaURI, and pick a name for the model.
Here you'll see stats about your spec, like the number of requests in the trace that went into making the spec, the total number of endpoints Akita discovered (after grouping requests by path parameter), and any sensitive data formats detected. Click on any of the endpoints to see more information.
Finally, there's also a handy button to download a YAML representation of your spec, which you can use anywhere OpenAPI3 specs are used. Akita will also use this model for generating diffs.
Updated 15 days ago
|Diff API Models|
|Merge API Models|
|Extend API Models|
|Run Akita on Every Pull Request|
|Watch API Traffic to Non-Network Tests|