IMPORTANT - this is API v2, which was released as part of ResourceSpace 7.9.
ResourceSpace implements a RESTful API that returns JSON. All requests must be signed using a shared private key specific to each user.
To make an API call simply access the /api/ URL of your ResourceSpace installation with the following parameters:
|user||The alphanumeric ID of the user to access the system as, for example "admin".|
|function||The function you wish to perform. See the API function reference for more details.|
|param1, param2, param3...||The parameters to pass to each function. These are specific to each function and are documented in the function reference. It's important that the values are properly percent-encoded. If a function has 5 parameters and the developer only needs e.g. param3, then the request must be done like "param1=¶m2=¶m3=value3".|
|sign||The signature. This is generated by taking the private API key for the user (from the user account page in ResourceSpace) then appending the query URL, and finally producing a sha256 hexadecimal hash of that string.|
This is an example in PHP.
// Set the private API key for the user (from the user account page) and the user we're accessing the system as. $private_key="bfab0581232784c7b04a5c9"; $user="admin"; // Search for 'cat' $query="user=" . $user . "&function=do_search¶m1=cat"; // Sign the query using the private key $sign=hash("sha256",$private_key . $query); // Make the request and output the JSON results. echo file_get_contents("http://my.resourcespace.system/api/?" . $query . "&sign=" . $sign);
The equivalent in Perl:
#!/usr/bin/perl -w use Digest::SHA qw(sha256_hex); use LWP::Simple; use Data::Dumper; use JSON; use strict; # Set the private API key for the user (from the user account page) and the user we're accessing the system as. my $private_key = "bfab0581232784c7b04a5c9"; my $user = "admin"; # Search for 'cat' my $query = "user=$user&function=do_search¶m1=cat"; # Sign the query using the private key my $sign = sha256_hex($private_key . $query); # Make the request and output the JSON results. my $result = decode_json(get("http://my.resourcespace.system/api/index.php?$query&sign=$sign")); print Dumper($result)
Other languages are possible and would work in a similar way.