Let’s face it, the manual process of documenting REST APIs sucks big time. The process goes like this:
- Craft a cURL request for an API Endpoint.
- Copy the response.
- Narrate the API, paste the cURL and response on an editor.
- Edit the response, describe necessary request and response headers, query parameters etc.
- Repeat steps 1-4 for each of your tens of Endpoints.
- Publish the documentation on the web.
- Repeat these steps for each release.
This is a laborious process. However, it doesn’t have to be this way. Meet SpyREST to see how it produces purely organic, automated, replayable, published, version aware and customizable API Documentation for you.
This is how it works:
- You script the API calls using any scripting you prefer, including bash/cURL, automated test frameworks, etc. For example, using a test framework:
describe 'gists' do
it "List a user's gists since a time:" do
response = Github.get '/users/smsohan/gists?since=20140101T00:00:00Z', @common_options
assert_equal 200, response.code
refute_nil response.body
end
end
- Use the SpyREST http proxy
http://SpyREST.com:9081
to perform this call on a real API. - You get the same response, and SpyREST produces a fully baked API documentation as you see here:
Try here if you want to see for yourself:
curl -k -x "http://spyrest.com:9081" -H "Accept: application/vnd.github.v3+json" "https://api.github.com/users/YOUR_GITHUB_USER_NAME/gists"
See the documentation at
http://spyrest.com/api_resources/gists?api_host=api.github.com&api_version=v3
Drop me a line if you’d like to use this to publish your API documentations.