snipt

Ctrl+h for KB shortcuts

Markdown

Snipt API

The Snipt API provides all of the functionality needed to interact with public and private snipts. The entire Snipt UI is actually powered by the API behind the scenes. If you have an issue with the API, you have a few options:

  • Use the comments attached to this snipt.
  • Reply to us on Twitter.
  • File a support ticket on GitHub

Overview

The API is made up of a collection of resources. These resources are separated by whether they are public or private resources. There are two main API endpoints:

https://snipt.net/api/public/

https://snipt.net/api/private/

These endpoints return data in the format based on an HTTP header that you send along in the request. For example, if you would like XML returned:

Accept: application/xml

The following content types are supported: json, jsonp, xml, yaml, plist.

To preview an API response in your browser without sending along a custom HTTP request header, you can append the requested content type in the query string, like so:

https://snipt.net/api/public/?format=json


Public API

The public API is simply that: public. It's restricted to GET requests, only. You make requests, get data back, do something with that data, etc.

When you get snipts from the public API, you only get snipts back that have been marked as public. Same with tag counts - those counts will only reflect snipts that've been tagged and are also public.


Private API

The private API allows you to write apps that interact with a user's snipts. It supports almost everything that the Snipt website supports, as the website itself uses the API as its backend.

Authentication

To authenticate with the private API, you have two options. The first option is to pass an Authorization header along with your request, like this:

Authorization: ApiKey username:api_key

We've created a test user for testing the private API:

Username: api_test_user

API key: a0eb5dfb1e8c26366b9b5cfea3f7dc20543bf1fb

The second option for authenticating with the private API is to pass along the username and API key in the query string, like this:

https://snipt.net/api/private/?username=api_test_user&api_key=a0eb...


Resources

Snipt

Get public snipts:

GET https://snipt.net/api/public/snipt/
  • Optional parameters: limit, offset, order_by, tag, user, q
  • If provided, order_by can be one of:
    • created (oldest first)
    • -created (newest first)
    • modified (oldest first)
    • -modified (newest first)
  • If provided, user must be the ID (integer) of a user, which you can retrieve via a Snipt or User resource (see examples below). Providing a user flag will only return snipts created by that user.
  • If provided, tag must be the ID (integer) of a tag, which you can retrieve via a Snipt or Tag resource (see examples below). Providing a tag flag will only return snipts tagged with that tag.
  • If provided, q is a search term to filter results by.

Get public snipts tagged with php:

GET https://snipt.net/api/public/snipt/?tag=9
  • Note: you can get the ID of a tag from the Tag resource below.

Get public snipts ordered by oldest-first:

GET https://snipt.net/api/public/snipt/?order_by=created

Search for public snipts that match flappers:

GET https://snipt.net/api/public/snipt/?q=flappers

Get public snipts created by a specific user:

GET https://snipt.net/api/public/snipt/?user=3
  • You can get the ID of a user from the User resource or within a Snipt resource.

Get an individual snipt:

GET https://snipt.net/api/public/snipt/39388/?format=json

Get a user's snipts from the private API:

GET https://snipt.net/api/private/snipt/
    Authorization ApiKey api_test_user:a0eb5dfb1e8c26366b9b5cfea3f7dc20543bf1fb
  • Optional parameters: limit, offset, order_by, tag, q
  • If provided, order_by can be one of:
    • created (oldest first)
    • -created (newest first)
    • modified (oldest first)
    • -modified (newest first)
  • If provided, tag must be the ID (integer) of a tag, which you can retrieve via a Snipt or Tag resource (see examples below). Providing a tag flag will only return snipts tagged with that tag.
  • If provided, q is a search term to filter results by.

Get a user's individual snipt from the private API:

GET https://snipt.net/api/private/snipt/39597/
    Authorization ApiKey api_test_user:a0eb5dfb1e8c26366b9b5cfea3f7dc20543bf1fb

Create a snipt:

POST https://snipt.net/api/private/snipt/
     Authorization ApiKey api_test_user:a0eb5dfb1e8c26366b9b5cfea3f7dc20543bf1fb
     Content-Type  application/json
     {"title": "A snipt", "lexer": "text"}
  • Required fields: lexer
  • Optional fields: title, code, tags, public, blog_post
  • lexer must be one of these (the short / lowercase code): https://snipt.net/api/public/lexer/
  • If provided, tags is a string of tags, like this: tag-1, tag2, "tag 3", etc.

Edit a snipt (partial):

PATCH https://snipt.net/api/private/snipt/39598/
      Authorization ApiKey api_test_user:a0eb5dfb1e8c26366b9b5cfea3f7dc20543bf1fb
      Content-Type  application/json
      {"title": "A snipt"}
  • Note: you can also use PUT, but you'll need to send along the entire snipt object, or omitted fields will be erased.

Delete a snipt:

DELETE https://snipt.net/api/private/snipt/39595/
       Authorization ApiKey api_test_user:a0eb5dfb1e8c26366b9b5cfea3f7dc20543bf1fb

Lexer

Get all lexers:

GET https://snipt.net/api/public/lexer/

User

Get public information on a specific user:

GET https://snipt.net/api/public/user/3/

If you don't know the ID:

GET https://snipt.net/api/public/user/?username=nick

Get private information on a specific user from the private API:

GET https://snipt.net/api/private/user/9971/
    Authorization ApiKey api_test_user:a0eb5dfb1e8c26366b9b5cfea3f7dc20543bf1fb

Tag

Get public tags:

GET https://snipt.net/api/public/tag/
  • This will only retrieve tags that have been assigned to a public snipt.
  • If provided, q is a search term to filter results by. Give it the tag slug, such as: https://snipt.net/api/public/tag/?q=php

Get a user's tags from the private API:

GET https://snipt.net/api/private/tag/
    Authorization ApiKey api_test_user:a0eb5dfb1e8c26366b9b5cfea3f7dc20543bf1fb
  • This will return all tags that have been used by this user.

Favorite

Favorites are only available via the private API.


Get a user's favorites from the private API:

GET https://snipt.net/api/private/favorite/
    Authorization ApiKey api_test_user:a0eb5dfb1e8c26366b9b5cfea3f7dc20543bf1fb

Create a new favorite from the private API:

POST https://snipt.net/api/private/favorite/
     Authorization ApiKey api_test_user:a0eb5dfb1e8c26366b9b5cfea3f7dc20543bf1fb
     Content-Type  application/json
     {"snipt": 1, "user": 9971}
  • Note: you can't create duplicate snipt / user favorites, you'll receive an error if you try to do so.
  • snipt is the ID of the snipt to be favorited, and user is the ID of the user who is doing the favoriting.

Get a favorite from the private API:

GET https://snipt.net/api/private/favorite/1948/
    Authorization ApiKey api_test_user:a0eb5dfb1e8c26366b9b5cfea3f7dc20543bf1fb
  • This obviously has limited use. You'll probably want to get a list of the user's favorites (see above) and cache that data.

Delete a favorite from the private API:

DELETE https://snipt.net/api/private/favorite/1948/
       Authorization ApiKey api_test_user:a0eb5dfb1e8c26366b9b5cfea3f7dc20543bf1fb
https://snipt.net/embed/a751a1bcb4a56a0f76e9a119c17d7f9b/
https://snipt.net/raw/a751a1bcb4a56a0f76e9a119c17d7f9b/
a751a1bcb4a56a0f76e9a119c17d7f9b
markdown
Markdown
265
2016-06-30T15:26:33
True
False
False
/api/public/snipt/39520/
snipt-api
<p>The Snipt API provides all of the functionality needed to interact with public and private snipts. The entire Snipt UI is actually powered by the API behind the scenes. If you have an issue with the API, you have a few options:</p> <ul> <li>Use the comments attached to this snipt.</li> <li>Reply to us on <a href="http://twitter.com/snipt">Twitter</a>.</li> <li>File a support ticket on <a href="https://github.com/nicksergeant/snipt/issues">GitHub</a></li> </ul> <hr /> <h2>Overview</h2> <p>The API is made up of a collection of resources. These resources are separated by whether they are public or private resources. There are two main API endpoints:</p> <blockquote> <p><a href="https://snipt.net/api/public/">https://snipt.net/api/public/</a></p> <p><a href="https://snipt.net/api/private/">https://snipt.net/api/private/</a></p> </blockquote> <p>These endpoints return data in the format based on an HTTP header that you send along in the request. For example, if you would like XML returned:</p> <pre><code>Accept: application/xml </code></pre> <p>The following content types are supported: <code>json</code>, <code>jsonp</code>, <code>xml</code>, <code>yaml</code>, <code>plist</code>.</p> <p>To preview an API response in your browser without sending along a custom HTTP request header, you can append the requested content type in the query string, like so:</p> <blockquote> <p><a href="https://snipt.net/api/public/?format=json">https://snipt.net/api/public/?format=json</a></p> </blockquote> <hr /> <h2>Public API</h2> <p>The public API is simply that: public. It's restricted to GET requests, only. You make requests, get data back, do something with that data, etc.</p> <p>When you get snipts from the public API, you only get snipts back that have been marked as public. Same with tag counts - those counts will only reflect snipts that've been tagged and are also public.</p> <hr /> <h2>Private API</h2> <p>The private API allows you to write apps that interact with a user's snipts. It supports almost everything that the Snipt website supports, as the website itself uses the API as its backend.</p> <h4>Authentication</h4> <p>To authenticate with the private API, you have two options. The first option is to pass an <code>Authorization</code> header along with your request, like this:</p> <pre><code>Authorization: ApiKey username:api_key </code></pre> <p>We've created a test user for testing the private API:</p> <blockquote> <p>Username: <code>api_test_user</code></p> <p>API key: <code>a0eb5dfb1e8c26366b9b5cfea3f7dc20543bf1fb</code></p> </blockquote> <p>The second option for authenticating with the private API is to pass along the username and API key in the query string, like this:</p> <blockquote> <p><a href="https://snipt.net/api/private/?username=api_test_user&amp;api_key=a0eb5dfb1e8c26366b9b5cfea3f7dc20543bf1fb&amp;format=json">https://snipt.net/api/private/?username=api_test_user&amp;api_key=a0eb...</a></p> </blockquote> <hr /> <h2>Resources</h2> <h4>Snipt</h4> <p>Get public snipts:</p> <pre><code>GET https://snipt.net/api/public/snipt/ </code></pre> <ul> <li>Optional parameters: <code>limit</code>, <code>offset</code>, <code>order_by</code>, <code>tag</code>, <code>user</code>, <code>q</code></li> <li>If provided, <code>order_by</code> can be one of: <ul> <li><code>created</code> (oldest first)</li> <li><code>-created</code> (newest first)</li> <li><code>modified</code> (oldest first)</li> <li><code>-modified</code> (newest first)</li> </ul></li> <li>If provided, <code>user</code> must be the ID (integer) of a user, which you can retrieve via a Snipt or User resource (see examples below). Providing a user flag will only return snipts created by that user.</li> <li>If provided, <code>tag</code> must be the ID (integer) of a tag, which you can retrieve via a Snipt or Tag resource (see examples below). Providing a tag flag will only return snipts tagged with that tag.</li> <li>If provided, <code>q</code> is a search term to filter results by.</li> </ul> <hr /> <p>Get public snipts tagged with <code>php</code>:</p> <pre><code>GET https://snipt.net/api/public/snipt/?tag=9 </code></pre> <ul> <li>Note: you can get the ID of a tag from the Tag resource below.</li> </ul> <hr /> <p>Get public snipts ordered by oldest-first:</p> <pre><code>GET https://snipt.net/api/public/snipt/?order_by=created </code></pre> <hr /> <p>Search for public snipts that match <code>flappers</code>:</p> <pre><code>GET https://snipt.net/api/public/snipt/?q=flappers </code></pre> <hr /> <p>Get public snipts created by a specific user:</p> <pre><code>GET https://snipt.net/api/public/snipt/?user=3 </code></pre> <ul> <li>You can get the ID of a user from the User resource or within a Snipt resource.</li> </ul> <hr /> <p>Get an individual snipt:</p> <pre><code>GET https://snipt.net/api/public/snipt/39388/?format=json </code></pre> <hr /> <p>Get a user's snipts from the private API:</p> <pre><code>GET https://snipt.net/api/private/snipt/ Authorization ApiKey api_test_user:a0eb5dfb1e8c26366b9b5cfea3f7dc20543bf1fb </code></pre> <ul> <li>Optional parameters: <code>limit</code>, <code>offset</code>, <code>order_by</code>, <code>tag</code>, <code>q</code></li> <li>If provided, <code>order_by</code> can be one of: <ul> <li><code>created</code> (oldest first)</li> <li><code>-created</code> (newest first)</li> <li><code>modified</code> (oldest first)</li> <li><code>-modified</code> (newest first)</li> </ul></li> <li>If provided, <code>tag</code> must be the ID (integer) of a tag, which you can retrieve via a Snipt or Tag resource (see examples below). Providing a tag flag will only return snipts tagged with that tag.</li> <li>If provided, <code>q</code> is a search term to filter results by.</li> </ul> <hr /> <p>Get a user's individual snipt from the private API:</p> <pre><code>GET https://snipt.net/api/private/snipt/39597/ Authorization ApiKey api_test_user:a0eb5dfb1e8c26366b9b5cfea3f7dc20543bf1fb </code></pre> <hr /> <p>Create a snipt:</p> <pre><code>POST https://snipt.net/api/private/snipt/ Authorization ApiKey api_test_user:a0eb5dfb1e8c26366b9b5cfea3f7dc20543bf1fb Content-Type application/json {"title": "A snipt", "lexer": "text"} </code></pre> <ul> <li>Required fields: <code>lexer</code></li> <li>Optional fields: <code>title</code>, <code>code</code>, <code>tags</code>, <code>public</code>, <code>blog_post</code></li> <li><code>lexer</code> must be one of these (the short / lowercase code): <a href="https://snipt.net/api/public/lexer/">https://snipt.net/api/public/lexer/</a></li> <li>If provided, <code>tags</code> is a string of tags, like this: <code>tag-1, tag2, "tag 3"</code>, etc.</li> </ul> <hr /> <p>Edit a snipt (partial):</p> <pre><code>PATCH https://snipt.net/api/private/snipt/39598/ Authorization ApiKey api_test_user:a0eb5dfb1e8c26366b9b5cfea3f7dc20543bf1fb Content-Type application/json {"title": "A snipt"} </code></pre> <ul> <li>Note: you can also use <code>PUT</code>, but you'll need to send along the entire snipt object, or omitted fields will be erased.</li> </ul> <hr /> <p>Delete a snipt:</p> <pre><code>DELETE https://snipt.net/api/private/snipt/39595/ Authorization ApiKey api_test_user:a0eb5dfb1e8c26366b9b5cfea3f7dc20543bf1fb </code></pre> <hr /> <h4>Lexer</h4> <p>Get all lexers:</p> <pre><code>GET https://snipt.net/api/public/lexer/ </code></pre> <hr /> <h4>User</h4> <p>Get public information on a specific user:</p> <pre><code>GET https://snipt.net/api/public/user/3/ </code></pre> <p>If you don't know the ID:</p> <pre><code>GET https://snipt.net/api/public/user/?username=nick </code></pre> <hr /> <p>Get private information on a specific user from the private API:</p> <pre><code>GET https://snipt.net/api/private/user/9971/ Authorization ApiKey api_test_user:a0eb5dfb1e8c26366b9b5cfea3f7dc20543bf1fb </code></pre> <hr /> <h4>Tag</h4> <p>Get public tags:</p> <pre><code>GET https://snipt.net/api/public/tag/ </code></pre> <ul> <li>This will only retrieve tags that have been assigned to a public snipt.</li> <li>If provided, <code>q</code> is a search term to filter results by. Give it the tag slug, such as: <code>https://snipt.net/api/public/tag/?q=php</code></li> </ul> <hr /> <p>Get a user's tags from the private API:</p> <pre><code>GET https://snipt.net/api/private/tag/ Authorization ApiKey api_test_user:a0eb5dfb1e8c26366b9b5cfea3f7dc20543bf1fb </code></pre> <ul> <li>This will return all tags that have been used by this user.</li> </ul> <hr /> <h4>Favorite</h4> <p>Favorites are only available via the private API.</p> <hr /> <p>Get a user's favorites from the private API:</p> <pre><code>GET https://snipt.net/api/private/favorite/ Authorization ApiKey api_test_user:a0eb5dfb1e8c26366b9b5cfea3f7dc20543bf1fb </code></pre> <hr /> <p>Create a new favorite from the private API:</p> <pre><code>POST https://snipt.net/api/private/favorite/ Authorization ApiKey api_test_user:a0eb5dfb1e8c26366b9b5cfea3f7dc20543bf1fb Content-Type application/json {"snipt": 1, "user": 9971} </code></pre> <ul> <li>Note: you can't create duplicate snipt / user favorites, you'll receive an error if you try to do so.</li> <li><code>snipt</code> is the ID of the snipt to be favorited, and <code>user</code> is the ID of the user who is doing the favoriting.</li> </ul> <hr /> <p>Get a favorite from the private API:</p> <pre><code>GET https://snipt.net/api/private/favorite/1948/ Authorization ApiKey api_test_user:a0eb5dfb1e8c26366b9b5cfea3f7dc20543bf1fb </code></pre> <ul> <li>This obviously has limited use. You'll probably want to get a list of the user's favorites (see above) and cache that data.</li> </ul> <hr /> <p>Delete a favorite from the private API:</p> <pre><code>DELETE https://snipt.net/api/private/favorite/1948/ Authorization ApiKey api_test_user:a0eb5dfb1e8c26366b9b5cfea3f7dc20543bf1fb </code></pre>
api, snipt
--- 
+++ 
@@ -2,7 +2,7 @@
 snipts. The entire Snipt UI is actually powered by the API behind the scenes. If you have
 an issue with the API, you have a few options:
 
-* Use the comments attached to this snipt
+* Use the comments attached to this snipt.
 * Reply to us on [Twitter](http://twitter.com/snipt).
 * File a support ticket on [GitHub](https://github.com/nicksergeant/snipt/issues)
 
  • nick
  • 7 months, 3 weeks ago
--- 
+++ 
@@ -2,7 +2,7 @@
 snipts. The entire Snipt UI is actually powered by the API behind the scenes. If you have
 an issue with the API, you have a few options:
 
-* Use the comments attached to this snipt.
+* Use the comments attached to this snipt
 * Reply to us on [Twitter](http://twitter.com/snipt).
 * File a support ticket on [GitHub](https://github.com/nicksergeant/snipt/issues)
 
  • nick
  • 7 months, 3 weeks ago
  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
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
--- 
+++ 
@@ -1,266 +1,265 @@
-The Snipt API provides all of the functionality needed to interact with public and private
-snipts. The entire Snipt UI is actually powered by the API behind the scenes. If you have
-an issue with the API, you have a few options:
-
-* Ask "nicksergeant" in #snipt on irc.freenode.net.
-* Use the comments attached to this snipt.
-* Reply to us on [Twitter](http://twitter.com/snipt).
-* File a support ticket on [GitHub](https://github.com/nicksergeant/snipt/issues)
-
------------------------------------------------
-
-## Overview
-
-The API is made up of a collection of resources. These resources are separated by whether they
-are public or private resources. There are two main API endpoints:
-
-> [https://snipt.net/api/public/](https://snipt.net/api/public/)
-
-> [https://snipt.net/api/private/](https://snipt.net/api/private/)
-
-These endpoints return data in the format based on an HTTP header that you send along in the
-request. For example, if you would like XML returned:
-
-    Accept: application/xml
-
-The following content types are supported: `json`, `jsonp`, `xml`, `yaml`, `plist`.
-
-To preview an API response in your browser without sending along a custom HTTP request header,
-you can append the requested content type in the query string, like so:
-
-> [https://snipt.net/api/public/?format=json](https://snipt.net/api/public/?format=json)
-
------------------------------------------------
-
-## Public API
-
-The public API is simply that: public. It's restricted to GET requests, only. You make
-requests, get data back, do something with that data, etc.
-
-When you get snipts from the public API, you only get snipts back that have been marked as
-public. Same with tag counts - those counts will only reflect snipts that've been tagged and
-are also public.
-
------------------------------------------------
-
-## Private API
-
-The private API allows you to write apps that interact with a user's snipts. It supports
-almost everything that the Snipt website supports, as the website itself uses the API as
-its backend.
-
-#### Authentication
-
-To authenticate with the private API, you have two options. The first option is to pass an
-`Authorization` header along with your request, like this:
-
-    Authorization: ApiKey username:api_key
-
-We've created a test user for testing the private API:
-
-> Username: `api_test_user`
-
-> API key: `a0eb5dfb1e8c26366b9b5cfea3f7dc20543bf1fb`
-
-The second option for authenticating with the private API is to pass along the username and
-API key in the query string, like this:
-
-> [https://snipt.net/api/private/?username=api_test_user&api_key=a0eb...](https://snipt.net/api/private/?username=api_test_user&api_key=a0eb5dfb1e8c26366b9b5cfea3f7dc20543bf1fb&format=json)
-
------------------------------------------------
-
-## Resources
-
-#### Snipt
-
-Get public snipts:
-
-    GET https://snipt.net/api/public/snipt/
-
-- Optional parameters: `limit`, `offset`, `order_by`, `tag`, `user`, `q`
-- If provided, `order_by` can be one of:
-  - `created` (oldest first)
-  - `-created` (newest first)
-  - `modified` (oldest first)
-  - `-modified` (newest first)
-- If provided, `user` must be the ID (integer) of a user, which you can retrieve via a Snipt or User resource (see examples below). Providing a user flag will only return snipts created by that user.
-- If provided, `tag` must be the ID (integer) of a tag, which you can retrieve via a Snipt or Tag resource (see examples below). Providing a tag flag will only return snipts tagged with that tag.
-- If provided, `q` is a search term to filter results by.
-
------------------------------------------------
-
-Get public snipts tagged with `php`:
-
-    GET https://snipt.net/api/public/snipt/?tag=9
-
-- Note: you can get the ID of a tag from the Tag resource below.
-
------------------------------------------------
-
-Get public snipts ordered by oldest-first:
-
-    GET https://snipt.net/api/public/snipt/?order_by=created
-
------------------------------------------------
-
-Search for public snipts that match `flappers`:
-
-    GET https://snipt.net/api/public/snipt/?q=flappers
-
------------------------------------------------
-
-Get public snipts created by a specific user:
-
-    GET https://snipt.net/api/public/snipt/?user=3
-
-- You can get the ID of a user from the User resource or within a Snipt resource.
-
------------------------------------------------
-
-Get an individual snipt:
-
-    GET https://snipt.net/api/public/snipt/39388/?format=json
-
------------------------------------------------
-
-Get a user's snipts from the private API:
-
-    GET https://snipt.net/api/private/snipt/
-        Authorization ApiKey api_test_user:a0eb5dfb1e8c26366b9b5cfea3f7dc20543bf1fb
-
-- Optional parameters: `limit`, `offset`, `order_by`, `tag`, `q`
-- If provided, `order_by` can be one of:
-  - `created` (oldest first)
-  - `-created` (newest first)
-  - `modified` (oldest first)
-  - `-modified` (newest first)
-- If provided, `tag` must be the ID (integer) of a tag, which you can retrieve via a Snipt or Tag resource (see examples below). Providing a tag flag will only return snipts tagged with that tag.
-- If provided, `q` is a search term to filter results by.
-
------------------------------------------------
-
-Get a user's individual snipt from the private API:
-
-    GET https://snipt.net/api/private/snipt/39597/
-        Authorization ApiKey api_test_user:a0eb5dfb1e8c26366b9b5cfea3f7dc20543bf1fb
-
------------------------------------------------
-
-Create a snipt:
-
-    POST https://snipt.net/api/private/snipt/
-         Authorization ApiKey api_test_user:a0eb5dfb1e8c26366b9b5cfea3f7dc20543bf1fb
-         Content-Type  application/json
-         {"title": "A snipt", "lexer": "text"}
-
-- Required fields: `lexer`
-- Optional fields: `title`, `code`, `tags`, `public`, `blog_post`
-- `lexer` must be one of these (the short / lowercase code): [https://snipt.net/api/public/lexer/](https://snipt.net/api/public/lexer/)
-- If provided, `tags` is a string of tags, like this: `tag-1, tag2, "tag 3"`, etc.
-
------------------------------------------------
-
-Edit a snipt (partial):
-
-    PATCH https://snipt.net/api/private/snipt/39598/
-          Authorization ApiKey api_test_user:a0eb5dfb1e8c26366b9b5cfea3f7dc20543bf1fb
-          Content-Type  application/json
-          {"title": "A snipt"}
-
-- Note: you can also use `PUT`, but you'll need to send along the entire snipt object, or
-omitted fields will be erased.
-
------------------------------------------------
-
-Delete a snipt:
-
-    DELETE https://snipt.net/api/private/snipt/39595/
-           Authorization ApiKey api_test_user:a0eb5dfb1e8c26366b9b5cfea3f7dc20543bf1fb
-
------------------------------------------------
-
-#### Lexer
-
-Get all lexers:
-
-    GET https://snipt.net/api/public/lexer/
-
------------------------------------------------
-
-#### User
-
-Get public information on a specific user:
-
-    GET https://snipt.net/api/public/user/3/
-
-If you don't know the ID:
-
-    GET https://snipt.net/api/public/user/?username=nick
-
------------------------------------------------
-
-Get private information on a specific user from the private API:
-
-    GET https://snipt.net/api/private/user/9971/
-        Authorization ApiKey api_test_user:a0eb5dfb1e8c26366b9b5cfea3f7dc20543bf1fb
-
------------------------------------------------
-
-#### Tag
-
-Get public tags:
-
-    GET https://snipt.net/api/public/tag/
-
-- This will only retrieve tags that have been assigned to a public snipt.
-- If provided, `q` is a search term to filter results by. Give it the tag slug, such as: `https://snipt.net/api/public/tag/?q=php`
-
------------------------------------------------
-
-Get a user's tags from the private API:
-
-    GET https://snipt.net/api/private/tag/
-        Authorization ApiKey api_test_user:a0eb5dfb1e8c26366b9b5cfea3f7dc20543bf1fb
-
-- This will return all tags that have been used by this user.
-
------------------------------------------------
-
-#### Favorite
-
-Favorites are only available via the private API.
-
------------------------------------------------
-
-Get a user's favorites from the private API:
-
-    GET https://snipt.net/api/private/favorite/
-        Authorization ApiKey api_test_user:a0eb5dfb1e8c26366b9b5cfea3f7dc20543bf1fb
-
------------------------------------------------
-
-Create a new favorite from the private API:
-
-    POST https://snipt.net/api/private/favorite/
-         Authorization ApiKey api_test_user:a0eb5dfb1e8c26366b9b5cfea3f7dc20543bf1fb
-         Content-Type  application/json
-         {"snipt": 1, "user": 9971}
-
-- Note: you can't create duplicate snipt / user favorites, you'll receive an error if you try to do so.
-- `snipt` is the ID of the snipt to be favorited, and `user` is the ID of the user who is doing the favoriting.
-
------------------------------------------------
-
-Get a favorite from the private API:
-
-    GET https://snipt.net/api/private/favorite/1948/
-        Authorization ApiKey api_test_user:a0eb5dfb1e8c26366b9b5cfea3f7dc20543bf1fb
-
-- This obviously has limited use. You'll probably want to get a list of the user's favorites (see above) and cache that data.
-
------------------------------------------------
-
-Delete a favorite from the private API:
-
-    DELETE https://snipt.net/api/private/favorite/1948/
+The Snipt API provides all of the functionality needed to interact with public and private
+snipts. The entire Snipt UI is actually powered by the API behind the scenes. If you have
+an issue with the API, you have a few options:
+
+* Use the comments attached to this snipt.
+* Reply to us on [Twitter](http://twitter.com/snipt).
+* File a support ticket on [GitHub](https://github.com/nicksergeant/snipt/issues)
+
+-----------------------------------------------
+
+## Overview
+
+The API is made up of a collection of resources. These resources are separated by whether they
+are public or private resources. There are two main API endpoints:
+
+> [https://snipt.net/api/public/](https://snipt.net/api/public/)
+
+> [https://snipt.net/api/private/](https://snipt.net/api/private/)
+
+These endpoints return data in the format based on an HTTP header that you send along in the
+request. For example, if you would like XML returned:
+
+    Accept: application/xml
+
+The following content types are supported: `json`, `jsonp`, `xml`, `yaml`, `plist`.
+
+To preview an API response in your browser without sending along a custom HTTP request header,
+you can append the requested content type in the query string, like so:
+
+> [https://snipt.net/api/public/?format=json](https://snipt.net/api/public/?format=json)
+
+-----------------------------------------------
+
+## Public API
+
+The public API is simply that: public. It's restricted to GET requests, only. You make
+requests, get data back, do something with that data, etc.
+
+When you get snipts from the public API, you only get snipts back that have been marked as
+public. Same with tag counts - those counts will only reflect snipts that've been tagged and
+are also public.
+
+-----------------------------------------------
+
+## Private API
+
+The private API allows you to write apps that interact with a user's snipts. It supports
+almost everything that the Snipt website supports, as the website itself uses the API as
+its backend.
+
+#### Authentication
+
+To authenticate with the private API, you have two options. The first option is to pass an
+`Authorization` header along with your request, like this:
+
+    Authorization: ApiKey username:api_key
+
+We've created a test user for testing the private API:
+
+> Username: `api_test_user`
+
+> API key: `a0eb5dfb1e8c26366b9b5cfea3f7dc20543bf1fb`
+
+The second option for authenticating with the private API is to pass along the username and
+API key in the query string, like this:
+
+> [https://snipt.net/api/private/?username=api_test_user&api_key=a0eb...](https://snipt.net/api/private/?username=api_test_user&api_key=a0eb5dfb1e8c26366b9b5cfea3f7dc20543bf1fb&format=json)
+
+-----------------------------------------------
+
+## Resources
+
+#### Snipt
+
+Get public snipts:
+
+    GET https://snipt.net/api/public/snipt/
+
+- Optional parameters: `limit`, `offset`, `order_by`, `tag`, `user`, `q`
+- If provided, `order_by` can be one of:
+  - `created` (oldest first)
+  - `-created` (newest first)
+  - `modified` (oldest first)
+  - `-modified` (newest first)
+- If provided, `user` must be the ID (integer) of a user, which you can retrieve via a Snipt or User resource (see examples below). Providing a user flag will only return snipts created by that user.
+- If provided, `tag` must be the ID (integer) of a tag, which you can retrieve via a Snipt or Tag resource (see examples below). Providing a tag flag will only return snipts tagged with that tag.
+- If provided, `q` is a search term to filter results by.
+
+-----------------------------------------------
+
+Get public snipts tagged with `php`:
+
+    GET https://snipt.net/api/public/snipt/?tag=9
+
+- Note: you can get the ID of a tag from the Tag resource below.
+
+-----------------------------------------------
+
+Get public snipts ordered by oldest-first:
+
+    GET https://snipt.net/api/public/snipt/?order_by=created
+
+-----------------------------------------------
+
+Search for public snipts that match `flappers`:
+
+    GET https://snipt.net/api/public/snipt/?q=flappers
+
+-----------------------------------------------
+
+Get public snipts created by a specific user:
+
+    GET https://snipt.net/api/public/snipt/?user=3
+
+- You can get the ID of a user from the User resource or within a Snipt resource.
+
+-----------------------------------------------
+
+Get an individual snipt:
+
+    GET https://snipt.net/api/public/snipt/39388/?format=json
+
+-----------------------------------------------
+
+Get a user's snipts from the private API:
+
+    GET https://snipt.net/api/private/snipt/
+        Authorization ApiKey api_test_user:a0eb5dfb1e8c26366b9b5cfea3f7dc20543bf1fb
+
+- Optional parameters: `limit`, `offset`, `order_by`, `tag`, `q`
+- If provided, `order_by` can be one of:
+  - `created` (oldest first)
+  - `-created` (newest first)
+  - `modified` (oldest first)
+  - `-modified` (newest first)
+- If provided, `tag` must be the ID (integer) of a tag, which you can retrieve via a Snipt or Tag resource (see examples below). Providing a tag flag will only return snipts tagged with that tag.
+- If provided, `q` is a search term to filter results by.
+
+-----------------------------------------------
+
+Get a user's individual snipt from the private API:
+
+    GET https://snipt.net/api/private/snipt/39597/
+        Authorization ApiKey api_test_user:a0eb5dfb1e8c26366b9b5cfea3f7dc20543bf1fb
+
+-----------------------------------------------
+
+Create a snipt:
+
+    POST https://snipt.net/api/private/snipt/
+         Authorization ApiKey api_test_user:a0eb5dfb1e8c26366b9b5cfea3f7dc20543bf1fb
+         Content-Type  application/json
+         {"title": "A snipt", "lexer": "text"}
+
+- Required fields: `lexer`
+- Optional fields: `title`, `code`, `tags`, `public`, `blog_post`
+- `lexer` must be one of these (the short / lowercase code): [https://snipt.net/api/public/lexer/](https://snipt.net/api/public/lexer/)
+- If provided, `tags` is a string of tags, like this: `tag-1, tag2, "tag 3"`, etc.
+
+-----------------------------------------------
+
+Edit a snipt (partial):
+
+    PATCH https://snipt.net/api/private/snipt/39598/
+          Authorization ApiKey api_test_user:a0eb5dfb1e8c26366b9b5cfea3f7dc20543bf1fb
+          Content-Type  application/json
+          {"title": "A snipt"}
+
+- Note: you can also use `PUT`, but you'll need to send along the entire snipt object, or
+omitted fields will be erased.
+
+-----------------------------------------------
+
+Delete a snipt:
+
+    DELETE https://snipt.net/api/private/snipt/39595/
+           Authorization ApiKey api_test_user:a0eb5dfb1e8c26366b9b5cfea3f7dc20543bf1fb
+
+-----------------------------------------------
+
+#### Lexer
+
+Get all lexers:
+
+    GET https://snipt.net/api/public/lexer/
+
+-----------------------------------------------
+
+#### User
+
+Get public information on a specific user:
+
+    GET https://snipt.net/api/public/user/3/
+
+If you don't know the ID:
+
+    GET https://snipt.net/api/public/user/?username=nick
+
+-----------------------------------------------
+
+Get private information on a specific user from the private API:
+
+    GET https://snipt.net/api/private/user/9971/
+        Authorization ApiKey api_test_user:a0eb5dfb1e8c26366b9b5cfea3f7dc20543bf1fb
+
+-----------------------------------------------
+
+#### Tag
+
+Get public tags:
+
+    GET https://snipt.net/api/public/tag/
+
+- This will only retrieve tags that have been assigned to a public snipt.
+- If provided, `q` is a search term to filter results by. Give it the tag slug, such as: `https://snipt.net/api/public/tag/?q=php`
+
+-----------------------------------------------
+
+Get a user's tags from the private API:
+
+    GET https://snipt.net/api/private/tag/
+        Authorization ApiKey api_test_user:a0eb5dfb1e8c26366b9b5cfea3f7dc20543bf1fb
+
+- This will return all tags that have been used by this user.
+
+-----------------------------------------------
+
+#### Favorite
+
+Favorites are only available via the private API.
+
+-----------------------------------------------
+
+Get a user's favorites from the private API:
+
+    GET https://snipt.net/api/private/favorite/
+        Authorization ApiKey api_test_user:a0eb5dfb1e8c26366b9b5cfea3f7dc20543bf1fb
+
+-----------------------------------------------
+
+Create a new favorite from the private API:
+
+    POST https://snipt.net/api/private/favorite/
+         Authorization ApiKey api_test_user:a0eb5dfb1e8c26366b9b5cfea3f7dc20543bf1fb
+         Content-Type  application/json
+         {"snipt": 1, "user": 9971}
+
+- Note: you can't create duplicate snipt / user favorites, you'll receive an error if you try to do so.
+- `snipt` is the ID of the snipt to be favorited, and `user` is the ID of the user who is doing the favoriting.
+
+-----------------------------------------------
+
+Get a favorite from the private API:
+
+    GET https://snipt.net/api/private/favorite/1948/
+        Authorization ApiKey api_test_user:a0eb5dfb1e8c26366b9b5cfea3f7dc20543bf1fb
+
+- This obviously has limited use. You'll probably want to get a list of the user's favorites (see above) and cache that data.
+
+-----------------------------------------------
+
+Delete a favorite from the private API:
+
+    DELETE https://snipt.net/api/private/favorite/1948/
            Authorization ApiKey api_test_user:a0eb5dfb1e8c26366b9b5cfea3f7dc20543bf1fb
  • nick
  • 7 months, 3 weeks ago
Copyrighted, illegal, or inappropriate content? Email support@snipt.net.