SpyREST

Supported by Mashape

Home » How it Works

How it Works

SpyREST automatically generates REST API documentation based on real API calls. As the name suggests, SpyREST works as a software in the middle between a API client and the API to capture the web traffic. It then adds the necessary sugar and butter to bake the API documentation with enhanced information. You can run the following command to see it in practice:

curl -k -x "http://spyrest.com:9081" \
-H "Accept: application/vnd.github.v3+json" \
-H "x-spy-rest-desc: Searches assembly language repositories for the word tetris" \
"https://api.github.com/search/repositories?q=tetris+language:assembly&sort=stars&order=desc"

And see the generated documentation here

Under the hood this is what happens:

  1. The following option tells curl to use SpyREST as a proxy, enabling SpyREST to capture the traffic
    -x http://spyrest.com:9081
              
  2. SpyREST automatically detects the version of the API to be v3 from the following header
    "Accept: application/vnd.github.v3+json"
              
  3. SpyREST also guesses the API resource to be repositories from the URL
    /search/repositories
              
  4. The custom header x-spy-rest-desc allows us to provide a description for the API so that SpyREST can display it for its users
    "x-spy-rest-desc: Searches assembly language repositories for the word tetris"