# Titanium

> The top-level Titanium module.

- Source: https://titaniumsdk.com/docs/sdk/main/Titanium
- Titanium SDK version: main
- Kind: module
- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK 0.1
- Extends: Titanium.Module
- Inheritance: Titanium.Module > Titanium.Proxy

The Titanium module provides the Titanium Mobile API, allowing developers to access native
features of each target environment. Currently, the Android and iOSenvironments are supported.

#### Titanium Namespace

The complete Titanium API is accessible from the `Titanium` namespace but, for convenience and
brevity, the alias `Ti` is also provided. As the `Titanium` namespace is functionally-identical
to its `Ti` alias, it is always recommended to use `Ti` in your code.

For example, the following pairs of Titanium calls behave exactly the same.

``` js
Titanium.API.info('Hello Titanium!');
Ti.API.info('Hello Titanium!');

Titanium.Utils.sha256('Hello Titanium!');
Ti.Utils.sha256('Hello Titanium!');

Titanium.App.Properties.setString('hello_msg','Hello Titanium!');
Ti.App.Properties.setString('hello_msg','Hello Titanium!');

Titanium.Database.open('mydb');
Ti.Database.open('mydb');
```

#### Global APIs

Titanium includes a number of built-in JavaScript objects that are not part of the Titanium
namespace, including String formatting, timers, and the CommonJS `require` function.
See [Global APIs](https://titaniumsdk.com/docs/sdk/Global.md) for details.

## Properties

### buildDate

- Type: String
- Platforms: Android, iPhone, iPad, macOS
- Permission: read-only

Date of the Titanium build.

### buildHash

- Type: String
- Platforms: Android, iPhone, iPad, macOS
- Permission: read-only

Git hash of the Titanium build.

### userAgent

- Type: String
- Platforms: Android, iPhone, iPad, macOS

User-agent string used by Titanium.

### version

- Type: String
- Platforms: Android, iPhone, iPad, macOS
- Permission: read-only

Version of Titanium that is executing.

## Methods

### createBuffer

- Platforms: Android, iPhone, iPad, macOS

Creates a new buffer based on the params.

Parameters:

- `params` (CreateBufferArgs): creation arguments

Returns: Titanium.Buffer - The new buffer.

Example: Create a buffer with 1K bytes

``` js
var buffer = Ti.createBuffer({ length: 1024 });
```

Example: Create a buffer with string

Create a buffer with the string "hello world" encoded in UTF-8
``` js
var buffer = Ti.createBuffer({ value: "hello world" });
```

Example: Create a buffer with encoded float

Create a buffer with the encoded value of the double-precision floating point
number 1.234567 in Big Endian (network) byte order
``` js
var buffer = Ti.createBuffer({ value: 1.234567, type: Ti.Codec.TYPE_DOUBLE, byteOrder: Ti.Codec.BIG_ENDIAN });
```

## Inherited members

7 members are inherited. Each is documented on the type that declares it.

- [Titanium.Proxy](https://titaniumsdk.com/docs/sdk/main/Titanium.Proxy.md): `addEventListener`, `apiName`, `applyProperties`, `bubbleParent`, `fireEvent`, `lifecycleContainer`, `removeEventListener`

---

- This corpus documents Titanium SDK 13.4.1. Anything here that does not name a version describes 13.4.1.
- Titanium is maintained by TiDev. The Appcelerator toolchain is retired: there is no `appc` CLI, no Appcelerator Studio and no hosted build service. The supported CLI is `titanium` on npm, invoked as `ti`.

