Peter Robinett

API Libraries

There are several libraries, all developed at Mediamatic, that make interacting with the anyMeta API easier, for example by performing authentication, validating request syntax, and converting the serialized data format to native data structures.
The libraries include, in order of recommendation: python-anymeta This is the most popular anyMeta library and, accordingly, the one that has the most documentation and attention from Mediamatic. API methods can be called quite naturally and there is support included for asynchronous operation using the Twisted framework. There are some useful code included for queuing API calls, and there is an included command-line program that does OAuth authorization and provides an API REPL. Even if you chose to use another anyMeta library you may find you need to use python-anymeta for the initial authorization. The library's website is In addition to the actual source code, the site contains several tutorials which walk you through getting credentials, querying the API with them, and fetching user information based upon an RFID tag. One useful tip is that when calling anymeta.attachment.create you can give an absolute path to a file instead of the base64 encoded base and the library will automatically load the file. You must do so like so: data=”@/absolute/path/to/file”. java-anymeta As the name suggests it is a Java library for anyMeta. Like with many Java libraries it can be used in other JVM languages, including Processing. Its website is and there is a little bit more information at The library has no simplified way to request creditentials like python-anymeta does. Because of this and because it can reuse ones saved by the any-registry tool, you may want to use python-anymeta in conjunction with java-anymeta. php-anymeta This is an experimental library with little to no documentation. It should only be used if you must use PHP and want to avoid making requests directly. It can be found at anymeta.js This is a Javascript library that makes asynchronous interactions with anyMeta servers quite easy in Javascript. Not all API methods have been implemented as Javascript functions but the ones that do exist include common methods for things, edges, predicates, and users. As these functions only make it easier to call the function AnyMeta.wrappedRequest, you can easily extend the library and write your own wrappers if you find a function you'd like to do is missing. Because anymeta.js assumes the presence of XMLHttpRequest and one which is, naturally, able to make requests to the anyMeta server requested. It will work, naturally, when the anyMeta site is on the same domain. However, anyMeta does not currently support Cross-Origin Resource Sharing, meaning that cross-domain requests will normally not work. For requests outside of a standard browser environment, some work may be required. iPhone and Android apps written using PhoneGap or similar web view-based approaches will work if the Javascript code making the request is local to the app (e.g. accessed via the file:// protocol). In other environments you may need to mimic XMLHttpRequest, for instance with env.js, or modify anymeta.js to use a different networking mechanism. The library can be found at Javascript By giving the query parameter 'format' with value 'json' a JSON response is returned. Likewise the query parameter 'callback' can be used to specify a Javascript function call to wrap around the result data. Together these options makes JSONP responses possible. This is most useful for anyMeta site owners, as they may place Javascript code on their own site and use the XMLHttpRequest object to call their local API. In addition, since the Javascript code is running on the same site the logged-in user's cookie will be used to authenticate the requests, removing any need to use OAuth. However, there are several ways to make remote requests. First, you may make JSONP requests by appending script tags to your document. This will only work for API methods that allow GET requests. Second, you may make an AJAX request if your browser does not prohibit cross-domain requests. Writing your own library By no means do you need to use one of the Mediamatic anyMeta libraries. Perhaps your language of choice (Objective-C for iPhone apps, Ruby, you name it) isn't represented or perhaps you prefer to take a different approach. No problem, as you've seen the API is relatively simple. However, for your own sake and that of future users of your library, you should keep the following in mind. OAuth OAuth, frankly, can be quite tricky and a good library will handle all this for the library user. Try to make the authorization handshake as easy as possible and then transparently sign all API requests. Translate responses from the serialization format to native data structures. Sure, JSON looks a lot like Javascript or Python code and some languages can natively handle XML, but don't be afraid of embracing the exceptional parts of your language and specifically its data structures. You might even consider making classes for Things and Edges to provide additional levels of convenience, such has update and delete methods, and type-safety. Be aware of the difference between an error and an empty response, and particularly whether an empty response represents a success or error. Unfortunately the API is currently rather inconsistent on this subject, so this is an area where you can provide a real help to your library's users by providing more consistent information.