logo aa:  1203 GK XML interface
Jump to: Read | Write

Read

General

Logtypes (state)

0 = Dropped to; 1 = Grabbed from; 2 = A comment; 3 = Seen in; 4 = Archived; 5 = Visiting;

GK Types (type)

0 = Traditional; 1 = A book/CD/DVD...; 2 = A human; 3 = A coin; 4 = KretyPost;

Reference number and id conversion

$id=hexdec(substr($gk, 2, 4));
$gk=sprintf("GK%04X",$id);

Database synchronising

This can be used to synchronize your database with GK database - useful for OpenCaching and other geocaching projects as well as for other purposes ;) Please note, all opencaching sites should be using Method 2!

Note: export*.php has a limit of retrieved data set at 10 days (ie you can download data changed in the past 10 days only). This should be enough to sync local OC nodes or other databases. To get older data check: here.

Method 1: All GeoKrety & logs information (slow and large volume of data)

To get list of GK created after the date and moves registered after the date:
http://geokrety.org/export.php?modifiedsince=20090901000000

Sample output (without headers):

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<gkxml version="1.0" date="2013-01-05 13:00:49">

 <geokret id="6664">
   <name><![CDATA[Piramidy]]></name>
   <description><![CDATA[by Terry Pratchett]]></description>
   <owner id="3807"><![CDATA[meteor2017]]></owner>
   <datecreated>2010-01-17 17:43:50</datecreated>
   <distancetravelled>408</distancetravelled>
	 <state>0</state>
	 <missing>0</missing>
   <position latitude="49.48972" longitude="18.96848" />
   <waypoints>
      <waypoint><![CDATA[OP41A1]]></waypoint>
   </waypoints>
   <type id="1"><![CDATA[A book/CD/DVD...]]></type>
</geokret>

 <moves id="284778">
   <geokret id="28328"><![CDATA[Indián 2]]></geokret>
   <position latitude="50.33383" longitude="13.51802" />
   <waypoints>
      <waypoint><![CDATA[GC1W85C]]></waypoint>
   </waypoints>
   <date moved="2013-01-05 12:00:00" logged="2013-01-05 12:48:01" />
   <user id="17715"><![CDATA[sacreecoeur]]></user>
   <comment><![CDATA[Moje první GeoKrety]]></comment>
   <logtype id="0"><![CDATA[Dropped to]]></logtype>
</moves>

</gkxml>

Method 2: Only GeoKrety information (fast, only most important data; designed for OC sites)

To get list of GK that changed location during last hour: http://geokrety.org/export_oc.php?modifiedsince=20161203022231

State field may have different value than in other versions of export scripts. This is because OC sites only need to know if a geokret is in a cache or in the hands of some geocacher. So if someone dips a geokret, its state will be 1 (grabbed).

Note: export*.php has a limit of retrieved data set at 10 days (ie you can download data changed in the past 10 days only). This should be enough to sync local OC nodes or other databases. To get older data check: here.

Sample output:

<geokret id="4849">
   <name><![CDATA[B&B's Dragonfly]]></name>
   <distancetravelled>1959</distancetravelled>
   <state>0</state>
   <position latitude="53.73917" longitude="17.40568" />
   <waypoints>
      <waypoint><![CDATA[OP1003]]></waypoint>
   </waypoints>
</geokret>
<geokret id="3249">
   <name><![CDATA[Geokretynka]]></name>
   <distancetravelled>113</distancetravelled>
   <state>1</state>
   <position latitude="0.00000" longitude="0.00000" />
   <waypoints>
      <waypoint><![CDATA[]]></waypoint>
   </waypoints>
</geokret>

Retriving information

Note: export*.php has a limit of retrieved data set at 10 days (ie you can download data changed in the past 10 days only). This should be enough to sync local OC nodes or other databases. To get older data check: here.

http://geokrety.org/export2.php

sample output:

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<gkxml version="1.0" date="2010-12-09 19:10:03">
<geokrety>
	<geokret id="8143" dist="251" lat="53.14598" lon="23.18567"
	waypoint="OP2FD9" owner_id="3813" state="0" type="0" 
	last_pos_id="11536" last_log_id="11553"
	image="1273660644jr8sm.jpg">
	<![CDATA[Wiewireczka]]>
	</geokret>
</geokrety>
</gkxml>
last_pos_id - id of the last position (waypoint); last_log_id - id of the last log (may be a waypoint, comment etc)

General purpose swiches:

Above swiches can be mixed. Eg to list my (ownerid=1) geokrets which are in GC caches, just enter:
http://geokrety.org/export2.php?userid=1&wpt=gc

Retriving user's inventory:

Compressing output

Write

this part of API is highly experimental!

(1) secid

Logging of geokrety is possible by passing to appropriate script variable secid via POST method. The secid is 128 characters long string, unique for all users (it should be kept secret like a password). The secid can be obtained by passing variables login and password to the script:

http://geokrety.org/api-login2secid.php

via POST method. If correct login credentials are supplied, the secid is returned.

(2) logging

To log a geokret, you have to pass to the http://geokrety.org/ruchy.php script the secid as well as other data you normally pass via form:

variabledescriptionexample
secidauthentication string - see above
nrgeokret's tracking codeGH68MA
formname = 'ruchy' (must be set this way)ruchy
logtypesee logtypeson the top of this document0
datathe log date YYYY-MM-DD2012-12-15
godzinahour HH15
minutaminutes MM23
comment(optional) comment to the logIt is a good place for this geokret!
app(optional) application name, <=16 charsLocus
app_ver(optional) application version, <=16 chars1.16dev
mobile_lang(optional) error messages language;
for list of avaliable languages see here
pl_PL.UTF-8

The new position of geokret should be set by one of the following variables:

variabledescriptionexample
latlonlatitude and longitude (various formats acceptable)52.1534 21.0539
wptwaypointOP05E5

All those via POST method. After successful logging the geokret, the xml is returned, like in this example.

After successful data submission the "no errors" code is returned along with gk number:

<?xml version="1.0" ?>
<gkxml version="1.0" date="2013-01-03 21:29:11">
<errors>
 <error></error>
</errors>
<geokrety>
 <geokret id="27334"/>
</geokrety>
</gkxml>

If errors occurs, the XML error list is returned in the defined language, eg:

<?xml version="1.0" ?>
<gkxml version="1.0" date="2013-01-03 21:13:51">
<errors>
<error>Wrong secid</error>
<error>Wrond date or time</error>
</errors>
</gkxml>

If you provide an app name, it would be nice to send us an application icon (16x16, png, eg app icon), that we could add short info about application in the log entry.

If you have any idea, how to improve this API or any function-request, feel free to contact us!

Sample scripts

Here are sample scripts for using GK api

Made in Poland | by filips | xhtml + css | geokrety.org | contact | g+ | Report abuse | Terms of use | ssl