Dragon Cave API

The Dragon Cave API is an HTTPS interface for programmatically accessing a variety of data about users and dragons. The API should always be used over “scraping” the site’s HTML—scraping is forbidden, even for information that the API does not provide.

Use of the Dragon Cave API is subject to the API Terms and Conditions.

Base URL

https://dragcave.net/api/v2/ 

Unless otherwise specified, endpoints expect GET requests, and return JSON. All requests must contain an Authorization: Bearer <privatekey> header, using either a private API key obtained from the Manage Applications page, or a user access token obtained via OAuth.

Other deprecated forms of access are covered in the legacy documentation.

OAuth

OAuth 2.0 is a framework for allowing third party applications to identify who they are acting on behalf of. The Dragon Cave API uses OAuth to allow applications to fetch information on behalf of specific users, even if they have chosen to hide that information publicly.

Most developers will integrate OAuth2 via an existing library, but the details of the framework are in RFC 6749. Once you have an application, you’ll need to use your “public key” (client_id) and “private key” (client_secret).

Base authorization URL

https://dragcave.net/oauth_login 

Token URL

https://dragcave.net/api/oauth2/token 

Token Revocation URL

https://dragcave.net/api/oauth2/token/revoke 

OAuth 2.0 Authorization Server Metadata is also available for interoperability with libraries that support discovering configuration automatically.

Available OAuth2 Scopes

The following scopes are available for requesting during the authorization process. Scopes are associated with an access token; changing the scope of usage requires requesting a new access token.

identifyAccess the /me endpoint. Granted by default when using OAuth2 login.
dragonsRead a user’s dragon list, even if hidden to others.
groupsAccess all of a user’s dragon groups, including private groups.

Error Handling

All API responses contain an array with the key errors. For most requests, this array will be empty, but otherwise it will contain information about what went wrong.

Sites should not treat a non-empty value as a failed request. In certain cases, errors may be returned alongside a complete response in order to provide additional diagnostic information or warnings such as deprecation notices.

Entries in the errors array will be a tuple containing an error code along with a string describing the error. Error codes are as follows:

0NoticeThe request likely completed successfully, but there is info for the API user (e.g. deprecated behavior).
1Endpoint not foundThe specified endpoint does not map to a known endpoint.
2Missing/Invalid parameterRequired parameters were not given, or their value is not valid. Refer to each endpoint for a description of acceptable vlaues.
3Resource not foundThe ID of the dragon, user, or other entity specified in the request was not found.
4User errorSomething is "wrong" with the user's account. Either it is disabled, or they have no dragons.
5Internal errorSomething isn’t working on Dragon Cave’s side. Try again later.

Endpoints

/api/v2/dragon/{id}: Get Dragon

Returns dragon data for one egg, hatchling, or dragon.

Parameters

idDragon ID.
nameDragon name. Mutually exclusive with ID.

Response

idDragon's ID, may be up to 5 characters in length.
nameDragon's name if it has one, otherwise null.
ownerOwner's username, only if they have set their account settings to reveal their username.
startStolen/Bred on date in YYYY/MM/DD. 0 if hidden.
hatchHatched on date in YYYY/MM/DD. 0 for eggs or hidden
growDate hatchling matured into adult in YYYY/MM/DD. 0 for eggs and hatchlings.
deathDate dragon was killed/died in YYYY/MM/DD. 0 if dragon is still alive.
viewsSelf-explanatory.
uniqueSelf-explanatory.
clicksSelf-explanatory.
gender"Male" or "Female," empty if not yet revealed.
acceptaidWhether or not the owner of the egg/hatchling is "accepting aid." That this value can change over time, so you should re-check periodically or rely on explicit permission from the dragon's owner by using OAuth.
hoursleftNumber of hours until egg dies. -1 if hidden, frozen, or adult, -2 if dead.
parent_fFemale parent/mother.
parent_mMale parent/father.

Examples

  • https://dragcave.net/api/v2/dragon/abCd3
  • https://dragcave.net/api/v2/dragon?name=Named+Dragon

/api/v2/dragon/{id}/children: Get Dragon Children

Returns dragon data for one dragon and its children and their children and so on. Limited to 5 generations or up to 200 dragons.

Parameters

idDragon ID.
nameDragon name. Mutually exclusive with ID.

Response

dragonsList of dragons (see the Get Dragon endpoint).

Examples

  • https://dragcave.net/api/v2/dragon/abCd3/children
  • https://dragcave.net/api/v2/dragon/children/?name=Named+Dragon

/api/v2/dragon/{id}/lineage: Get Dragon Lineage

Returns dragon data for one dragon and all of its parents and their parents and so on. Limited to 12 generations or up to 200 dragons.

Parameters

idDragon ID.
nameDragon name. Mutually exclusive with ID.

Response

dragonsList of dragons (see the Get Dragon endpoint).

Examples

  • https://dragcave.net/api/v2/dragon/abCd3/lineage
  • https://dragcave.net/api/v2/dragon/lineage/?name=Named+Dragon

/api/v2/dragons: Get Dragons (Bulk)POST

Returns dragon data for multiple eggs, hatchlings, or dragons. Fetching many dragons at once in a single request is much faster/more efficient than making many requests.

Parameters

idsComma-separated list of dragon IDs. Can be passed via the URL or as a application/x-www-form-urlencoded POST parameter.

Response

dragonsList of dragons (see the Get Dragon endpoint).

Examples

  • https://dragcave.net/api/v2/dragons?ids=12345,abCd3,DeFgh,56789
  • https://dragcave.net/api/v2/dragons (POST data: ids=12345,abCd3,DeFgh,56789)

/api/v2/group/{id}: Get Group

Returns information about a single dragon group. Private groups cannot be loaded unless the request is made with the owner's access token that has requested the groups scope.

Parameters

idGroup's ID.

Response

idGroup's ID.
nameGroups's name.
visibilityOne of HIGHLIGHTED, PUBLIC, or PRIVATE.
linkFully-qualified URL to the group.

Examples

  • https://dragcave.net/api/v2/group/1234

/api/v2/group/{id}/dragons: Get Group Dragons

Returns dragon data for all of the eggs, hatchlings, and dragons in a group. Private groups cannot be loaded unless the request is made with the owner's access token that has requested the groups scope.

Parameters

idGroup ID.
filterSubset of dragons to return: ALL, GROWING, ADULTS_AND_FROZEN.
limitHow many dragons to return per-page. Default 500. There is no upper bound on this parameter, but requests that try to fetch too many dragons at once may fail.
afterThe pagination cursor (where to resume paging).

Response

dragonsList of dragons (see the Get Dragon endpoint).
dataPagination info.

Examples

  • https://dragcave.net/api/v2/group/1234/dragons
  • https://dragcave.net/api/v2/group/1234/dragons?filter=GROWING

/api/v2/me: Get Logged In User

Returns information about the currently logged-in user. Requires passing a user access token.

Response

user_idID of the currently logged-in user.
usernameName of the currently logged-in user.

/api/v2/user: Get User Dragons

Returns dragon data for all of a user's eggs, hatchlings, or dragons.

Parameters

usernameThe target user's name.
filterSubset of dragons to return: ALL, GROWING, ADULTS_AND_FROZEN.
limitHow many dragons to return per-page. Default 500. There is no upper bound on this parameter, but requests that try to fetch too many dragons at once may fail.
afterThe pagination cursor (where to resume paging).

Response

dragonsList of dragons (see the view endpoint).
dataPagination info.

Examples

  • https://dragcave.net/api/v2/user?username=Username
  • https://dragcave.net/api/v2/user?username=Username&filter=GROWING

/api/v2/user/groups: Get User Groups

Returns a list of all of a user's dragon groups. Only highlighted groups will be returned, unless the request is made with a user access token that has the groups scope.

Parameters

usernameThe target user's name.
limitHow many groups to return per-page. Default 50.
afterThe pagination cursor (where to resume paging).

Response

groupsList of groups. See the Get Group endpoint.
dataPagination info.

Examples

  • https://dragcave.net/api/v2/user/groups?username=Username