On April 1st the Rank and Index Checkers price will grow by 2 kop. for a keyword on XS Pricing Plan. But for you the price won't change for now!
We've frozen old prices till June 1st for all accounts, active in 2025.
Follow us on Telegram 📧

Sorting results (orders parameter) - Topvisor API

This parameter is applicable to the read-only operations, i.e to use with the get operator.

Some methods support the parameter combined with the edit operator to re-sort objects.


Default sorting depends on the applied method.

Orders parameter structure

orders is an array of fieldOrder sortable field objects.
A sortable field object has the following properties:

  • fieldOrder.name - field name
  • fieldOrder.direction - sorting order (ASC or DESC)

Examples

In the below example, we'll get a list of keywords added to the NN project and sorted alphabetically in the ascending order.

Request


POST /v2/json/get/keywords_2/keywords/

{"project_id": /* project id (int) */}

Result


			{"result":[{"id":"80764821","name":"test keyword 1"},{"id":"80764822","name":"test keyword 2"},{"id":"80764823","name":"test keyword 3"},{"id":"80764824","name":"test keyword 4"},{"id":"80764825","name":"test keyword 5"}]}
			

Request


POST /v2/json/get/keywords_2/keywords/

{"project_id": /* project id (int) */, "orders":[{"name":"name","direction":"DESC"}]}

Result


			{"result":[{"id":"80764825","name":"test keyword 5"},{"id":"80764824","name":"test keyword 4"},{"id":"80764823","name":"test keyword 3"},{"id":"80764822","name":"test keyword 2"},{"id":"80764821","name":"test keyword 1"}]}
			

SDK example

In the below example, we'll get a list of keywords added to the NN projects and sorted alphabetically in the ascending order.

	<?php

	$projectId = '%NN%'; // ID of your project

	$TVSession = new TVSession();

	$selectorKeywords = new TVPen($TVSession, 'get', 'keywords_2', 'keywords');
	$selectorKeywords->setData(['project_id' => $project_id]);
	$selectorKeywords->serOrders([
		TVFields::genOrderData('name', 'DESC')
	]);

	$page = $selectorKeywords->exec();
	if(is_null($page->getResult())) return var_dump($page->getErrors());

	// $page - array of keywords
	foreach($page->getResult() as $resultItem){
		var_dump($resultItem);
	}