Pagination

The Search endpoint will return listings in pages, rather than all at once. Currently, by default, the first 20 matching listings will be returned in the first page. The totalResults field in the response message indicates if there are any more listings to be returned. If the value of totalResults is greater than the count field, then there are more pages of results. Similarly, you could use the currentPage and totalPages fields.

See also: Searching

Note: It is possible that the default page size of 20 will change in the future. To guarantee a certain page size, you should specify the rows parameter (see below).

To request a different number of listings per page, specify the rows parameter. The value must be between between 1 and 50.

For example, to request the first 30 matching listings you would send a request such as:

http://api.sensis.com.au/ob-20110511/test/search?query=hairdresser&rows=30&key=...

To request the next page of listings simply execute the search again, but specify a value of 2 for the page parameter. Ensure that all other parameters are the same, including the search query (query), the location (location) and the page size (rows).

Note: If you change the page size between requests, you may end up with the same listings appearing on two or more pages, or some listings being missed altogether.

To request more pages, simply increment the page parameter each time. If you request a page beyond the total number of pages, the last page of results will be returned instead.

Example

To initiate a search and return the first page of results (with a page size of 30 listings):

http://api.sensis.com.au/ob-20110511/test/search?query=hairdresser&rows=30&key=...

The first 30 matching listings are returned:

{
    results: [
        ...
    ],
    count: 30,
    totalResults: 75,
    currentPage: 1,
    totalPages: 3,
    code: 200,
    message: "OK"
    ...
}

In this example, there will be three pages of results (totalPages is 3).

To request the next page:

http://api.sensis.com.au/ob-20110511/test/search?query=hairdresser&rows=30&page=2&key=...

Returns the next 30 listings:

{
    results: [
        ...
    ],
    count: 30,
    totalResults: 75,
    currentPage: 2,
    totalPages: 3,
    code: 200,
    message: "OK"
    ...
}

To request the next (and last) page:

http://api.sensis.com.au/ob-20110511/test/search?query=hairdresser&rows=30&page=3&key=...

Will return the last 15 listings:

{
    results: [
        ...
    ],
    count: 15,
    totalResults: 75,
    currentPage: 3,
    totalPages: 3,
    code: 200,
    message: "OK"
    ...
}