Metadata & Properties API

Metadata & Properties API

Overview

Endpoints for managing NFT metadata, properties, and attributes. These endpoints enable you to update, retrieve, and store metadata for NFTs.

Get NFT Metadata

Retrieve the metadata for a specific NFT.

GET api.bloclabs.com/v1/nfts/{token_id}/metadata

Response

{
    "status": "success",
    "data": {
        "token_id": "1234",
        "collection_address": "0x789...def",
        "metadata": {
            "name": "Artwork #1",
            "description": "Description of the artwork",
            "image": "ipfs://Qm...",
            "external_url": "https://example.com/nft/1234",
            "attributes": [
                {
                    "trait_type": "Background",
                    "value": "Blue"
                },
                {
                    "trait_type": "Rarity",
                    "value": "Legendary",
                    "display_type": "string"
                }
            ],
            "animation_url": "ipfs://Qm...",  // Optional
            "youtube_url": "https://..."      // Optional
        },
        "last_updated": "2024-03-15T10:00:00Z"
    }
}

Update Metadata

Update the metadata for an NFT.

POST api.bloclabs.com/v1/nfts/{token_id}/metadata

Request

{
    "name": "Updated Artwork #1",
    "description": "New description",
    "image": "ipfs://Qm...",
    "attributes": [
        {
            "trait_type": "Background",
            "value": "Red"
        }
    ],
    "external_url": "https://example.com/nft/1234"
}

Response

{
    "status": "success",
    "data": {
        "token_id": "1234",
        "collection_address": "0x789...def",
        "metadata_uri": "ipfs://Qm...",
        "updated_at": "2024-03-15T10:00:00Z",
        "transaction_hash": "0xabc...123"  // If on-chain update
    }
}

Upload Media

Upload media files (images, videos) for NFT metadata.

POST api.bloclabs.com/v1/nfts/media/upload

Request

# Multipart form data
Content-Type: multipart/form-data

file: <binary_data>
type: "image"  # image, video, animation

Response

{
    "status": "success",
    "data": {
        "media_uri": "ipfs://Qm...",
        "mime_type": "image/png",
        "size": 1024576,
        "gateway_url": "https://ipfs.io/ipfs/Qm..."
    }
}

Get Collection Properties

Retrieve all properties/traits used in a collection.

GET api.bloclabs.com/v1/nfts/collections/{collection_id}/properties

Response

{
    "status": "success",
    "data": {
        "properties": [
            {
                "trait_type": "Background",
                "values": ["Blue", "Red", "Green"],
                "occurrence": {
                    "Blue": 50,
                    "Red": 30,
                    "Green": 20
                }
            },
            {
                "trait_type": "Rarity",
                "values": ["Common", "Rare", "Legendary"],
                "occurrence": {
                    "Common": 70,
                    "Rare": 25,
                    "Legendary": 5
                }
            }
        ],
        "total_items": 100
    }
}

Error Responses

Invalid Metadata

{
    "status": "error",
    "message": "Invalid metadata format",
    "code": "INVALID_METADATA",
    "data": {
        "validation_errors": [
            "Image URL is required",
            "Name exceeds maximum length"
        ]
    }
}

Upload Failed

{
    "status": "error",
    "message": "Media upload failed",
    "code": "UPLOAD_FAILED",
    "data": {
        "reason": "File size exceeds limit",
        "max_size": "100MB"
    }
}

Metadata Update Failed

{
    "status": "error",
    "message": "Failed to update metadata",
    "code": "UPDATE_FAILED",
    "data": {
        "reason": "Not authorized to update"
    }
}

Notes

  • Metadata should follow OpenSea metadata standards

  • Images should be hosted on IPFS for permanence

  • Maximum file size for uploads is 100MB

  • Supported media formats: PNG, JPG, GIF, MP4, WEBM

  • Properties are case-sensitive

  • Consider gas costs for on-chain metadata updates

  • Metadata updates may take time to reflect on marketplaces

Last updated

Was this helpful?