OAuth 1

Please use following adresses and key/secret obtain from administrators to authenticate users:
Access /api/oauth/access_token.php
There are two ways to work with the API. First is when you want to get access for user's data from your website. In this case you may redirect your user to for entering his credentials and work with callback afterwards.
Second is to use it from the code directly, when user has provided his\her credentials into your application. In order to perform an OAuth dance following steps are required
Attention: unless opposite specified, all requests mean to be full OAuth-signed requests like
    GET /api/oauth/access_token.php?

Attention 2: parameters have to be sorted alphabetically, in other case signature verification will fail.:
    GET /api/geocache.php?
        id=2197&         <----- This should go before oauth parameters

Reply format and errors

API replies to all requests with dictionary containing two keys - "status" - which indicates request processing status and "data" which contains response data (if any), i.e.:
"Status" dictionary comes with "code" key which may have "OK" or "ERROR" value (string). If request processing ended with errors, "status" dictionary will contain additional information about it:
{"status":{"code":"ERROR","type":"AuthorisationRequired","description":"Request wasn't signed"},"data":[]}
There are 3 error types:
Not all parameters are set, or parameters submitted in wrong format
Authorisation error. This status returned when any authorisation error is occured. I.e. request was not signed, request was signed with expired token, etc

Important notice:You should be ready to handle this type of error in any time. Although there's virtually no TTL for obtained OAuth tokens, they may be expired or invalidated by server. Best practice is try to re-authenticate user when you receive this kind of error for the first time.
This status returned when some unexpected, abnormal situation has occured.

It's highly discouraged to use string passed in "description" key somewhere in yours app logic flow. Please treat it as hint for developer.

Supported requests

List of geocaches in rectangular area

URL: /api/list.php
Type: GET

This request requires 4 parameters (minlat, maxlat, minlng, maxlng) in floating point number format, which defines bounding box of requested area.
In reply, list of geocaches in this are will be returned. It will contain only brief data, as shown below.

			"id":(geocache ID, int),
			"name":(geocache name, string),
				"id":(geocache author id, int),
				"name":(geocache author name, string)
			"type":(geocache type, int, see in Geocache section),
			"typeString":(geocache type, int, see in Geocache section),
			"attributes":(array of geocache attributes),
			"status":(geocache status, int),
			"statusString":(geocache status, string),
			"isFound":(is found by current user, boolean),
	// other geocaches, if any

List of geocaches around the given point

URL: /api/list_center.php
Type: GET

Returns list of caches in area defined by center and radius.
Center (lat, lng) - float coordinates of the center point.
Radius (radius) - float radius, in km.
Reply is the same as from list.php

Full data of geocache

URL: /api/geocache.php
Type: GET

This method accepts only one parameter - 'id' which should be passed via GET request and should have int format.

If geocache with specified id is not found, error will be returned, i.e.:
{"status":{"code":"ERROR","type":"WrongParameters","description":"Specified geocache was not found."},"data":[]}
Otherwise, full information about specified geocache is returned:
		"id":(geocache id, int),
		"name":(geocache name, string),
			"id":(author user id, int),
			"name":(author name, string)
			"id":(attribute id, int),
			"name":(attribute name, string)
			}, //...other attributes, if any
		"isFound":(is found by current user, boolean),
		"winter":(seasonal availability, see "Winter Mode" chapter below),
			"container":(description of geocache container and/or contents. string),
			"cache":(geocache description, string),
			"area":(area description, string),
			"traditionalPart":(traditional part, string, see Winter Mode chapter below),
			"virtualPart":(virtual part, string, see Winter Mode chapter below),
			"isHtml":(should descriptions be treated as html-formatted text, boolean)
			"id":(logbook note id, int),
			"typeString":(type of logbook record, string, see Adding records to geocache logbook for details),
				"id":(id of note author, int),
				"name":(name of note author, string)
			"date":(datetime when this note was added, string, in format "0000-00-00 00:00:00"),
			"text":(text, string)
			}, //....other notes, if any
				"id":(image id, int),
				"type":(image type, "areaPhoto" or cachePhoto),
				"url":(image url, string),
				"description":(photo description, string, may not be presented)

Winter mode

Value of 'winter' key in full geocache information dictionary may have following values:

availableWinter mode is off, user may find geocache as usual.
virtualWinter mode is on, user should find answer to virtual question (virtualPart key) instead of trying to find geocache's container.
unavailWinter mode is on, geocache is not available.
Important notice: if 'winter' key is not present in full geocache information dictionary, it should be assumed as 'available'.

Although you application may behave like a web site and not show traditionalPart description while winter mode is on, it may actually be good practice to show all available information about geocache with additional notice about active winter mode instead. Especially, if you application stores data locally, as winter mode may be turned on or off by author in any time.

Adding records to geocache logbook

URL: /api/note.php
Type: POST

Following parameters are accepted via POST method:
cacheID (int)ID of geocache for which note is submitted
type (string)Type of note, one of following value:
foundUser found a geocache
notFoundUser wasn't found a geocache
commentJust comment for geocache
visitedNotTriedToFindUser visited place near geocache, but wasn't tried to find it
text (string)Text of published note. User's experience about finding geocache should be shared here. Please do not use auto-generated text here. If text provided here is very short - note will be rejected.

If logbook entry was successfully added, ID assigned for it will be returned, otherwise error will be reported.


Marking caches as watched

URL: /api/mark.php
Type: POST

Following parameters are accepted via POST method:
cacheID (int) ID of geocache which is affected
watched (bool) "true", if it's needed to mark the cache as watched, "false" if it's needed to "unwatch' the cache

Uploading photo to album

URL: /api/photo.php
Type: POST

Following parameters are accepted via POST method:
cacheID (int)ID of geocache where to upload photo
image (string)Base64-encoded image
caption (string)(Optional) Title of the photo

If the photo was successfully added, "success: true" will be reported and URL of the image will be returned, otherwise error will be reported.

{"status":{"code":"OK"},"data":{"success":"true", "image_url": ""}}

Adding personal notes

URL: /api/personal_note.php
Type: POST

Updates user's personal note for the given cache. Following parameters are accepted via POST method:
cacheID (int) ID of geocache where to update note photo
note_test (string) Text of the note. Shouldn't be more than 10k chars

User profile

URL: /api/profile.php
Type: GET

Gets User profile. There are three possible ways to call this method: Error will be returned if both userID and profileID are passed.

		"id":(user id, int),
		"profileID":(user profile id, int),
		"name":(user name, string),
		"foundCaches":(amount of geocaches found by user, int),
		"hiddenCaches":(amount of geocaches hidden by user, int)