TheBadge documentation
  • 👨‍🏫TheBadge's Introduction
    • Relevance
  • đź’ŽLanding page
  • 🏅What is a Badge
    • Definition
    • Badge history
    • Badge Categories
      • Community Badges
      • Third-party Badges
  • đź«‚Protocol Participants
    • Creators
    • Curators
    • Badge Receiver
    • Badge Types
    • Badge Status
  • ⚙️Protocol Mechanics
    • How it works
    • Challenge
    • Challenge Flow
  • 📚How to / Guides
    • How to get a badge
    • How to create a badge
    • How to become a creator
    • How to become a curator
    • How to curate
    • How to challenge
    • How to claim a third party certificate
    • How to place your diploma on LinkedIn
  • ⛓️Integration Guide
    • How to fetch badges
    • How to render badges
      • Using the TheBadge-UI-Library
  • 🙂Community
    • TheBadge's Ambassador
Powered by GitBook
On this page

Was this helpful?

  1. Integration Guide

How to fetch badges

PreviousHow to place your diploma on LinkedInNextHow to render badges

Last updated 1 year ago

Was this helpful?

You can get access to Badges connecting to TheBadge’s subgraph:

Goerli Testnet

Graph url:

Graph name: theBadge

Ethereum Mainnet

Coming soon

In the subgraph, you can request data about badges. You can search for them by using the badge's id.

For example:

query badgeById($id: ID!) {
   badge(id: $id) {
     id
     evidenceMetadataUrl
     reviewDueDate
     status
     isChallenged
     receiver {
       id
     }
     badgeType {
       id
       metadataURL
       validFor
       badgesMintedAmount
     }
   }
 }

Take into account that a badge’s id has the format: “ {ownerAddress} - {badgeTypeId} ”

Using the field: “evidenceMetadataUrl” (IPFS hash) you can obtain further information about the Badge. If you get the IPFS data from it, the JSON file that you receive has a structure like this:

{
    Columns: [],
    Values: {},
    Image:
}

On the Image field, you will get the hash of the PNG file stored in IPFS for this particular Badge. If you want to show visually a Badge, you can use the image from there. On the other hand, Values and Columns contain the evidence provided by the user to obtain it.

“Columns” represents the form fields with label, type and description, and “Values” is an object (key-value) with the form label as key and the evidence on the other side.

If you want to obtain all the badges for a particular address, you can use this:

query userBadges($ownerAddress: ID!) {
    badges(where: {requestedBy: $ownerAddress}) {
      id
      status
      reviewDueDate
      evidenceMetadataUrl
      badgeType {
        validFor
        metadataURL
        id
        badgesMintedAmount
        creator {
          creatorMetadata
        }
      }
    }
  }

If you have any questions or need further assistance, feel free to contact our team on our !

⛓️
🚀
https://api.thegraph.com/subgraphs/name/nicosampler/thebadge-goerli
Discord