Welcome to Pakt!

Developer Resources

Pakt.com JSON (JavaScript Object Notation) Web Services

Pakt.com offers developers the ability to mashup its content using JSON.

JSON is a lightweight computer data interchange format. It is a text-based, human-readable format for representing simple data structures and associative arrays (called objects). It does not require JavaScript to read or write; it is easy to parse by any language and libraries and tools exist in many languages to handle JSON.

Basically, it's the fat-free alternative to XML. Check out JSON.org for more information on JSON.

This page describes the Pakt.com JSON Web Services. Some examples for implementation are provided below as well.

General Data objects provided in JSON request

ResultSet : The top level data object
TotalRecordsAvailable : Total number of records available for requested query
RecordsReturned : Number of records returned for this query
PageSize : Max number of records to return for this query
StartPosition : Starting record offset for query
Result : Array of [RecordsReturned] records of Pakt tutorial data

Data objects provided in Result array

url : URL location of Pakt tutorial
date : Date that the Pakt was created or last updated
rating : Community feedback rating of Pakt tutorial
language : Language of the Pakt tutorial
category : Category of Pakt tutorial
sub_category : Sub Category of Pakt tutorial
title : Title of Pakt tutorial
image : Logo image location for this Pakt tutorial

Simple JSON request

The JSON request returns the output wrapped in a callback function called "pakt_json_results". A basic example of a JSON request to pakt.com is demonstrated below.

<html>
<head>
<title>Popular Pakts</title>
</head>
</body>
<script type="text/javascript">
    function pakt_json_results(obj) {
        alert(obj.ResultSet.Result[0].title);
    }
</script>
<script type="text/javascript" src="http://www.pakt.com/developer/json/"></script>
<body></body>
</html>

The code above will display a message box with the Pakt tutorial title of the first element in the JSON data object.

JSON query options

The developer can vary the javascript src url with the following options

type : The type of query to be performed. Options are "popular" or "new". "Popular" sorts the results by their rating. "New" sorts the results by date. Example: Returns the first 100 popular Pakt tutorials.

http://www.pakt.com/developer/json/?type=popular

query : Query string used to search through records. Example: Return only Pakt tutorials related to the keystring "dog", sort by popularity.

http://www.pakt.com/developer/json/?type=popular&query=dog

size : Specify the number of records to return per request. Example: Return the 5 most recent Pakt tutorials.

http://www.pakt.com/developer/json/?type=new&size=5

start : Specify the starting record number. Example: Return the 5 most recent Pakt tutorials starting at record 20.

http://www.pakt.com/developer/json/?type=new&size=5&start=20

user : Specify the author of the Pakt tutorials. Example: Return all Pakt tutorials created by user "chris".

http://www.pakt.com/developer/json/?user=chris

language : Specify the Pakt tutorial language. Example: Return all French Pakt tutorials.

http://www.pakt.com/developer/json/?language=french

Example JSON Data

The example below demonstrates the JSON output for the following query that grabs the newest Pakt tutorial from user "chris".

http://www.pakt.com/developer/json/?type=new&user=chris&size=1

View resulting JSON data object below.

pakt_json_results({
"ResultSet":{
    "TotalRecordsAvailable":"11",
    "RecordsReturned":"1",
    "PageSize":"1",
    "StartPosition":"0",
    "Result":[{
        "url":"http://www.pakt.com/pakt/?id=7201bd363804d2f317702f0bf16f3ddc&t=Take_the_Live_Earth_Pledge",
        "date":"Sep 24, 2007",
        "rating":"4.7 / 5",
        "language":"American-English",
        "category":"Environment",
        "sub_category":"Activism",
        "title":"Take the Live Earth Pledge",
        "image":"http://images.pakt.com/images/user/chris/chris_db85f60386259f0.jpg"
    }]
}})

Thanks for reading! Please let us know about creative ways that you are using this data!

Pakt development team.