|
Welcome to 4shared REST API documentation!
IntroductionThe 4shared API is built to conform to the design principles of Representational State Transfer (REST). 4shared resources like files, folders and users can be accessed and updated using the HTTP methods GET, POST, PUT and DELETE. In general, a list of the resources is available through /{resource name}, to get a specific resource, use /{resource name}/{id} and subresources like a list of user's files can be received through /{resource name}/{id}/{subresource name} The current API version is 0. Version is specified in the API URL: http://www.4shared.com/v0/ Public callsYou can start using the API after creating an application. Public API calls may be done with application's consumer key. This example shows how to get latest files:
http://www.4shared.com/v0/files.json?oauth_consumer_key={application's consumer key}
Formats4shared API supports xml, json and jsonp formats. The requested format can be specified by appending .format to the resource path:
http://www.4shared.com/v0/files.json?oauth_consumer_key={application's consumer key}
http://www.4shared.com/v0/files.xml?oauth_consumer_key={application's consumer key}
http://www.4shared.com/v0/files.jsonp?oauth_consumer_key={application's consumer key}
The alternative way of specifying format is setting the HTTP Accept header:
$ curl -H "Accept: application/json" "http://www.4shared.com/v0/files?oauth_consumer_key={application's consumer key}"
$ curl -H "Accept: application/xml" "http://www.4shared.com/v0/files?oauth_consumer_key={application's consumer key}"
$ curl -H "Accept: application/javascript" "http://www.4shared.com/v0/files?oauth_consumer_key={application's
consumer key}"
If you're using JSONP, you need to pass a callback parameter: Global request parameters
oauth_consumer_key is used to do public API calls. PaginationThe default number of items you can receive is 100. This value can be changed by passing limit parameter; you can also change the starting item by passing offset parameter.
$ curl "http://www.4shared.com/v0/files?oauth_consumer_key={application consumer key}&offset=0&limit=20"
$ curl "http://www.4shared.com/v0/files?oauth_consumer_key={application consumer key}&offset=20&limit=20"
FilteringYou can search file lists by using keyword filtering. For example to find files that are relevant to the keyword "sky": $ curl "http://www.4shared.com/v0/files.json?oauth_consumer_key={application's consumer
key}&query=sky"
You can also filter file lists by categories. For example to find only video files: $ curl "http://www.4shared.com/v0/files.json?oauth_consumer_key={application's consumer key}&category=2"
Categories:
AuthenticationTo do public calls you need only application's consumer key, but to access resources on behalf of the 4shared user, your application should be granted access. 4shared uses OAuth 1.0 to authenticate API requests. See OAuth specification for details on authentication process. Endpoints
Error HandlingErrors are returned using HTTP status code. Additional information may be included in the body of the result. For example:
$ curl -i http://www.4shared.com/v0/user.json
HTTP/1.1 401 Unauthorized
Content-Type: application/json; charset=utf-8 Access-Control-Allow-Origin: * Access-Control-Allow-Methods: GET, PUT, POST, DELETE Access-Control-Allow-Headers: Authorization, Content-Type, Accept Content-Length: 30
{"ok":false,"message":"Bad or expired token","statusCode":401}
Common errors are:
|