Skip to content

Commit cc06f41

Browse files
authored
chore: [sc-26283] Enhance namegraph-sdk (#596)
* Update readme & reduce magic numbers * Moving default variables to index.ts & changing Responses to interfaces from types * defaults & interfaces back to utils due to repo dependencies * Detailed documentation as comments and docstrings (synchronized with python package amap) * unit tests for index.ts and utils.ts * Add changeset
1 parent 3e55bfc commit cc06f41

File tree

6 files changed

+822
-137
lines changed

6 files changed

+822
-137
lines changed

.changeset/strange-flies-nail.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@namehash/namegraph-sdk": patch
3+
---
4+
5+
Update NameGraph SDK's README, add detailed documentation and provide test coverage for the package

packages/namegraph-sdk/README.md

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
A TypeScript SDK for interacting with the NameGraph APIs, providing access to the world's largest collection of names. This SDK enables easy integration with the NameGraph API endpoints for name and collection suggestions.
44

5+
## Features
6+
7+
- **Category-based Suggestions**: Get name suggestions organized by various categories including related terms, wordplay, alternates, and more
8+
- **Collection Management**: Find, count, and analyze collections of names
9+
- **Smart Sampling**: Sample and fetch top members from collections
10+
- **Advanced Search**: Search collections by string or by collection ID
11+
12+
513
## Installation
614

715
```bash
@@ -25,13 +33,6 @@ import { namegraph } from "namegraph-sdk";
2533
const suggestions = await namegraph.groupedByCategory("zeus");
2634
```
2735

28-
## Features
29-
30-
- **Category-based Suggestions**: Get name suggestions organized by various categories including related terms, wordplay, alternates, and more
31-
- **Collection Management**: Find, count, and analyze collections of names
32-
- **Smart Sampling**: Sample and fetch top members from collections
33-
- **Advanced Search**: Search collections by string or by collection ID
34-
3536
## API Reference
3637

3738
### Client Configuration
@@ -62,12 +63,22 @@ const suggestions = await client.suggestionsByCategory("zeus");
6263
const members = await client.sampleCollectionMembers("collection_id");
6364
```
6465

65-
#### Fetch Top Collection Members
66+
#### Fetch Collection Members
6667

6768
```typescript
69+
// with pagination
70+
const members = await client.fetchCollectionMembers("collection_id", {offset: 0, limit: 20});
71+
72+
// Top members
6873
const topMembers = await client.fetchTopCollectionMembers("collection_id");
6974
```
7075

76+
#### Generate Scrambled Variations of Collection Tokens
77+
78+
```typescript
79+
const scrambled = await client.scrambleCollectionTokens('collection_id', {seed: 42});
80+
```
81+
7182
#### Find Collections
7283

7384
```typescript
@@ -91,6 +102,11 @@ const stringCount = await client.countCollectionsByString("zeus god");
91102
const memberCount = await client.countCollectionsByMember("zeus");
92103
```
93104

105+
#### Get Collection by ID
106+
```typescript
107+
const collection = await client.getCollectionById("collection_id");
108+
```
109+
94110
### Response Types
95111

96112
The SDK provides TypeScript types for all API responses. Key types include:
@@ -136,3 +152,13 @@ The SDK supports various grouping categories for name suggestions:
136152
- `expand`: Expanded versions
137153
- `gowild`: Creative variations
138154
- `other`: Additional suggestions
155+
156+
## Contact Us
157+
158+
Visit our [website](https://namehashlabs.org/) to get in contact.
159+
160+
## License
161+
162+
Licensed under the MIT License, Copyright © 2023-present [NameHash Labs](https://namehashlabs.org).
163+
164+
See [LICENSE](./LICENSE) for more information.

0 commit comments

Comments
 (0)