This repository has been archived by the owner on Feb 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
286 lines (249 loc) · 10.3 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>Kittn API docs</title>
<link href="https://fonts.googleapis.com/css?family=PT+Sans&display=swap" rel="stylesheet">
<link rel="stylesheet" href="css/style.css" media="screen" />
<link rel="stylesheet" href="css/print.css" media="print" />
<script src="js/all.js"></script>
<link rel="stylesheet" href="css/highlight-darcula.css" media="" />
<script src="js/highlight.pack.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
</head>
<body class="" data-languages="["php","python","bash","javascript"]">
<a href="#" id="nav-button">
<span>
NAV
<img src="images/navbar.png" alt="-image" class=""/>
</span>
</a>
<div class="tocify-wrapper">
<div class="lang-selector">
<a href="#" data-language-name="php">php</a>
<a href="#" data-language-name="python">python</a>
<a href="#" data-language-name="bash">bash</a>
<a href="#" data-language-name="javascript">javascript</a>
</div>
<div class="search">
<input type="text" class="search" id="input-search" placeholder="Search">
</div>
<ul class="search-results"></ul>
<ul id="toc">
</ul>
<ul class="toc-footer" id="toc-footer">
<li><a href='#'>Sign up for a developer key</a></li>
<li><a href='https://github.com/knuckleswtf/pastel-js'>Documentation powered by Pastel 🎨</a></li>
</ul>
<ul class="toc-footer" id="last-updated">
<li>Last updated: June 18, 2020</li>
</ul>
</div>
<div class="page-wrapper">
<div class="dark-box"></div>
<div class="content">
<h1 id="introduction">Introduction</h1>
<p>Welcome to the Kittn API! You can use our API to can get information on various cats, kittens, and breeds in our database.</p>
<aside>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).</aside>
<p>This example API documentation page was borrowed from <a href="https://github.com/slatedocs/slate">Slate</a> and generated with <a href="https://github.com/knuckleswtf/pastel">Pastel</a>. Feel free to edit it and use it as a base for your own API's documentation.</p>
<h1 id="authentication">Authentication</h1>
<blockquote>
<p>To authorize, use this code:</p>
</blockquote>
<pre><code class="php language-php"># 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));
</code></pre>
<pre><code class="python language-python">import kittn
api = kittn.authorize('meowmeowmeow')
</code></pre>
<pre><code class="bash language-bash"># With Bash, you pass in the correct header with each request
curl "api_endpoint_here"
-H "Authorization: meowmeowmeow"
</code></pre>
<pre><code class="javascript language-javascript">const kittn = require('kittn');
let api = kittn.authorize('meowmeowmeow');
</code></pre>
<blockquote>
<p>Make sure to replace <code>meowmeowmeow</code> with your API key.</p>
</blockquote>
<p>Kittn uses API keys to allow access to the API. You can register a new Kittn API key at our <a href="http://example.com/developers">developer portal</a>.</p>
<p>Kittn expects for the API key to be included in all API requests to the server in a header that looks like the following:</p>
<p><code>Authorization: meowmeowmeow</code></p>
<aside class="notice">
You must replace <code>meowmeowmeow</code> with your personal API key.
</aside>
<h1 id="kittens">Kittens</h1>
<h2 id="getallkittens">Get All Kittens</h2>
<pre><code class="php language-php">$client = new \GuzzleHttp\Client();
$response = $client->get("http://example.com/kittens/");
$body = $response->getBody();
print_r(json_decode((string) $body));
</code></pre>
<pre><code class="python language-python">import kittn
api = kittn.authorize('meowmeowmeow')
api.kittens.get()
</code></pre>
<pre><code class="bash language-bash">curl "http://example.com/api/kittens"
-H "Authorization: meowmeowmeow"
</code></pre>
<pre><code class="javascript language-javascript">const kittn = require('kittn');
let api = kittn.authorize('meowmeowmeow');
let kittens = api.kittens.get();
</code></pre>
<blockquote>
<p>The above command returns JSON structured like this:</p>
</blockquote>
<pre><code class="json language-json">[
{
"id": 1,
"name": "Fluffums",
"breed": "calico",
"fluffiness": 6,
"cuteness": 7
},
{
"id": 2,
"name": "Max",
"breed": "unknown",
"fluffiness": 5,
"cuteness": 10
}
]
</code></pre>
<p>This endpoint retrieves all kittens.</p>
<h3 id="httprequest">HTTP Request</h3>
<p><small class="badge badge-green">GET</small> <strong><code>http://example.com/api/kittens</code></strong></p>
<h4 class="fancy-heading-panel"><b>Query Parameters</b></h4>
<p>
<code><b>include_cats</b></code> <i>Default: <code>false</code></i>
<br>
If set to true, the result will also include cats.
</p>
<p>
<code><b>available</b></code> <i>Default: <code>true</code></i>
<br>
If set to false, the result will include kittens that have already been adopted.
</p>
<aside class="success">
Remember — a happy kitten is an authenticated kitten!
</aside>
<h2 id="getaspecifickitten">Get a Specific Kitten</h2>
<pre><code class="php language-php">$client = new \GuzzleHttp\Client();
$response = $client->get('http://example.com/kittens/2');
$body = $response->getBody();
print_r(json_decode((string) $body));
</code></pre>
<pre><code class="python language-python">import kittn
api = kittn.authorize('meowmeowmeow')
api.kittens.get(2)
</code></pre>
<pre><code class="bash language-bash">curl "http://example.com/api/kittens/2"
-H "Authorization: meowmeowmeow"
</code></pre>
<pre><code class="javascript language-javascript">const kittn = require('kittn');
let api = kittn.authorize('meowmeowmeow');
let max = api.kittens.get(2);
</code></pre>
<blockquote>
<p>The above command returns JSON structured like this:</p>
</blockquote>
<pre><code class="json language-json">{
"id": 2,
"name": "Max",
"breed": "unknown",
"fluffiness": 5,
"cuteness": 10
}
</code></pre>
<p>This endpoint retrieves a specific kitten.</p>
<aside class="warning">Inside HTML code blocks like this one, you can't use Markdown, so use <code><code></code> blocks to denote code.</aside>
<h3 id="httprequest-1">HTTP Request</h3>
<p><small class="badge badge-green">GET</small> <strong><code>http://example.com/kittens/<ID></code></strong></p>
<h4 class="fancy-heading-panel"><b>URL Parameters</b></h4>
<p>
<code><b>ID</b></code>
<br>
The ID of the kitten to retrieve.
</p>
<h2 id="deleteaspecifickitten">Delete a Specific Kitten</h2>
<pre><code class="php language-php">$client = new \GuzzleHttp\Client();
$response = $client->delete('http://example.com/kittens/2');
$body = $response->getBody();
print_r(json_decode((string) $body));
</code></pre>
<pre><code class="python language-python">import kittn
api = kittn.authorize('meowmeowmeow')
api.kittens.delete(2)
</code></pre>
<pre><code class="bash language-bash">curl "http://example.com/api/kittens/2"
-X DELETE
-H "Authorization: meowmeowmeow"
</code></pre>
<pre><code class="javascript language-javascript">const kittn = require('kittn');
let api = kittn.authorize('meowmeowmeow');
let max = api.kittens.delete(2);
</code></pre>
<blockquote>
<p>The above command returns JSON structured like this:</p>
</blockquote>
<pre><code class="json language-json">{
"id": 2,
"deleted" : ":("
}
</code></pre>
<p>This endpoint deletes a specific kitten.</p>
<h3 id="httprequest-2">HTTP Request</h3>
<p><small class="badge badge-red">DELETE</small> <strong><code>http://example.com/kittens/<ID></code></strong></p>
<h4 class="fancy-heading-panel"><b>URL Parameters</b></h4>
<p>
<code><b>ID</b></code>
<br>
The ID of the kitten to delete.
</p><h1 id="errors">Errors</h1>
<aside class="notice">
This error section is stored in a separate file in <code>includes/errors.md</code>. Pastel allows you to split your docs across multiple files...just add them to the top of your <code>index.md</code>'s front matter. Files are included in the order listed.
</aside>
<p>The Kittn API uses the following error codes:</p>
<p>Error Code | Meaning
---------- | -------
400 | Bad Request -- Your request is invalid.
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! Slow down!
500 | Internal Server Error -- We had a problem with our server. Try again later.
503 | Service Unavailable -- We're temporarily offline for maintenance. Please try again later.</p>
</div>
<div class="dark-box">
<div class="lang-selector">
<a href="#" data-language-name="php">php</a>
<a href="#" data-language-name="python">python</a>
<a href="#" data-language-name="bash">bash</a>
<a href="#" data-language-name="javascript">javascript</a>
</div>
</div>
</div>
<script>
$(function () {
var languages = ["php","python","bash","javascript"];
setupLanguages(languages);
});
</script>
</body>
</html>