title | language_tabs | toc_footers | logo | last_updated | includes | |||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Kittn API docs |
|
|
false |
|
Welcome to the Kittn API! You can use our API to can get information on various cats, kittens, and breeds in our database.
As you scroll, you'll see code examples for working with the API in Bash, PHP, Python, and JavaScript in the dark area to the right (or as part of the content on mobile), and you can switch the programming language of the examples with the tabs in the top right (or from the nav menu at the top left on mobile).This example API documentation page was borrowed from Slate and generated with Pastel. Feel free to edit it and use it as a base for your own API's documentation.
To authorize, use this code:
# With PHP, you can pass in the correct header with each request
$client = new \GuzzleHttp\Client();
$response = $client->get(
"api_endpoint_here",
[
'headers' => [
'Authorization' => 'meowmeowmeow',
],
]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import kittn
api = kittn.authorize('meowmeowmeow')
# With Bash, you pass in the correct header with each request
curl "api_endpoint_here"
-H "Authorization: meowmeowmeow"
const kittn = require('kittn');
let api = kittn.authorize('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.
Kittn expects the API key to be included in all API requests to the server in a header that looks like the following:
Authorization: meowmeowmeow
meowmeowmeow
with your personal API key.
$client = new \GuzzleHttp\Client();
$response = $client->get("http://example.com/kittens/");
$body = $response->getBody();
print_r(json_decode((string) $body));
import kittn
api = kittn.authorize('meowmeowmeow')
api.kittens.get()
curl "http://example.com/api/kittens"
-H "Authorization: meowmeowmeow"
const kittn = require('kittn');
let api = kittn.authorize('meowmeowmeow');
let kittens = api.kittens.get();
The above command returns JSON structured like this:
[
{
"id": 1,
"name": "Fluffums",
"breed": "calico",
"fluffiness": 6,
"cuteness": 7
},
{
"id": 2,
"name": "Max",
"breed": "unknown",
"fluffiness": 5,
"cuteness": 10
}
]
This endpoint retrieves all kittens.
GET http://example.com/api/kittens
include_cats
Default: false
If set to true, the result will also include cats.
available
Default: true
If set to false, the result will include kittens that have already been adopted.
$client = new \GuzzleHttp\Client();
$response = $client->get('http://example.com/kittens/2');
$body = $response->getBody();
print_r(json_decode((string) $body));
import kittn
api = kittn.authorize('meowmeowmeow')
api.kittens.get(2)
curl "http://example.com/api/kittens/2"
-H "Authorization: meowmeowmeow"
const kittn = require('kittn');
let api = kittn.authorize('meowmeowmeow');
let max = api.kittens.get(2);
The above command returns JSON structured like this:
{
"id": 2,
"name": "Max",
"breed": "unknown",
"fluffiness": 5,
"cuteness": 10
}
This endpoint retrieves a specific kitten.
Inside HTML code blocks like this one, you can't use Markdown, so use<code>
blocks to denote code.
GET http://example.com/kittens/<ID>
ID
The ID of the kitten to retrieve.
$client = new \GuzzleHttp\Client();
$response = $client->delete('http://example.com/kittens/2');
$body = $response->getBody();
print_r(json_decode((string) $body));
import kittn
api = kittn.authorize('meowmeowmeow')
api.kittens.delete(2)
curl "http://example.com/api/kittens/2"
-X DELETE
-H "Authorization: meowmeowmeow"
const kittn = require('kittn');
let api = kittn.authorize('meowmeowmeow');
let max = api.kittens.delete(2);
The above command returns JSON structured like this:
{
"id": 2,
"deleted" : ":("
}
This endpoint deletes a specific kitten.
DELETE http://example.com/kittens/<ID>
ID
The ID of the kitten to delete.