What is Swagger?
Swagger is an open-source software framework that helps developers design, build, document, and consume RESTful Web services.
Each endpoint uses the HTTP GET method. Every operation returns either a successful HTTP 200 response with a defined schema or a default error response.
To use this Swagger API documentation, you must first set up the necessary API calls from a tool or platform that supports RESTful HTTP requests. Here are the general steps you would follow:
- Identify the API Endpoint: First, select the API endpoint you want to interact with. For instance, if you want to get the latest block's details for Archway mainnet, the endpoint would be https://api.mainnet.archway.io/blocks/latest.
- Choose the HTTP Method: For all the endpoints in this specification, the HTTP method is GET.
- Construct the API URL: This involves appending the API endpoint to the base URL of the API.
- Include Query Parameters (if needed): Some endpoints require additional parameters that should be included in the request. For instance, the /validatorsets endpoint accepts a block height as a parameter: https://api.mainnet.archway.io/validatorsets/18000.
- Send the Request: Use a tool, library, or software that can send HTTP requests. This could be a command-line tool like curl, a programming language with libraries for sending HTTP requests, or a complete API platform like Postman or Insomnia.
- Handle the Response: The response will be a JSON object, as defined by the schemas in the Swagger specification.
An example on how to query the information regarding the latest block, would be to launch the following command in your terminal shell:
curl -X 'GET' \ 'https://api.mainnet.archway.io/blocks/latest' \ -H 'accept: application/json'