ver. 1926 (dbed1d0) services/apiref services/apisrv services/attrs services/caches services/caches/formatters services/caches/map services/caches/search services/caches/shortcuts services/logs services/logs/images services/oauth services/replicate services/users |
Examples, libraries and toolsToolsIf you're just getting to know OKAPI, you might want to check out OKAPI Browser (screenshot), a basic OAuth Console for OKAPI methods. It is an open-source project. You can fork it on GitHub or simply install it here.Are there any client libraries?OKAPI does not require you to use any special libraries. You should use OKAPI "as is", via basic HTTP requests and responses. However, if you know of any useful third-party libraries, then let us know. We may choose to post a link somewhere here. PHP Example 1 - simple queryPlease note that the examples below use extremely simplied error checking routines. If you want to be "professional", then you should catch all HTTP 400 Responses, read their bodies (OKAPI error messages), and deal with them more gracefully. This will print the number of users in the Opencaching.DE installation: PHP Example 2 - search for nearest geocachesThis will print the codes of some nearest unfound caches: JavaScript ExampleIt is possible to access OKAPI directly from user's browser, without the need for server backend. OKAPI allows Cross-domain XHR requests. You can also use JSONP output format. There are some limitations of both these techniques though. This example does the following:
C# ExampleOKAPI Browser (already mentioned in the Tools section) is an open-source project. Written in C#.NET, uses the apisrv and apiref modules to dynamically retrieve the current list of OKAPI installations and methods. Get the source or try it first. Comments |