PubNub's Storage & Playback feature enables developers to store messages as they are published, and retrieve them at a later time. Our storage layer is a time-series based database. Each published message is timestamped to the nearest 10 nanoseconds.
Learn more about our Storage & Playback feature here.
This function fetches historical messages of a channel.
PubNub Storage/Playback Service provides real-time access to an unlimited history for all messages published to PubNub. Stored messages are replicated across multiple availability zones in several geographical data center locations. Stored messages can be encrypted with AES-256 message encryption ensuring that they are not readable while stored on PubNub's network.
It is possible to control how messages are returned and in what order, for example you can:
- Search for messages starting on the newest end of the timeline (default behavior -
reverse
= false
) - Search for messages from the oldest end of the timeline by setting
reverse
to true
. - Page through results by providing a
start
OR end
time token. - Retrieve a slice of the time line by providing both a
start
AND end
time token. - Limit the number of messages to a specific quantity using the
count
parameter.
| Start & End parameter usage clarity: If only the start parameter is specified (without end ), you will receive messages that are older than and up to that start timetoken value. If only the end parameter is specified (without start ) you will receive messages that match that end timetoken value and newer. Specifying values for both start and end parameters will return messages between those timetoken values (inclusive on the end value). Keep in mind that you will still receive a maximum of 100 messages even if there are more messages that meet the timetoken values. Iterative calls to history adjusting the start timetoken is necessary to page through the full set of results if more than 100 messages meet the timetoken values. |
To run History
you can use the following method(s) in the Vue V4 SDK
Retrieve the last 100 messages on a channel:
import PubNubVue from 'pubnub-vue';
const pubnub = PubNubVue.getInstance();
pubnub.history(
{
channel: 'history_channel',
count: 100, // how many items to fetch
stringifiedTimeToken: true, // false is the default
},
function(status, response) {
// handle status, response
}
);
// Example of Status
{
error: false,
operation: "PNHistoryOperation",
statusCode: 200
}
// Example of Response
{
endTimeToken: "14867650866860159",
messages: [
{
timetoken: "14867650866860159",
entry: "[User 636] hello World"
},
{...},
{...},
{...}
],
startTimeToken: "14867650866860159"
}
This function fetches historical messages of a channel.
PubNub Storage/Playback Service provides real-time access to an unlimited history for all messages published to PubNub. Stored messages are replicated across multiple availability zones in several geographical data center locations. Stored messages can be encrypted with AES-256 message encryption ensuring that they are not readable while stored on PubNub's network.
It is possible to control how messages are returned and in what order, for example you can:
- Page through results by providing a
start
OR end
time token. - Retrieve a slice of the time line by providing both a
start
AND end
time token. - Limit the number of messages to a specific quantity using the
count
parameter.
| The batch history is limited to 500 channels and only the last 25 messages per channel. |
| Start & End parameter usage clarity: If only the start parameter is specified (without end ), you will receive messages that are older than and up to that start timetoken value. If only the end parameter is specified (without start ) you will receive messages that match that end timetoken value and newer. Specifying values for both start and end parameters will return messages between those timetoken values (inclusive on the end value). Keep in mind that you will still receive a maximum of 25 messages per channel even if there are more messages that meet the timetoken values. |
To run Batch History
you can use the following method(s) in the Vue V4 SDK
Retrieve the last 25 messages on a channel:
import PubNubVue from 'pubnub-vue';
const pubnub = PubNubVue.getInstance();
// assuming pubnub is an initialized instance
// start, end, count are optional
pubnub.fetchMessages(
{
channels: ['ch1', 'ch2', 'ch3'],
start: "15343325214676133",
end: "15343325004275466",
count: 30
},
function(status, response) {
// handle response
}
);
//Example of status
{
error: false,
operation: 'PNFetchMessagesOperation',
statusCode: 200
}
//Example of response
{
channels:
{
"my-channel":[{
"message":"message_1",
"timetoken":"15483367794816642"
},
{
"message":"message_2",
"timetoken":"15483367810978163"
},
{
"message":"message_3",
"timetoken":"15483367819545303"
},
{
"message":"message_4",
"timetoken":"15483367827886667"
}]
"my-channel-2":[{
"message":"message_1",
"timetoken":"15483367827886667"
},
{
"message":"message_2",
"timetoken":"15483367819545303"
},
{
"message":"message_3",
"timetoken":"15483367810978163"
},
{
"message":"message_4",
"timetoken":"15483367794816642"
}]
"my-channel-3":[{
"message":"message_1",
"timetoken":"15483373338046565"
},
{
"message":"message_2",
"timetoken":"15483373303521793"
},
{
"message":"message_3",
"timetoken":"15483373407379141"
},
{
"message":"message_4",
"timetoken":"15483373366944653"
}]
}
}
Removes the messages from the history of a specific channel.
| There is a setting to accept delete from history requests for a key, which you must enable by checking the Enable Delete-From-History checkbox in the key settings for your key in the Administration Portal.
Requires Initialization with secret key. |
To Delete Messages from History
you can use the following method(s) in the Vue V4 SDK.
import PubNubVue from 'pubnub-vue';
const pubnub = PubNubVue.getInstance();
pubnub.deleteMessages(
{
channel: 'ch1',
start: '15088506076921021',
end: '15088532035597390'
},
function(result) {
console.log(result);
}
);
{
error: false,
operation: 'PNDeleteMessagesOperation',
statusCode: 200
}
PubNub's Storage & Playback feature enables developers to store messages as they are published, and retrieve them at a later time. Our storage layer is a time-series based database. Each published message is timestamped to the nearest 10 nanoseconds.
Learn more about our Storage & Playback feature here.
This function fetches historical messages of a channel.
PubNub Storage/Playback Service provides real-time access to an unlimited history for all messages published to PubNub. Stored messages are replicated across multiple availability zones in several geographical data center locations. Stored messages can be encrypted with AES-256 message encryption ensuring that they are not readable while stored on PubNub's network.
It is possible to control how messages are returned and in what order, for example you can:
- Search for messages starting on the newest end of the timeline (default behavior -
reverse
= false
) - Search for messages from the oldest end of the timeline by setting
reverse
to true
. - Page through results by providing a
start
OR end
time token. - Retrieve a slice of the time line by providing both a
start
AND end
time token. - Limit the number of messages to a specific quantity using the
count
parameter.
| Start & End parameter usage clarity: If only the start parameter is specified (without end ), you will receive messages that are older than and up to that start timetoken value. If only the end parameter is specified (without start ) you will receive messages that match that end timetoken value and newer. Specifying values for both start and end parameters will return messages between those timetoken values (inclusive on the end value). Keep in mind that you will still receive a maximum of 100 messages even if there are more messages that meet the timetoken values. Iterative calls to history adjusting the start timetoken is necessary to page through the full set of results if more than 100 messages meet the timetoken values. |
To run History
you can use the following method(s) in the Node.js V4 SDK
Retrieve the last 100 messages on a channel:
pubnub.history(
{
channel: 'history_channel',
count: 100, // how many items to fetch
stringifiedTimeToken: true, // false is the default
},
function (status, response) {
// handle status, response
}
);
// Example of Status
{
error: false,
operation: "PNHistoryOperation",
statusCode: 200
}
// Example of Response
{
endTimeToken: "14867650866860159",
messages: [
{
timetoken: "14867650866860159",
entry: "[User 636] hello World"
},
{...},
{...},
{...}
],
startTimeToken: "14867650866860159"
}
This function fetches historical messages of a channel.
PubNub Storage/Playback Service provides real-time access to an unlimited history for all messages published to PubNub. Stored messages are replicated across multiple availability zones in several geographical data center locations. Stored messages can be encrypted with AES-256 message encryption ensuring that they are not readable while stored on PubNub's network.
It is possible to control how messages are returned and in what order, for example you can:
- Page through results by providing a
start
OR end
time token. - Retrieve a slice of the time line by providing both a
start
AND end
time token. - Limit the number of messages to a specific quantity using the
count
parameter.
| The batch history is limited to 500 channels and only the last 25 messages per channel. |
| Start & End parameter usage clarity: If only the start parameter is specified (without end ), you will receive messages that are older than and up to that start timetoken value. If only the end parameter is specified (without start ) you will receive messages that match that end timetoken value and newer. Specifying values for both start and end parameters will return messages between those timetoken values (inclusive on the end value). Keep in mind that you will still receive a maximum of 25 messages per channel even if there are more messages that meet the timetoken values. |
To run Batch History
you can use the following method(s) in the Node.js V4 SDK
Retrieve the last 25 messages on a channel:
// assuming pubnub is an initialized instance
// start, end, count are optional
pubnub.fetchMessages(
{
channels: ['ch1', 'ch2', 'ch3'],
start: "15343325214676133",
end: "15343325004275466",
count: 25
},
(status, response) => {
// handle response
}
);
//Example of status
{
error: false,
operation: 'PNFetchMessagesOperation',
statusCode: 200
}
//Example of response
{
channels:
{
"my-channel":[{
"message":"message_1",
"timetoken":"15483367794816642"
},
{
"message":"message_2",
"timetoken":"15483367810978163"
},
{
"message":"message_3",
"timetoken":"15483367819545303"
},
{
"message":"message_4",
"timetoken":"15483367827886667"
}]
"my-channel-2":[{
"message":"message_1",
"timetoken":"15483367827886667"
},
{
"message":"message_2",
"timetoken":"15483367819545303"
},
{
"message":"message_3",
"timetoken":"15483367810978163"
},
{
"message":"message_4",
"timetoken":"15483367794816642"
}]
"my-channel-3":[{
"message":"message_1",
"timetoken":"15483373338046565"
},
{
"message":"message_2",
"timetoken":"15483373303521793"
},
{
"message":"message_3",
"timetoken":"15483373407379141"
},
{
"message":"message_4",
"timetoken":"15483373366944653"
}]
}
}
Removes the messages from the history of a specific channel.
| There is a setting to accept delete from history requests for a key, which you must enable by checking the Enable Delete-From-History checkbox in the key settings for your key in the Administration Portal.
Requires Initialization with secret key. |
To Delete Messages from History
you can use the following method(s) in the Node.js V4 SDK.
pubnub.deleteMessages(
{
channel: 'ch1',
start: '15088506076921021',
end: '15088532035597390'
},
(result) => {
console.log(result);
}
);
{
error: false,
operation: 'PNDeleteMessagesOperation',
statusCode: 200
}
PubNub's Storage & Playback feature enables developers to store messages as they are published, and retrieve them at a later time. Our storage layer is a time-series based database. Each published message is timestamped to the nearest 10 nanoseconds.
Learn more about our Storage & Playback feature here.
This function fetches historical messages of a channel.
PubNub Storage/Playback Service provides real-time access to an unlimited history for all messages published to PubNub. Stored messages are replicated across multiple availability zones in several geographical data center locations. Stored messages can be encrypted with AES-256 message encryption ensuring that they are not readable while stored on PubNub's network.
It is possible to control how messages are returned and in what order, for example you can:
- Search for messages starting on the newest end of the timeline (default behavior -
reverse
= false
) - Search for messages from the oldest end of the timeline by setting
reverse
to true
. - Page through results by providing a
start
OR end
time token. - Retrieve a slice of the time line by providing both a
start
AND end
time token. - Limit the number of messages to a specific quantity using the
count
parameter.
| Start & End parameter usage clarity: If only the start parameter is specified (without end ), you will receive messages that are older than and up to that start timetoken value. If only the end parameter is specified (without start ) you will receive messages that match that end timetoken value and newer. Specifying values for both start and end parameters will return messages between those timetoken values (inclusive on the end value). Keep in mind that you will still receive a maximum of 100 messages even if there are more messages that meet the timetoken values. Iterative calls to history adjusting the start timetoken is necessary to page through the full set of results if more than 100 messages meet the timetoken values. |
To run History
you can use the following method(s) in the PhoneGap V4 SDK
Retrieve the last 100 messages on a channel:
pubnub.history(
{
channel: 'history_channel',
count: 100, // how many items to fetch
stringifiedTimeToken: true, // false is the default
},
function (status, response) {
// handle status, response
}
);
// Example of Status
{
error: false,
operation: "PNHistoryOperation",
statusCode: 200
}
// Example of Response
{
endTimeToken: "14867650866860159",
messages: [
{
timetoken: "14867650866860159",
entry: "[User 636] hello World"
},
{...},
{...},
{...}
],
startTimeToken: "14867650866860159"
}
This function fetches historical messages of a channel.
PubNub Storage/Playback Service provides real-time access to an unlimited history for all messages published to PubNub. Stored messages are replicated across multiple availability zones in several geographical data center locations. Stored messages can be encrypted with AES-256 message encryption ensuring that they are not readable while stored on PubNub's network.
It is possible to control how messages are returned and in what order, for example you can:
- Page through results by providing a
start
OR end
time token. - Retrieve a slice of the time line by providing both a
start
AND end
time token. - Limit the number of messages to a specific quantity using the
count
parameter.
| The batch history is limited to 500 channels and only the last 25 messages per channel. |
| Start & End parameter usage clarity: If only the start parameter is specified (without end ), you will receive messages that are older than and up to that start timetoken value. If only the end parameter is specified (without start ) you will receive messages that match that end timetoken value and newer. Specifying values for both start and end parameters will return messages between those timetoken values (inclusive on the end value). Keep in mind that you will still receive a maximum of 25 messages per channel even if there are more messages that meet the timetoken values. |
To run Batch History
you can use the following method(s) in the PhoneGap V4 SDK
Retrieve the last 25 messages on a channel:
// assuming pubnub is an initialized instance
// start, end, count are optional
pubnub.fetchMessages(
{
channels: ['ch1', 'ch2', 'ch3'],
start: "15343325214676133",
end: "15343325004275466",
count: 25
},
(status, response) => {
// handle response
}
);
//Example of status
{
error: false,
operation: 'PNFetchMessagesOperation',
statusCode: 200
}
//Example of response
{
channels:
{
"my-channel":[{
"message":"message_1",
"timetoken":"15483367794816642"
},
{
"message":"message_2",
"timetoken":"15483367810978163"
},
{
"message":"message_3",
"timetoken":"15483367819545303"
},
{
"message":"message_4",
"timetoken":"15483367827886667"
}]
"my-channel-2":[{
"message":"message_1",
"timetoken":"15483367827886667"
},
{
"message":"message_2",
"timetoken":"15483367819545303"
},
{
"message":"message_3",
"timetoken":"15483367810978163"
},
{
"message":"message_4",
"timetoken":"15483367794816642"
}]
"my-channel-3":[{
"message":"message_1",
"timetoken":"15483373338046565"
},
{
"message":"message_2",
"timetoken":"15483373303521793"
},
{
"message":"message_3",
"timetoken":"15483373407379141"
},
{
"message":"message_4",
"timetoken":"15483373366944653"
}]
}
}
Removes the messages from the history of a specific channel.
| There is a setting to accept delete from history requests for a key, which you must enable by checking the Enable Delete-From-History checkbox in the key settings for your key in the Administration Portal.
Requires Initialization with secret key. |
To Delete Messages from History
you can use the following method(s) in the PhoneGap V4 SDK.
pubnub.deleteMessages(
{
channel: 'ch1',
start: '15088506076921021',
end: '15088532035597390'
},
(result) => {
console.log(result);
}
);
{
error: false,
operation: 'PNDeleteMessagesOperation',
statusCode: 200
}
Beta Version Available! | A beta release of the PubNub React framework, version 2.0 is now available. You can access it in the v2.0 branch of the react repository. |
PubNub's Storage & Playback feature enables developers to store messages as they are published, and retrieve them at a later time. Our storage layer is a time-series based database. Each published message is timestamped to the nearest 10 nanoseconds.
Learn more about our Storage & Playback feature here.
This function fetches historical messages of a channel.
PubNub Storage/Playback Service provides real-time access to an unlimited history for all messages published to PubNub. Stored messages are replicated across multiple availability zones in several geographical data center locations. Stored messages can be encrypted with AES-256 message encryption ensuring that they are not readable while stored on PubNub's network.
It is possible to control how messages are returned and in what order, for example you can:
- Search for messages starting on the newest end of the timeline (default behavior -
reverse
= false
) - Search for messages from the oldest end of the timeline by setting
reverse
to true
. - Page through results by providing a
start
OR end
time token. - Retrieve a slice of the time line by providing both a
start
AND end
time token. - Limit the number of messages to a specific quantity using the
count
parameter.
| Start & End parameter usage clarity: If only the start parameter is specified (without end ), you will receive messages that are older than and up to that start timetoken value. If only the end parameter is specified (without start ) you will receive messages that match that end timetoken value and newer. Specifying values for both start and end parameters will return messages between those timetoken values (inclusive on the end value). Keep in mind that you will still receive a maximum of 100 messages even if there are more messages that meet the timetoken values. Iterative calls to history adjusting the start timetoken is necessary to page through the full set of results if more than 100 messages meet the timetoken values. |
To run History
you can use the following method(s) in the React V4 SDK
Retrieve the last 100 messages on a channel:
this.pubnub.history(
{
channel: 'my_channel',
count: 100, // 100 is the default
stringifiedTimeToken: true // false is the default
},
(status, response) => {
console.log(response);
}
);
// Example of Status
{
error: false,
operation: "PNHistoryOperation",
statusCode: 200
}
// Example of Response
{
endTimeToken: "14867650866860159",
messages: [
{
timetoken: "14867650866860159",
entry: "[User 636] hello World"
},
{...},
{...},
{...}
],
startTimeToken: "14867650866860159"
}
This function fetches historical messages of a channel.
PubNub Storage/Playback Service provides real-time access to an unlimited history for all messages published to PubNub. Stored messages are replicated across multiple availability zones in several geographical data center locations. Stored messages can be encrypted with AES-256 message encryption ensuring that they are not readable while stored on PubNub's network.
It is possible to control how messages are returned and in what order, for example you can:
- Page through results by providing a
start
OR end
time token. - Retrieve a slice of the time line by providing both a
start
AND end
time token. - Limit the number of messages to a specific quantity using the
count
parameter.
| The batch history is limited to 500 channels and only the last 25 messages per channel. |
| Start & End parameter usage clarity: If only the start parameter is specified (without end ), you will receive messages that are older than and up to that start timetoken value. If only the end parameter is specified (without start ) you will receive messages that match that end timetoken value and newer. Specifying values for both start and end parameters will return messages between those timetoken values (inclusive on the end value). Keep in mind that you will still receive a maximum of 25 messages per channel even if there are more messages that meet the timetoken values. |
To run Batch History
you can use the following method(s) in the React V4 SDK
Retrieve the last 25 messages on a channel:
// assuming pubnub is an initialized instance
// start, end, count are optional
pubnub.fetchMessages(
{
channels: ['ch1', 'ch2', 'ch3'],
start: "15343325214676133",
end: "15343325004275466",
count: 25
},
(status, response) => {
// handle response
}
);
//Example of status
{
error: false,
operation: 'PNFetchMessagesOperation',
statusCode: 200
}
//Example of response
{
channels:
{
"my-channel":[{
"message":"message_1",
"timetoken":"15483367794816642"
},
{
"message":"message_2",
"timetoken":"15483367810978163"
},
{
"message":"message_3",
"timetoken":"15483367819545303"
},
{
"message":"message_4",
"timetoken":"15483367827886667"
}]
"my-channel-2":[{
"message":"message_1",
"timetoken":"15483367827886667"
},
{
"message":"message_2",
"timetoken":"15483367819545303"
},
{
"message":"message_3",
"timetoken":"15483367810978163"
},
{
"message":"message_4",
"timetoken":"15483367794816642"
}]
"my-channel-3":[{
"message":"message_1",
"timetoken":"15483373338046565"
},
{
"message":"message_2",
"timetoken":"15483373303521793"
},
{
"message":"message_3",
"timetoken":"15483373407379141"
},
{
"message":"message_4",
"timetoken":"15483373366944653"
}]
}
}
Removes the messages from the history of a specific channel.
| There is a setting to accept delete from history requests for a key, which you must enable by checking the Enable Delete-From-History checkbox in the key settings for your key in the Administration Portal.
Requires Initialization with secret key. |
To Delete Messages from History
you can use the following method(s) in the React V4 SDK.
pubnub.deleteMessages(
{
channel: 'ch1',
start: '15088506076921021',
end: '15088532035597390'
},
(result) => {
console.log(result);
}
);
{
error: false,
operation: 'PNDeleteMessagesOperation',
statusCode: 200
}
PubNub's Storage & Playback feature enables developers to store messages as they are published, and retrieve them at a later time. Our storage layer is a time-series based database. Each published message is timestamped to the nearest 10 nanoseconds.
Learn more about our Storage & Playback feature here.
This function fetches historical messages of a channel.
PubNub Storage/Playback Service provides real-time access to an unlimited history for all messages published to PubNub. Stored messages are replicated across multiple availability zones in several geographical data center locations. Stored messages can be encrypted with AES-256 message encryption ensuring that they are not readable while stored on PubNub's network.
It is possible to control how messages are returned and in what order, for example you can:
- Search for messages starting on the newest end of the timeline (default behavior -
reverse
= false
) - Search for messages from the oldest end of the timeline by setting
reverse
to true
. - Page through results by providing a
start
OR end
time token. - Retrieve a slice of the time line by providing both a
start
AND end
time token. - Limit the number of messages to a specific quantity using the
count
parameter.
| Start & End parameter usage clarity: If only the start parameter is specified (without end ), you will receive messages that are older than and up to that start timetoken value. If only the end parameter is specified (without start ) you will receive messages that match that end timetoken value and newer. Specifying values for both start and end parameters will return messages between those timetoken values (inclusive on the end value). Keep in mind that you will still receive a maximum of 100 messages even if there are more messages that meet the timetoken values. Iterative calls to history adjusting the start timetoken is necessary to page through the full set of results if more than 100 messages meet the timetoken values. |
To run History
you can use the following method(s) in the Titanium V4 SDK
Retrieve the last 100 messages on a channel:
pubnub.history(
{
channel: 'my_channel',
count: 100, // 100 is the default
stringifiedTimeToken: true // false is the default
},
function (status, response) {
console.log(response);
}
);
// Example of Status
{
error: false,
operation: "PNHistoryOperation",
statusCode: 200
}
// Example of Response
{
endTimeToken: "14867650866860159",
messages: [
{
timetoken: "14867650866860159",
entry: "[User 636] hello World"
},
{...},
{...},
{...}
],
startTimeToken: "14867650866860159"
}
This function fetches historical messages of a channel.
PubNub Storage/Playback Service provides real-time access to an unlimited history for all messages published to PubNub. Stored messages are replicated across multiple availability zones in several geographical data center locations. Stored messages can be encrypted with AES-256 message encryption ensuring that they are not readable while stored on PubNub's network.
It is possible to control how messages are returned and in what order, for example you can:
- Page through results by providing a
start
OR end
time token. - Retrieve a slice of the time line by providing both a
start
AND end
time token. - Limit the number of messages to a specific quantity using the
count
parameter.
| The batch history is limited to 500 channels and only the last 25 messages per channel. |
| Start & End parameter usage clarity: If only the start parameter is specified (without end ), you will receive messages that are older than and up to that start timetoken value. If only the end parameter is specified (without start ) you will receive messages that match that end timetoken value and newer. Specifying values for both start and end parameters will return messages between those timetoken values (inclusive on the end value). Keep in mind that you will still receive a maximum of 25 messages per channel even if there are more messages that meet the timetoken values. |
To run Batch History
you can use the following method(s) in the Titanium V4 SDK
Retrieve the last 25 messages on a channel:
// assuming pubnub is an initialized instance
// start, end, count are optional
pubnub.fetchMessages(
{
channels: ['ch1', 'ch2', 'ch3'],
start: "15343325214676133",
end: "15343325004275466",
count: 25
},
(status, response) => {
// handle response
}
);
//Example of status
{
error: false,
operation: 'PNFetchMessagesOperation',
statusCode: 200
}
//Example of response
{
channels:
{
"my-channel":[{
"message":"message_1",
"timetoken":"15483367794816642"
},
{
"message":"message_2",
"timetoken":"15483367810978163"
},
{
"message":"message_3",
"timetoken":"15483367819545303"
},
{
"message":"message_4",
"timetoken":"15483367827886667"
}]
"my-channel-2":[{
"message":"message_1",
"timetoken":"15483367827886667"
},
{
"message":"message_2",
"timetoken":"15483367819545303"
},
{
"message":"message_3",
"timetoken":"15483367810978163"
},
{
"message":"message_4",
"timetoken":"15483367794816642"
}]
"my-channel-3":[{
"message":"message_1",
"timetoken":"15483373338046565"
},
{
"message":"message_2",
"timetoken":"15483373303521793"
},
{
"message":"message_3",
"timetoken":"15483373407379141"
},
{
"message":"message_4",
"timetoken":"15483373366944653"
}]
}
}
Removes the messages from the history of a specific channel.
| There is a setting to accept delete from history requests for a key, which you must enable by checking the Enable Delete-From-History checkbox in the key settings for your key in the Administration Portal.
Requires Initialization with secret key. |
To Delete Messages from History
you can use the following method(s) in the Titanium V4 SDK.
pubnub.deleteMessages(
{
channel: 'ch1',
start: '15088506076921021',
end: '15088532035597390'
},
(result) => {
console.log(result);
}
);
{
error: false,
operation: 'PNDeleteMessagesOperation',
statusCode: 200
}
PubNub's Storage & Playback feature enables developers to store messages as they are published, and retrieve them at a later time. Our storage layer is a time-series based database. Each published message is timestamped to the nearest 10 nanoseconds.
Learn more about our Storage & Playback feature here.
This function fetches historical messages of a channel.
PubNub Storage/Playback Service provides real-time access to an unlimited history for all messages published to PubNub. Stored messages are replicated across multiple availability zones in several geographical data center locations. Stored messages can be encrypted with AES-256 message encryption ensuring that they are not readable while stored on PubNub's network.
It is possible to control how messages are returned and in what order, for example you can:
- Search for messages starting on the newest end of the timeline (default behavior -
reverse
= false
) - Search for messages from the oldest end of the timeline by setting
reverse
to true
. - Page through results by providing a
start
OR end
time token. - Retrieve a slice of the time line by providing both a
start
AND end
time token. - Limit the number of messages to a specific quantity using the
count
parameter.
| Start & End parameter usage clarity: If only the start parameter is specified (without end ), you will receive messages that are older than and up to that start timetoken value. If only the end parameter is specified (without start ) you will receive messages that match that end timetoken value and newer. Specifying values for both start and end parameters will return messages between those timetoken values (inclusive on the end value). Keep in mind that you will still receive a maximum of 100 messages even if there are more messages that meet the timetoken values. Iterative calls to history adjusting the start timetoken is necessary to page through the full set of results if more than 100 messages meet the timetoken values. |
To run History
you can use the following method(s) in the JavaScript V4 SDK
Retrieve the last 100 messages on a channel:
pubnub.history(
{
channel: 'history_channel',
count: 100, // how many items to fetch
stringifiedTimeToken: true, // false is the default
},
function (status, response) {
// handle status, response
}
);
// Example of Status
{
error: false,
operation: "PNHistoryOperation",
statusCode: 200
}
// Example of Response
{
endTimeToken: "14867650866860159",
messages: [
{
timetoken: "14867650866860159",
entry: "[User 636] hello World"
},
{...},
{...},
{...}
],
startTimeToken: "14867650866860159"
}
This function fetches historical messages of a channel.
PubNub Storage/Playback Service provides real-time access to an unlimited history for all messages published to PubNub. Stored messages are replicated across multiple availability zones in several geographical data center locations. Stored messages can be encrypted with AES-256 message encryption ensuring that they are not readable while stored on PubNub's network.
It is possible to control how messages are returned and in what order, for example you can:
- Page through results by providing a
start
OR end
time token. - Retrieve a slice of the time line by providing both a
start
AND end
time token. - Limit the number of messages to a specific quantity using the
count
parameter.
| The batch history is limited to 500 channels and only the last 25 messages per channel. |
| Start & End parameter usage clarity: If only the start parameter is specified (without end ), you will receive messages that are older than and up to that start timetoken value. If only the end parameter is specified (without start ) you will receive messages that match that end timetoken value and newer. Specifying values for both start and end parameters will return messages between those timetoken values (inclusive on the end value). Keep in mind that you will still receive a maximum of 25 messages per channel even if there are more messages that meet the timetoken values. |
To run Batch History
you can use the following method(s) in the JavaScript V4 SDK
Retrieve the last 25 messages on a channel:
// assuming pubnub is an initialized instance
// start, end, count are optional
pubnub.fetchMessages(
{
channels: ['ch1', 'ch2', 'ch3'],
start: "15343325214676133",
end: "15343325004275466",
count: 25
},
(status, response) => {
// handle response
}
);
//Example of status
{
error: false,
operation: 'PNFetchMessagesOperation',
statusCode: 200
}
//Example of response
{
channels:
{
"my-channel":[{
"message":"message_1",
"timetoken":"15483367794816642"
},
{
"message":"message_2",
"timetoken":"15483367810978163"
},
{
"message":"message_3",
"timetoken":"15483367819545303"
},
{
"message":"message_4",
"timetoken":"15483367827886667"
}]
"my-channel-2":[{
"message":"message_1",
"timetoken":"15483367827886667"
},
{
"message":"message_2",
"timetoken":"15483367819545303"
},
{
"message":"message_3",
"timetoken":"15483367810978163"
},
{
"message":"message_4",
"timetoken":"15483367794816642"
}]
"my-channel-3":[{
"message":"message_1",
"timetoken":"15483373338046565"
},
{
"message":"message_2",
"timetoken":"15483373303521793"
},
{
"message":"message_3",
"timetoken":"15483373407379141"
},
{
"message":"message_4",
"timetoken":"15483373366944653"
}]
}
}
Removes the messages from the history of a specific channel.
| There is a setting to accept delete from history requests for a key, which you must enable by checking the Enable Delete-From-History checkbox in the key settings for your key in the Administration Portal.
Requires Initialization with secret key. |
To Delete Messages from History
you can use the following method(s) in the JavaScript V4 SDK.
pubnub.deleteMessages(
{
channel: 'ch1',
start: '15088506076921021',
end: '15088532035597390'
},
(result) => {
console.log(result);
}
);
{
error: false,
operation: 'PNDeleteMessagesOperation',
statusCode: 200
}
Returns the number of messages published on one or more channels since a given time. The count
returned is the number of messages in history with a timetoken
value greater
than the passed value in the channelTimetokens
parameter.
| For keys with unlimited message retention enabled, this method considers only messages published in the last 7 days. |
You can use the following method(s) in the JavaScript V4 SDK:
pubnub.messageCounts(
{
channels: ['ch1'],
channelTimetokens: ['15518041524300251']
},
(status, results) => {
console.log(status);
console.log(results);
}
);
| Channels without messages have a count of 0. Channels with 10,000 messages or more have a count of 10000. |
{
channels: {
ch1: 49
}
}
{
error: false,
operation: 'PNMessageCountsOperation',
statusCode: 200
}