Skip to contents

Retrieve NFT data, account information, and collections from the OpenSea marketplace. These functions wrap the OpenSea API v2 REST endpoints, providing R-native access to blockchain NFT metadata without requiring direct blockchain node access.

Use these functions when you need to: - Display NFT metadata in Shiny applications - Build NFT portfolio dashboards - Verify NFT ownership and authenticity - Discover collections by creator

All functions require the `ART_OPENSEA_KEY` environment variable. See README.md for configuration details.

Usage

get_os_account(account)

get_os_nft(id, chain, contract)

get_os_account_nfts(account, chain)

get_os_collections(creator, chain)

Arguments

account

Character. Ethereum wallet address in hexadecimal format (e.g., `"0xa16DCcD55139D5eF5B5Ff776553ef080EB6258fc"`). Obtain from user input, blockchain explorers (etherscan.io, polygonscan.com), or NFT marketplace URLs. The 42-character string starting with `0x` uniquely identifies a blockchain account.

id

Character or Integer. NFT token ID within the contract. Each NFT in a collection has a unique token ID (often sequential starting from 0). Extract from OpenSea URLs using `parseOpenseaURL()` or from marketplace listings.

chain

Character. Blockchain network identifier. Supported values include `"ethereum"` (mainnet), `"matic"` (Polygon), `"arbitrum"`, `"optimism"`, `"base"`, `"avalanche"`. Use lowercase network names as shown in OpenSea URLs. Determines which blockchain to query for NFT data.

contract

Character. NFT smart contract address in hexadecimal format (e.g., `"0x6444522C5aD44285b7856dd3336D09Fb939865F1"`). Each NFT collection has a unique contract address. Obtain from OpenSea collection pages, blockchain explorers, or `get_os_collections()` response.

creator

Character. OpenSea username of the collection creator (e.g., `"b_fatemi_art"`). This is the creator's profile username on OpenSea, not their wallet address. Obtain from OpenSea collection pages or creator profiles.

Value

Character. JSON string containing account profile data including username, bio, social media links, and collection statistics. Parse with `jsonlite::fromJSON()` to extract specific fields. Returns account metadata for display in profile pages or user dashboards.

Character. JSON string containing comprehensive NFT metadata including name, description, image URLs, traits/attributes, creator info, ownership history, and contract details. Parse with `jsonlite::fromJSON()` to access nested fields. Use this for displaying individual NFT details in galleries or verification workflows.

Character. JSON string containing an array of NFT objects (maximum 200 items per request). Each object includes NFT metadata similar to `get_os_nft()` response. Parse with `jsonlite::fromJSON()` and iterate through the `nfts` array. Use for building portfolio views or ownership verification. For accounts with >200 NFTs, implement pagination using the `next` cursor from the response.

Character. JSON string containing an array of collection objects (maximum 100 items). Each object includes collection name, description, contract address, creation date, and statistics. Parse with `jsonlite::fromJSON()` and access the `collections` array. Use for discovering all collections by a specific creator or building creator portfolio pages.

Functions

  • get_os_account(): Retrieve account information by wallet address

  • get_os_nft(): Retrieve NFT metadata by chain, contract, and token ID

  • get_os_account_nfts(): List all NFTs owned by an account on a chain

  • get_os_collections(): List collections created by a user on a chain

See also

OpenSea API docs: <https://docs.opensea.io/reference/api-overview>

Examples

if (FALSE) { # \dontrun{
get_os_account("0xa16DCcD55139D5eF5B5Ff776553ef080EB6258fc")
} # }
if (FALSE) { # \dontrun{
get_os_nft(
    id = 2,
    chain = "matic",
    contract = "0x6444522C5aD44285b7856dd3336D09Fb939865F1"
)
} # }
if (FALSE) { # \dontrun{
get_os_account_nfts(
    account = "0xa16DCcD55139D5eF5B5Ff776553ef080EB6258fc",
    chain = "matic"
)
} # }
if (FALSE) { # \dontrun{
get_os_collections(creator = "b_fatemi_art", chain = "matic")
} # }