Skip to main content
const axios = require("axios");
let data = JSON.stringify({
  query: `YOUR_GRAPHQL_QUERY_HERE`,
  variables: {
    id: "YOUR_PDA_ID",
  },
});

let config = {
  method: "post",
  maxBodyLength: Infinity,
  url: "https://sandbox.protocol.mygateway.xyz/graphql",
  headers: {
    "X-Api-Key": "<YOUR_API_KEY>",
    Authorization: "Bearer <YOUR_AUTHENTICATION_TOKEN>",
    "Content-Type": "application/json",
  },
  data: data,
};

axios
  .request(config)
  .then((response) => {
    console.log(JSON.stringify(response.data));
  })
  .catch((error) => {
    console.log(error);
  });
{
  "data": {
    "PDA": {
      "id": "f34cdbae-7e0b-4527-bb97-08fd0e74effe",
      "issuanceDate": "2024-02-16T14:53:15.350Z",
      "ownerHash": "b32e93ce3e1f464500e0a4d350ca390a2ef76ccd07c6cf52112e5e43953b50c7e8bfee58d6cce53ca04b40d5d2d3bf5a",
      "issuerHash": "b32e93ce3e1f464500e0a4d350ca390a2ef76ccd07c6cf52112e5e43953b50c7e8bfee58d6cce53ca04b40d5d2d3bf5a",
      "dataAsset": {
        "title": "Update Test 2",
        "dataModel": {
          "id": "9f27397e-27f2-4c30-b1b7-829371de4df5",
          "createdAt": "2023-12-13T18:58:09.433Z"
        },
        "claim": {
          "handleName": "@gateway_xyz",
          "favoritePosts": ["more awesome"]
        },
        "issuer": {
          "id": "dffb7a18-d2a4-472e-ac46-4f069b1e8ead"
        },
        "image": null
      },
      "status": "Valid"
    }
  }
}
You can fetch the details of a PDA by using the PDA query. You require the PDA ID to fetch the details of a PDA.
query PDA($id: String!) {
  PDA(id: $id) {
    id
    issuanceDate
    ownerHash
    issuerHash
    dataAsset {
      title
      dataModel {
        id
        createdAt
      }
      claim
      issuer {
        id
      }
      image
    }
    status
  }
}
const axios = require("axios");
let data = JSON.stringify({
  query: `YOUR_GRAPHQL_QUERY_HERE`,
  variables: {
    id: "YOUR_PDA_ID",
  },
});

let config = {
  method: "post",
  maxBodyLength: Infinity,
  url: "https://sandbox.protocol.mygateway.xyz/graphql",
  headers: {
    "X-Api-Key": "<YOUR_API_KEY>",
    Authorization: "Bearer <YOUR_AUTHENTICATION_TOKEN>",
    "Content-Type": "application/json",
  },
  data: data,
};

axios
  .request(config)
  .then((response) => {
    console.log(JSON.stringify(response.data));
  })
  .catch((error) => {
    console.log(error);
  });
{
  "data": {
    "PDA": {
      "id": "f34cdbae-7e0b-4527-bb97-08fd0e74effe",
      "issuanceDate": "2024-02-16T14:53:15.350Z",
      "ownerHash": "b32e93ce3e1f464500e0a4d350ca390a2ef76ccd07c6cf52112e5e43953b50c7e8bfee58d6cce53ca04b40d5d2d3bf5a",
      "issuerHash": "b32e93ce3e1f464500e0a4d350ca390a2ef76ccd07c6cf52112e5e43953b50c7e8bfee58d6cce53ca04b40d5d2d3bf5a",
      "dataAsset": {
        "title": "Update Test 2",
        "dataModel": {
          "id": "9f27397e-27f2-4c30-b1b7-829371de4df5",
          "createdAt": "2023-12-13T18:58:09.433Z"
        },
        "claim": {
          "handleName": "@gateway_xyz",
          "favoritePosts": ["more awesome"]
        },
        "issuer": {
          "id": "dffb7a18-d2a4-472e-ac46-4f069b1e8ead"
        },
        "image": null
      },
      "status": "Valid"
    }
  }
}
I