Search code examples
web-scrapingtwittermoralis

Get Twitter handle for an NFT contract address


I'm looking to get the official Twitter handle from an OS Verified project, programmatically.

I've tried calling the "collections" OS API, but the twitter_username field seems to rarely be populated with anything but "null" even for verified projects.

I've tried scraping the data manually with fetch but I got 1020 errors likely due to cloudflare protections.

Has anyone else used Moralis NFT or some other GraphHQ like service to obtain the Twitter handle of a given NFT project (starting out with a contract address)?


Solution

  • You can try Ubiquity API. They have an endpoint for collection metadata which also includes the Twitter account name

    https://ubiquity.api.blockdaemon.com/v1/nft/ethereum/mainnet/collection?contract_address=0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D
    

    This will give you the following response

    {
    "collection": {
        "id": "4203aedd-7964-5fe1-b932-eb8c4fda7822",
        "name": "Bored Ape Yacht Club",
        "description": "The Bored Ape Yacht Club is a collection of 10,000 unique Bored Ape NFTs— unique digital collectibles living on the Ethereum blockchain. Your Bored Ape doubles as your Yacht Club membership card, and grants access to members-only benefits, the first of which is access to THE BATHROOM, a collaborative graffiti board. Future areas and perks can be unlocked by the community through roadmap activation. Visit www.BoredApeYachtClub.com for more details.",
        "logo": "https://ubiquity.api.blockdaemon.com/v1/nft/media/ethereum/mainnet/collection/4203aedd-7964-5fe1-b932-eb8c4fda7822/logo.png",
        "banner": "https://ubiquity.api.blockdaemon.com/v1/nft/media/ethereum/mainnet/collection/4203aedd-7964-5fe1-b932-eb8c4fda7822/banner.jpeg",
        "verified": true,
        "contracts": [
            {
                "address": "0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D",
                "name": "BoredApeYachtClub",
                "symbol": "BAYC",
                "description": "",
                "image_url": "https://ubiquity.api.blockdaemon.com/v1/nft/media/ethereum/mainnet/",
                "type": "ERC721"
            }
        ],
        "meta": {
            "discord_url": "https://discord.gg/3P5K3dzgdB",
            "external_url": "http://www.boredapeyachtclub.com/",
            "twitter_username": "BoredApeYC"
        },
        "sub_collection": []
    }