NAV
shell ruby python javascript

Einführung

Herzlich Willkommen zur Kittn API! Sie können unsere API für den Zugriff auf Kittn API Endpunkte nutzen, welche Informationen zu verschiedenen Katzen aus unserer Datenbank abrufen kann.

Wir haben Schnittstellen in Shell, Ruby, Python, and JavaScript! Die dunklen Fenster auf der Rechtenseite zeigen Ihnen Code Beispiele. Über die Tabs im oberen rechten Bereich können Sie zwischen den verschiedenen Sprachen wechseln.

Dieses Beispiel für eine API-Dokumentation wurde mit Slate erstellt. Sie können dieses Beispiel bearbeiten und als Basis für Ihre eigene API-Dokumentation verwenden.

Authentifizierung

Um sich zu authentifizieren, nutzen Sie diesen Code:

require 'kittn'

api = Kittn::APIClient.authorize!('meowmeowmeow')
import kittn

api = kittn.authorize('meowmeowmeow')
# With shell, you can just pass the correct header with each request
curl "api_endpoint_here" \
  -H "Authorization: meowmeowmeow"
const kittn = require('kittn');

let api = kittn.authorize('meowmeowmeow');

Ersetzen Sie meowmeowmeow mit Ihrem API-Schlüssel.

Kittn verwendet API-Schlüssel um den Zugriff auf die API zu regeln. Sie können einen neuen Kittn API-Schlüssel auf unserem Entwickler Portal erhalten.

Der API-Schlüssel muss bei jeder API-Anfrage im Header wie folgt mitgesendet werden:

Authorization: meowmeowmeow

Kittens

Get All Kittens

require 'kittn'

api = Kittn::APIClient.authorize!('meowmeowmeow')
api.kittens.get
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.

HTTP Request

GET http://example.com/api/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

require 'kittn'

api = Kittn::APIClient.authorize!('meowmeowmeow')
api.kittens.get(2)
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.

HTTP Request

GET http://example.com/kittens/<ID>

URL Parameters

Parameter Description
ID The ID of the kitten to retrieve

Delete a Specific Kitten

require 'kittn'

api = Kittn::APIClient.authorize!('meowmeowmeow')
api.kittens.delete(2)
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.

HTTP Request

DELETE http://example.com/kittens/<ID>

URL Parameters

Parameter Description
ID The ID of the kitten to delete

Fehler

The Kittn API uses the following error codes:

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.