forked from ringcentral/slate
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
348 lines (308 loc) · 13.7 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
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
<!doctype html>
<html>
<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>API Reference</title>
<link href="stylesheets/screen.css" rel="stylesheet" media="screen" />
<link href="stylesheets/print.css" rel="stylesheet" media="print" />
<style>
.highlight table td { padding: 5px; }
.highlight table pre { margin: 0; }
.highlight, .highlight .w {
color: #f8f8f2;
background-color: #272822;
}
.highlight .err {
color: #151515;
background-color: #ac4142;
}
.highlight .c, .highlight .cd, .highlight .cm, .highlight .c1, .highlight .cs {
color: #505050;
}
.highlight .cp {
color: #f4bf75;
}
.highlight .nt {
color: #f4bf75;
}
.highlight .o, .highlight .ow {
color: #d0d0d0;
}
.highlight .p, .highlight .pi {
color: #d0d0d0;
}
.highlight .gi {
color: #90a959;
}
.highlight .gd {
color: #ac4142;
}
.highlight .gh {
color: #6a9fb5;
background-color: #151515;
font-weight: bold;
}
.highlight .k, .highlight .kn, .highlight .kp, .highlight .kr, .highlight .kv {
color: #aa759f;
}
.highlight .kc {
color: #d28445;
}
.highlight .kt {
color: #d28445;
}
.highlight .kd {
color: #d28445;
}
.highlight .s, .highlight .sb, .highlight .sc, .highlight .sd, .highlight .s2, .highlight .sh, .highlight .sx, .highlight .s1 {
color: #90a959;
}
.highlight .sr {
color: #75b5aa;
}
.highlight .si {
color: #8f5536;
}
.highlight .se {
color: #8f5536;
}
.highlight .nn {
color: #f4bf75;
}
.highlight .nc {
color: #f4bf75;
}
.highlight .no {
color: #f4bf75;
}
.highlight .na {
color: #6a9fb5;
}
.highlight .m, .highlight .mf, .highlight .mh, .highlight .mi, .highlight .il, .highlight .mo, .highlight .mb, .highlight .mx {
color: #90a959;
}
.highlight .ss {
color: #90a959;
}
</style>
<script src="javascripts/all.js"></script>
</head>
<body class="index" data-languages="["shell","ruby","python"]">
<a href="#" id="nav-button">
<span>
NAV
<img src="images/navbar.png" />
</span>
</a>
<div class="tocify-wrapper">
<img src="images/logo.png" />
<div class="lang-selector">
<a href="#" data-language-name="shell">shell</a>
<a href="#" data-language-name="ruby">ruby</a>
<a href="#" data-language-name="python">python</a>
</div>
<div class="search">
<input type="text" class="search" id="input-search" placeholder="Search">
</div>
<ul class="search-results"></ul>
<div id="toc">
</div>
<ul class="toc-footer">
<li><a href='#'>Sign Up for a Developer Key</a></li>
<li><a href='https://github.com/tripit/slate'>Documentation Powered by Slate</a></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 access Kittn API endpoints, which can get information on various cats, kittens, and breeds in our database.</p>
<p>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.</p>
<p>This example API documentation page was created with <a href="https://github.com/tripit/slate">Slate</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 class="highlight ruby"><code><span class="nb">require</span> <span class="s1">'kittn'</span>
<span class="n">api</span> <span class="o">=</span> <span class="no">Kittn</span><span class="o">::</span><span class="no">APIClient</span><span class="p">.</span><span class="nf">authorize!</span><span class="p">(</span><span class="s1">'meowmeowmeow'</span><span class="p">)</span>
</code></pre>
<pre class="highlight python"><code><span class="kn">import</span> <span class="nn">kittn</span>
<span class="n">api</span> <span class="o">=</span> <span class="n">kittn</span><span class="o">.</span><span class="n">authorize</span><span class="p">(</span><span class="s">'meowmeowmeow'</span><span class="p">)</span>
</code></pre>
<pre class="highlight shell"><code><span class="c"># With shell, you can just pass the correct header with each request</span>
curl <span class="s2">"api_endpoint_here"</span>
-H <span class="s2">"Authorization: meowmeowmeow"</span>
</code></pre>
<blockquote>
<p>Make sure to replace <code class="prettyprint">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 class="prettyprint">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="get-all-kittens">Get All Kittens</h2>
<pre class="highlight ruby"><code><span class="nb">require</span> <span class="s1">'kittn'</span>
<span class="n">api</span> <span class="o">=</span> <span class="no">Kittn</span><span class="o">::</span><span class="no">APIClient</span><span class="p">.</span><span class="nf">authorize!</span><span class="p">(</span><span class="s1">'meowmeowmeow'</span><span class="p">)</span>
<span class="n">api</span><span class="p">.</span><span class="nf">kittens</span><span class="p">.</span><span class="nf">get</span>
</code></pre>
<pre class="highlight python"><code><span class="kn">import</span> <span class="nn">kittn</span>
<span class="n">api</span> <span class="o">=</span> <span class="n">kittn</span><span class="o">.</span><span class="n">authorize</span><span class="p">(</span><span class="s">'meowmeowmeow'</span><span class="p">)</span>
<span class="n">api</span><span class="o">.</span><span class="n">kittens</span><span class="o">.</span><span class="n">get</span><span class="p">()</span>
</code></pre>
<pre class="highlight shell"><code>curl <span class="s2">"http://example.com/api/kittens"</span>
-H <span class="s2">"Authorization: meowmeowmeow"</span>
</code></pre>
<blockquote>
<p>The above command returns JSON structured like this:</p>
</blockquote>
<pre class="highlight json"><code><span class="p">[</span><span class="w">
</span><span class="p">{</span><span class="w">
</span><span class="nt">"id"</span><span class="p">:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w">
</span><span class="nt">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"Fluffums"</span><span class="p">,</span><span class="w">
</span><span class="nt">"breed"</span><span class="p">:</span><span class="w"> </span><span class="s2">"calico"</span><span class="p">,</span><span class="w">
</span><span class="nt">"fluffiness"</span><span class="p">:</span><span class="w"> </span><span class="mi">6</span><span class="p">,</span><span class="w">
</span><span class="nt">"cuteness"</span><span class="p">:</span><span class="w"> </span><span class="mi">7</span><span class="w">
</span><span class="p">},</span><span class="w">
</span><span class="p">{</span><span class="w">
</span><span class="nt">"id"</span><span class="p">:</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w">
</span><span class="nt">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"Max"</span><span class="p">,</span><span class="w">
</span><span class="nt">"breed"</span><span class="p">:</span><span class="w"> </span><span class="s2">"unknown"</span><span class="p">,</span><span class="w">
</span><span class="nt">"fluffiness"</span><span class="p">:</span><span class="w"> </span><span class="mi">5</span><span class="p">,</span><span class="w">
</span><span class="nt">"cuteness"</span><span class="p">:</span><span class="w"> </span><span class="mi">10</span><span class="w">
</span><span class="p">}</span><span class="w">
</span><span class="p">]</span><span class="w">
</span></code></pre>
<p>This endpoint retrieves all kittens.</p>
<h3 id="http-request">HTTP Request</h3>
<p><code class="prettyprint">GET http://example.com/api/kittens</code></p>
<h3 id="query-parameters">Query Parameters</h3>
<table><thead>
<tr>
<th>Parameter</th>
<th>Default</th>
<th>Description</th>
</tr>
</thead><tbody>
<tr>
<td>include_cats</td>
<td>false</td>
<td>If set to true, the result will also include cats.</td>
</tr>
<tr>
<td>available</td>
<td>true</td>
<td>If set to false, the result will include kittens that have already been adopted.</td>
</tr>
</tbody></table>
<aside class="success">
Remember — a happy kitten is an authenticated kitten!
</aside>
<h2 id="get-a-specific-kitten">Get a Specific Kitten</h2>
<pre class="highlight ruby"><code><span class="nb">require</span> <span class="s1">'kittn'</span>
<span class="n">api</span> <span class="o">=</span> <span class="no">Kittn</span><span class="o">::</span><span class="no">APIClient</span><span class="p">.</span><span class="nf">authorize!</span><span class="p">(</span><span class="s1">'meowmeowmeow'</span><span class="p">)</span>
<span class="n">api</span><span class="p">.</span><span class="nf">kittens</span><span class="p">.</span><span class="nf">get</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span>
</code></pre>
<pre class="highlight python"><code><span class="kn">import</span> <span class="nn">kittn</span>
<span class="n">api</span> <span class="o">=</span> <span class="n">kittn</span><span class="o">.</span><span class="n">authorize</span><span class="p">(</span><span class="s">'meowmeowmeow'</span><span class="p">)</span>
<span class="n">api</span><span class="o">.</span><span class="n">kittens</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span>
</code></pre>
<pre class="highlight shell"><code>curl <span class="s2">"http://example.com/api/kittens/2"</span>
-H <span class="s2">"Authorization: meowmeowmeow"</span>
</code></pre>
<blockquote>
<p>The above command returns JSON structured like this:</p>
</blockquote>
<pre class="highlight json"><code><span class="p">{</span><span class="w">
</span><span class="nt">"id"</span><span class="p">:</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w">
</span><span class="nt">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"Max"</span><span class="p">,</span><span class="w">
</span><span class="nt">"breed"</span><span class="p">:</span><span class="w"> </span><span class="s2">"unknown"</span><span class="p">,</span><span class="w">
</span><span class="nt">"fluffiness"</span><span class="p">:</span><span class="w"> </span><span class="mi">5</span><span class="p">,</span><span class="w">
</span><span class="nt">"cuteness"</span><span class="p">:</span><span class="w"> </span><span class="mi">10</span><span class="w">
</span><span class="p">}</span><span class="w">
</span></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="http-request">HTTP Request</h3>
<p><code class="prettyprint">GET http://example.com/kittens/<ID></code></p>
<h3 id="url-parameters">URL Parameters</h3>
<table><thead>
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
</thead><tbody>
<tr>
<td>ID</td>
<td>The ID of the kitten to retrieve</td>
</tr>
</tbody></table>
<h1 id="errors">Errors</h1>
<aside class="notice">This error section is stored in a separate file in `includes/_errors.md`. Slate allows you to optionally separate out your docs into many files…just save them to the `includes` folder and add them to the top of your `index.md`’s frontmatter. Files are included in the order listed.</aside>
<p>The Kittn API uses the following error codes:</p>
<table><thead>
<tr>
<th>Error Code</th>
<th>Meaning</th>
</tr>
</thead><tbody>
<tr>
<td>400</td>
<td>Bad Request – Your request sucks</td>
</tr>
<tr>
<td>401</td>
<td>Unauthorized – Your API key is wrong</td>
</tr>
<tr>
<td>403</td>
<td>Forbidden – The kitten requested is hidden for administrators only</td>
</tr>
<tr>
<td>404</td>
<td>Not Found – The specified kitten could not be found</td>
</tr>
<tr>
<td>405</td>
<td>Method Not Allowed – You tried to access a kitten with an invalid method</td>
</tr>
<tr>
<td>406</td>
<td>Not Acceptable – You requested a format that isn’t json</td>
</tr>
<tr>
<td>410</td>
<td>Gone – The kitten requested has been removed from our servers</td>
</tr>
<tr>
<td>418</td>
<td>I’m a teapot</td>
</tr>
<tr>
<td>429</td>
<td>Too Many Requests – You’re requesting too many kittens! Slow down!</td>
</tr>
<tr>
<td>500</td>
<td>Internal Server Error – We had a problem with our server. Try again later.</td>
</tr>
<tr>
<td>503</td>
<td>Service Unavailable – We’re temporarially offline for maintanance. Please try again later.</td>
</tr>
</tbody></table>
</div>
<div class="dark-box">
<div class="lang-selector">
<a href="#" data-language-name="shell">shell</a>
<a href="#" data-language-name="ruby">ruby</a>
<a href="#" data-language-name="python">python</a>
</div>
</div>
</div>
</body>
</html>