public function getAPIAttributes($params=array(), $relations = false)
    {
        $attributes = array();
        foreach ($this->attributes as $k=>$v)
        {
        	if (in_array($k, $params))
        		continue;

            $attributes[$k] = $v;
        }

        if ($relations != false)
        {
	        foreach ($relations as $relation=>$params)
	        {
	        	if (is_integer($relation))
	        	{
	        		$relation = $params;
	        		$params = array();
	        	}

	        	if (is_array($this->$relation))
	        	{
	        		$attributes[$relation] = array();
	        		foreach ($this->$relation as $k)
	        			$attributes[$relation][] = $k->getAPIAttributes($params);
	        	}
	        	else
	        	{
	        		if (isset($this->$relation))
	        			$attributes[$relation] = $this->$relation->getAPIAttributes($params);
	        		else
	        			$attributes[$relation] = array();
	        	}
	        }
        }

        return $attributes;
    }