--- a/api/classes/CTrends.php	2014-02-12 09:04:39.000000000 +0000
+++ b/api/classes/CTrends.php	2014-02-20 14:35:27.973240275 +0000
@@ -20,23 +20,23 @@
 
 
 /**
- * Class containing methods for operations with histories.
+ * Class containing methods for operations with trends.
  *
  * @package API
  */
-class CHistory extends CZBXAPI {
+class CTrends extends CZBXAPI {
 
-	protected $tableName = 'history';
+	protected $tableName = 'trends';
 	protected $tableAlias = 'h';
 	protected $sortColumns = array('itemid', 'clock');
 
 	public function __construct() {
-		// considering the quirky nature of the history API,
+		// considering the quirky nature of the trends API,
 		// the parent::__construct() method should not be called.
 	}
 
 	/**
-	 * Get history data.
+	 * Get trends data.
 	 *
 	 * @param array $options
 	 * @param array $options['itemids']
@@ -52,7 +52,7 @@
 		$nodeCheck = false;
 
 		$sqlParts = array(
-			'select'	=> array('history' => 'h.itemid'),
+			'select'	=> array('trends' => 'h.itemid'),
 			'from'		=> array(),
 			'where'		=> array(),
 			'group'		=> array(),
@@ -89,10 +89,14 @@
 		);
 		$options = zbx_array_merge($defOptions, $options);
 
-		if (!$tableName = CHistoryManager::getTableName($options['history'])) {
-			$tableName = 'history';
+		$tables = array(
+			ITEM_VALUE_TYPE_FLOAT => 'trends',
+			ITEM_VALUE_TYPE_UINT64 => 'trends_uint'
+		);
+		if (!$tableName = $tables[$options['history']]) {
+			$tableName = 'trends';
 		}
-		$sqlParts['from']['history'] = $tableName.' h';
+		$sqlParts['from']['trends'] = $tableName.' h';
 
 		// editable + PERMISSION CHECK
 		if (USER_TYPE_SUPER_ADMIN == self::$userData['type'] || $options['nopermissions']) {
@@ -156,18 +160,18 @@
 
 		// filter
 		if (is_array($options['filter'])) {
-			$this->dbFilter($sqlParts['from']['history'], $options, $sqlParts);
+			$this->dbFilter($sqlParts['from']['trends'], $options, $sqlParts);
 		}
 
 		// search
 		if (is_array($options['search'])) {
-			zbx_db_search($sqlParts['from']['history'], $options, $sqlParts);
+			zbx_db_search($sqlParts['from']['trends'], $options, $sqlParts);
 		}
 
 		// output
 		if ($options['output'] == API_OUTPUT_EXTEND) {
 			unset($sqlParts['select']['clock']);
-			$sqlParts['select']['history'] = 'h.*';
+			$sqlParts['select']['trends'] = 'h.*';
 		}
 
 		// countOutput
@@ -273,21 +277,4 @@
 		}
 		return $result;
 	}
-
-	protected function applyQuerySortOptions($tableName, $tableAlias, array $options, array $sqlParts) {
-		$isIdFieldUsed = false;
-
-		if ($options['history'] == ITEM_VALUE_TYPE_LOG || $options['history'] == ITEM_VALUE_TYPE_TEXT) {
-			$this->sortColumns['id'] = 'id';
-			$isIdFieldUsed = true;
-		}
-
-		$sqlParts = parent::applyQuerySortOptions($tableName, $tableAlias, $options, $sqlParts);
-
-		if ($isIdFieldUsed) {
-			unset($this->sortColumns['id']);
-		}
-
-		return $sqlParts;
-	}
--- a/include/classes/api/API.php	2014-02-12 09:04:38.000000000 +0000
+++ b/include/classes/api/API.php	2014-02-20 14:39:43.586414478 +0000
@@ -68,6 +68,7 @@
 		'template' => 'CTemplate',
 		'templatescreen' => 'CTemplateScreen',
 		'templatescreenitem' => 'CTemplateScreenItem',
+		'trends' => 'CTrends',
 		'trigger' => 'CTrigger',
 		'triggerprototype' => 'CTriggerPrototype',
 		'user' => 'CUser',
@@ -378,6 +379,13 @@
 	}
 
 	/**
+	 * @return CTrends
+	 */
+	public static function Trends() {
+		return self::getObject('trends');
+	}
+
+	/**
 	 * @return CTrigger
 	 */
 	public static function Trigger() {
