diff --git a/.changeset/smart-hats-rescue.md b/.changeset/smart-hats-rescue.md new file mode 100644 index 000000000..cf2cc7c5a --- /dev/null +++ b/.changeset/smart-hats-rescue.md @@ -0,0 +1,5 @@ +--- +"@namehash/namegraph-sdk": minor +--- + +Add new endpoint to NameGraph: findCollectionsByCollection diff --git a/packages/namegraph-sdk/src/index.ts b/packages/namegraph-sdk/src/index.ts index d88f88186..7d0a0d94d 100644 --- a/packages/namegraph-sdk/src/index.ts +++ b/packages/namegraph-sdk/src/index.ts @@ -132,7 +132,7 @@ export interface Collection { avatar_image: string; } -export interface FindCollectionsByStringResponse { +export interface FindCollectionsResponse { metadata: { total_number_of_matched_collections: number; processing_time_ms: number; @@ -163,9 +163,39 @@ export class NameGraph { this.abortController = new AbortController(); } + public groupedByCategory( + label: string, + ): Promise { + const sorter = "weighted-sampling"; + const min_suggestions = 100; + const max_suggestions = 100; + const min_primary_fraction = 0.1; + const mode = "full"; + const enable_learning_to_rank = true; + const name_diversity_ratio = 0.5; + const max_per_type = 2; + + const payload = { + label, + metadata: DEFAULT_METADATA, + sorter, + min_suggestions, + max_suggestions, + min_primary_fraction, + params: { + mode, + enable_learning_to_rank, + name_diversity_ratio, + max_per_type, + }, + }; + + return this.rawRequest(`grouped-by-category`, "POST", payload); + } + public findCollectionsByString( query: string, - ): Promise { + ): Promise { const offset = 0; const mode = "instant"; const limit_names = 10; @@ -194,34 +224,33 @@ export class NameGraph { return this.rawRequest("find_collections_by_string", "POST", payload); } - public groupedByCategory( - label: string, - ): Promise { - const sorter = "weighted-sampling"; - const min_suggestions = 100; - const max_suggestions = 100; - const min_primary_fraction = 0.1; - const mode = "full"; - const enable_learning_to_rank = true; + public findCollectionsByCollection( + collection_id: string, + ): Promise { + const limit_names = 10; + const offset = 0; + const sort_order = "AI"; + const max_related_collections = 3; + const max_per_type = 3; const name_diversity_ratio = 0.5; - const max_per_type = 2; + const min_other_collections = 0; + const max_other_collections = 3; + const max_total_collections = 6; const payload = { - label, - metadata: DEFAULT_METADATA, - sorter, - min_suggestions, - max_suggestions, - min_primary_fraction, - params: { - mode, - enable_learning_to_rank, - name_diversity_ratio, - max_per_type, - }, + limit_names, + offset, + sort_order, + max_related_collections, + max_per_type, + name_diversity_ratio, + min_other_collections, + max_other_collections, + max_total_collections, + collection_id, }; - return this.rawRequest(`grouped-by-category`, "POST", payload); + return this.rawRequest("find_collections_by_collection", "POST", payload); } public fetchTopCollectionMembers(