--- title: API Reference language_tabs: - shell - ruby - python toc_footers: - Sign Up for a Developer Key - Documentation Powered by Slate --- # Introduction Welcome to the Kittn API! You can use our API to access Kittn API endpoints, which can get information on various cats, kittens, and breeds in our database. We have language bindings in Shell, Ruby, and Python! You can view code examples in the dark area to the right, and you can switch the programming language of the examples with the tabs in the top right. This example API documentation page was created with [Slate](http://github.com/tripit/slate). Feel free to edit it and use it as a base for your own API's documentation. # Authentication > To authorize, use this code: ```ruby require 'kittn' api = Kittn::APIClient.authorize!('meowmeowmeow') ``` ```python import 'kittn' api = Kittn.authorize('meowmeowmeow') ``` ```shell # With shell, you can just pass the correct header with each request curl "api_endpoint_here" -H "Authorization: meowmeowmeow" ``` > Make sure to replace `meowmeowmeow` with your API key. Kittn uses API keys to allow access to the API. You can register a new Kittn API key at our [developer portal](http://example.com/developers). Kittn expects for the API key to be included in all API requests to the server in a header that looks like the following: `Authorization: meowmeowmeow` # Kittens ## Get All Kittens ```ruby require 'kittn' api = Kittn::APIClient.authorize!('meowmeowmeow') api.kittens.get ``` ```python import 'kittn' api = Kittn.authorize('meowmeowmeow') api.kittens.get() ``` ```shell curl "http://example.com/api/kittens" -H "Authorization: meowmeowmeow" ``` > The above command returns JSON structured like this: ```json [ { "id": 1, "name": "Fluffums", "breed": "calico", "fluffiness": 6, "cuteness": 7 }, { "id": 2, "name": "Isis", "breed": "unknown", "fluffiness": 5, "cuteness": 10 } ] ``` This endpoint retrieves all kittens. ### HTTP Request `GET http://example.com/kittens` ### Query Parameters Parameter | Default | Description --------- | ------- | ----------- include_cats | false | If set to true, the result will also include cats. available | true | If set to false, the result will include kittens that have already been adopted. ## Get a Specific Kitten ```ruby require 'kittn' api = Kittn::APIClient.authorize!('meowmeowmeow') api.kittens.get(2) ``` ```python import 'kittn' api = Kittn.authorize('meowmeowmeow') api.kittens.get(2) ``` ```shell curl "http://example.com/api/kittens/3" -H "Authorization: meowmeowmeow" ``` > The above command returns JSON structured like this: ```json { "id": 2, "name": "Isis", "breed": "unknown", "fluffiness": 5, "cuteness": 10 } ``` This endpoint retrieves a specific kitten. ### HTTP Request `GET http://example.com/kittens/` ### URL Parameters Parameter | Description --------- | ----------- ID | The ID of the cat to retrieve # Errors The Kittn API uses the following error codes: Error Code | Meaning ---------- | ------- 400 | Bad Request -- Your request sucks 401 | Unauthorized -- Your API key is wrong 403 | Forbidden -- The kitten requested is hidden for administrators only 404 | Not Found -- The specified kitten could not be found 405 | Method Not Allowed -- You tried to access a kitten with an invalid method 406 | Not Acceptable -- You requested a format that isn't json 410 | Gone -- The kitten requested has been removed from our servers 418 | I'm a teapot 429 | Too Many Requests -- You're requesting too many kittens! Slown down! 500 | Internal Server Error -- We had a problem with our server. Try again later. 503 | Service Unavailable -- We're temporarially offline for maintanance. Please try again later. <%= properties_table(resource) %> <% resource.namespaced.each do |grouped_resource| %> <% grouped_resource.paths.each do |resource_by_path| %> ## <%= resource_by_path.header %> Actions on the <%= resource.name %> resource <% if resource_by_path.routes.first.route_params.present? %> + Parameters <% resource_by_path.routes.first.route_params.each do |param| %> + <%= param.description %> <% end %> <% end %> <% resource_by_path.routes.each do |route| %> ### <%= route.route_description %> <% if show_request_sample?(route) %> <%= route.request_description %> <%= formatted_request_headers %> + Body <%= resource.sample_request %> <% end %> <%= route.response_description %> <%= formatted_response_headers %> + Body <%= resource.sample_response(route) %> <% end %> <% end %> <% end %>