Examples, libraries and tools
ToolsIf 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 query
Please note that the examples below use very simple error checking routines. If you want to be "professional", you should catch 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.US installation:
PHP Example 2 - search for nearest geocaches
This will print the codes of some nearest unfound caches:
It 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:
OKAPI 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.