Skip to content

Yurba.js / yurba.js / SearchResource

Class: SearchResource

dialogs()

dialogs(query, payload, page?): Promise<Dialog[]>

Finds dialogs

Parameters

query

string

Search mask

payload

FindDialogPayload

FindDialogPayload Search data

page?

number

Page number (default 0)

Returns

Promise<Dialog[]>

Array of Dialog objects

Since

1.0.0

Throws

If parameters are invalid

Example

javascript
// Basic search
const results = await rest.search.dialogs('programming', {
  sort: 0,    // by relevance
  type: 0,    // all types
  country: 0, // all countries
  topic: 0    // all topics
});

// Search groups by popularity
const groups = await rest.search.dialogs('tech', {
  sort: 1,    // by popularity
  type: 1,    // groups only
  country: 0,
  topic: 5    // tech & science
});

// Search channels alphabetically
const channels = await rest.search.dialogs('news', {
  sort: 2,    // alphabetically
  type: 2,    // channels only
  country: 231, // USA
  topic: 0
}, 1); // page 1

// Using enum types
import { Country, FDTopic } from '@yurbajs/types';
const education = await rest.search.dialogs('learn', {
  sort: 0,
  type: 1,
  country: Country.Ukraine,
  topic: FDTopic.Education
});

tracks()

tracks(query, page?): Promise<Track[]>

Finds tracks

Parameters

query

string

Song name or artist

page?

number

Page number (optional)

Returns

Promise<Track[]>

Array of Track objects

Since

1.0.0

Throws

If query is invalid or page is negative

Example

javascript
// Search by song name
const tracks = await rest.search.tracks('Bohemian Rhapsody');

// Search by artist
const artistTracks = await rest.search.tracks('Queen');

// With pagination
const moreTracks = await rest.search.tracks('rock', 1);

users()

users(payload, page?): Promise<User[]>

Finds users

Parameters

payload

FindUserPayload

FindUserPayload Search filters

page?

number

Page number (default 0)

Returns

Promise<User[]>

Array of User objects

Since

1.0.0

Throws

If parameters are invalid

Example

javascript
// Basic search
const users = await rest.search.users({
  sort: 0,
  country: 0,
  region: 0,
  city: 0,
  worksAt: "",
  relationships: 0,
  online: 0,
  avatar: 0
});

// Search married users from Ukraine
const marriedUsers = await rest.search.users({
  sort: 0,
  country: 228, // Ukraine
  region: 0,
  city: 0,
  worksAt: "",
  relationships: RelationshipStatus.Married,
  online: 1,
  avatar: 0
});