Selecting fields to return

This parameter is applicable to the read and add operations only, i.e. to use with the get and add operators.

Some methods support this parameter combined with the edit operator to create assignable objects. For more details on these methods, refer to the related documentation.

By default, the tool returns a basic list of element fields. For example, only IDs.
To secure high-speed API operation and app performance, select only fields required for a current task.

The list of all available fields is described in the API documentation.

Examples

In the below example, we'll get a list of keywords added to the NN project, their IDs and group names.

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) */, "fields":["id","name","group_name"]}

Result


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

SDK example

In the below example we'll get a list of keywords added to the NN project,
as well as their IDs and group names.

	<?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->setFields(['id', 'name', 'group_name']);

	$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);
	}