Meet snAPI
PHPSnaps.com offers an API for non-commercial use by outside developers. Anyone can write new applications using PHPSnaps' data.
snAPI uses the REST architectural style for ease of use. For more information read this article.
All calls to snAPI methods REQUIRE a snAPI key. You can get a snAPI key from your account's management area.
Some calls will require POST data, all these are discussed on the specific pages for each method.
Jump to snAPI documentation.
More on the snAPI key
Your snAPI key ties your user account and the IP of the server where the calls are originating and gives you access to the snAPI calls.
Getting started
The endpoint for snAPI is http://api.phpsnaps.com
An example request:
An example response:
<rsp stat="1">
<call object="object" method="method" />
</rsp>
The object word in the snAPI request refers to objects inside the PHPSnaps data structure. Examples of objects are:
- Snaps
- People
- Tags
The method word is the set of actions that can occur on an object. For instance, object Snaps implements the method "latest" where it returns a set of the latest snaps added to PHPSnaps.
Arguments like arg1 in the example are variable data that customize the response of the method.
The key variable is your snAPI key linked to the IP of the server doing the request.
Response status
The root element of a snAPI response is called rsp. The root element has one attribute called stat, short for status. The value of stat will be, either zero for a failed response or one for a successful response.
You should always check the value of the stat attribute before parsing the rest of the XML tree.
In case of an error the response will contain one child node called err with two attributes: code and msg. Code is the unique error code of the error and msg is a user friendly message explaining why the request or the response failed.
<rsp stat="0">
<err code="[error-code]" msg="[error-message]" />
</rsp>
Helper code snippets
None added yet.
