The Safe Pony API

The safe pony API allows you to find definitely-safe-for-work ponies, optionally filtered by tags.

Types

The primary type in the pony API is a Pony, which looks like this:

interface Pony {
    id: number;               // The ID of the pony, as a 53-bit integer.
    derpiId: number | null;   // The ID of the pony on Derpibooru, if known.
    tags: string[];           // An array of tags applied to the image.
    sourceURL: string | null; // The original source of the image, if known.

    height: number;           // The height of the image, in pixels.
    width: number;            // The width of the image, in pixels.
    aspectRatio: number;      // Width divided by height.
    mimeType: string;         // The mime-type of the image; generally one of "image/jpeg", "image/png" or "image/gif"
    originalFormat: string;   // The original extension of the image; generally one of "jpg", "png" or "gif".
    representations: {
        full: string;         // URL pointing to the image as originally uploaded, which may be any size.
        tall: string;         // URL to an image that fits in a 1024x4096 box.
        large: string;        // URL to an image that fits in a 1280x1024 box.
        medium: string;       // URL to an image that fits in an 800x600 box.
        small: string;        // URL to an image that fits in a 320x240 box.
        thumb: string;        // URL to an image that fits in a 250x250 box.
        thumbSmall: string;   // URL to an image that fits in a 150x150 box.
        thumbTiny: string;    // URL to an image that fits in a 50x50 box.
    };
}

It is okay to hotlink the given URLs, which should be stable and available indefinitely. However, please do not try generating them instead of using the given values; the format may change in the future.

Random pony: /api/v1/pony/random

Query parameters:

q (optional)
A comma-separated list of tags to search for, such as twilight sparkle, sitting. The returned pony will have all the specified tags. If no matching pony exists, an HTTP 404 status is returned.
no_stem (optional)
If present, tag stemming is disabled. By default, when not specified, tag stemming is enabled.

Returns a random JSON-encoded pony in the following format:

interface Result {
    pony: Pony;
}
Example
{
  "pony": {
    "aspectRatio": 1.32953020134228,
    "derpiId": 1523751,
    "height": 1490,
    "id": 5067491655024640,
    "mimeType": "image/png",
    "originalFormat": "png",
    "representations": {
      "full": "https://pones.theponyapi.com/file/ponies/5067491655024640/full",
      "large": "https://pones.theponyapi.com/file/ponies/5067491655024640/large",
      "medium": "https://pones.theponyapi.com/file/ponies/5067491655024640/medium",
      "small": "https://pones.theponyapi.com/file/ponies/5067491655024640/small",
      "tall": "https://pones.theponyapi.com/file/ponies/5067491655024640/tall",
      "thumb": "https://pones.theponyapi.com/file/ponies/5067491655024640/thumb",
      "thumbSmall": "https://pones.theponyapi.com/file/ponies/5067491655024640/thumb_small",
      "thumbTiny": "https://pones.theponyapi.com/file/ponies/5067491655024640/thumb_tiny"
    },
    "sourceURL": "http://celebi-yoshi.deviantart.com/art/Peach-Hack-701811756",
    "tags": ["artist:celebi-yoshi", "commission", "cute", "female", "mare", "oc", "oc only",
             "oc:peach hack", "pegasus", "pony", "prone", "safe", "smiling", "solo"],
    "width": 1981
  }
}

Pony by ID: /api/v1/pony/id/<id>

Returns the pony with the given id (corresponding to a Pony's id field). If a pony with the specified ID does not exist, returns HTTP status 404.

Note: this endpoint can return unapproved ponies if requested by ID (though there is no way to get an unapproved pony's ID). The approved property indicates whether this pony is approved.

interface Result {
    approved: boolean; // true if the pony is approved, false otherwise.
    pony: Pony;
}
Example
{
  "approved": true,
  "pony": {
    "aspectRatio": 1.32953020134228,
    "derpiId": 1523751,
    "height": 1490,
    "id": 5067491655024640,
    "mimeType": "image/png",
    "originalFormat": "png",
    "representations": {
      "full": "https://pones.theponyapi.com/file/ponies/5067491655024640/full",
      "large": "https://pones.theponyapi.com/file/ponies/5067491655024640/large",
      "medium": "https://pones.theponyapi.com/file/ponies/5067491655024640/medium",
      "small": "https://pones.theponyapi.com/file/ponies/5067491655024640/small",
      "tall": "https://pones.theponyapi.com/file/ponies/5067491655024640/tall",
      "thumb": "https://pones.theponyapi.com/file/ponies/5067491655024640/thumb",
      "thumbSmall": "https://pones.theponyapi.com/file/ponies/5067491655024640/thumb_small",
      "thumbTiny": "https://pones.theponyapi.com/file/ponies/5067491655024640/thumb_tiny"
    },
    "sourceURL": "http://celebi-yoshi.deviantart.com/art/Peach-Hack-701811756",
    "tags": ["artist:celebi-yoshi", "commission", "cute", "female", "mare", "oc", "oc only",
             "oc:peach hack", "pegasus", "pony", "prone", "safe", "smiling", "solo"],
    "width": 1981
  },
}

Tag list: /api/v1/tags

Returns an array of the names of every known tag:

interface Result {
    tags: string[];
}

Tags by name: /api/v1/tag/<name>

Returns information about the tag with the given name. Aliases are also accepted, but stemmed tags are not. If a tag with the specified name does not exist, returns HTTP status 404.

interface Result {
    name: string; // The primary name of the tag.
    aliases: string[]; // The aliases of the tag.
    stemmed: string; // The stemmed version of the tag, used for stemmed searches.
    stemmed_aliases: string[]; // The stemmed aliases of the tag, used for stemmed searches.
}
Example
{
  "tag": {
    "name": "twilight sparkle",
    "stemmed": "twilight sparkl",
    "aliases": ["twiight sparkle", "twilght", "twilght sparkle", "twilight saprkle",
                "twilightsparkle", "ts", "twileesha sparkles", "twilight sparkles"],
    "stemmed_aliases": ["twiight sparkl", "twilght", "twilght sparkl", "twilight saprkl",
                        "twilightsparkl", "ts", "twileesha sparkl"]
  }
}