feat: add search command for collections, NFTs, tokens, and accounts#16
Merged
feat: add search command for collections, NFTs, tokens, and accounts#16
Conversation
Adds a new 'search' command group that uses the OpenSea GraphQL API (collectionsByQuery, itemsByQuery, currenciesByQuery, accountsByQuery) to search across the marketplace. CLI subcommands: - opensea search collections <query> - opensea search nfts <query> - opensea search tokens <query> - opensea search accounts <query> Also adds: - GraphQL method to OpenSeaClient - SearchAPI class to the programmatic SDK - Search result types - README documentation Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Contributor
Original prompt from chris.maddern@opensea.io |
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
⚙️ Control Options:
|
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…t method Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
ryanio
approved these changes
Feb 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat: add search command for collections, NFTs, tokens, and accounts
Summary
Adds a new
searchcommand group to the CLI that enables searching across OpenSea's marketplace data. Since the OpenSea REST API (api.opensea.io/api/v2) does not expose search endpoints, this uses the GraphQL API (gql.opensea.io/graphql) via four existing queries:collectionsByQuery,itemsByQuery,currenciesByQuery, andaccountsByQuery.Changes:
src/client.ts: Addedgraphql()method toOpenSeaClient(alongside existingget/postfor REST), with newgraphqlUrlconfig option. Includes proper error handling for HTTP errors, GraphQLerrorsarray, and missingdataresponses.src/commands/search.ts: New command file with 4 subcommands:collections,nfts,tokens,accountssrc/sdk.ts: NewSearchAPIclass exposed asclient.search.*for programmatic usagesrc/types/api.ts: New search result interfaces (SearchCollectionResult,SearchNFTResult,SearchTokenResult,SearchAccountResult)src/types/index.ts: AddedgraphqlUrltoOpenSeaClientConfigUsage:
opensea search collections mfers opensea search nfts "cool cat" --collection tiny-dinos-eth --limit 5 opensea search tokens usdc --chain base opensea search accounts vitalikSDK usage:
Updates since last revision
graphql()method to explicitly guard against missingdatain GraphQL responses. Previouslyjson.data as Tcould returnundefinedand crash callers; now throwsOpenSeaAPIError(500, "GraphQL response missing data", "graphql").maininto branch (brings in test suite, CI workflow, shared mocks from test: add full unit and integration test suite with CI workflow #20).test/client.test.ts: 5 tests forgraphql()method — success path, customgraphqlUrl, HTTP errors, GraphQL errors array, missingdataguardtest/commands/search.test.ts: 10 tests for the search CLI command — all 4 subcommands with default/custom options, table format outputtest/sdk.test.ts: 4 tests forSearchAPI— verifies correct GraphQL query strings and variable passing for each methodtest/mocks.ts: AddedgraphqltoMockClienttype andcreateCommandTestContext()Review & Testing Checklist for Human
src/commands/search.tsandsrc/sdk.ts. Consider whether these should be deduplicated into a shared location.Recommended test plan:
Notes