Galaxy API

GraphQL API Docs

Access to Galaxy is served up by a GraphQL (GQL) API at https://galaxy.rollup.id

To prevent abuse, the service limits requests for each application to 10 per minute.

Setup Guide

There are several ways you can consume GQL APIs and we've documented how below. If you are interested in a deeper understanding of GraphQL you can visit the GraphQL documentation portal.

For these examples we are using Javascript but you would be able to achieve similar results with your preferred language.

Option 1: Simple Fetch Client

A simple fetch client is the fastest way to consume a GQL API if you are not using GQL anywhere else in your application since this method requires no new dependencies.

Here is a simple example of using fetch with Galaxy.

const query = `query getProfile() {
  profile {
    displayName
    pfp
  }
}`

const { profile } = fetch("https://galaxy.rollup.id/graphql", {
  method: "post",
  headers: {
    "Authorization": `Bearer ${jwt}`,
    "X-GALAXY-KEY": "...",
  },
  body: JSON.stringify({ query }),
})
  .then(r => r.json())
  .catch(err => {
    console.error(err) // something went wrong
    return { profile: null }
  })

In this example we are calling the Galaxy "profile" resolver and asking it to return two fields.

Here is the same operation but with two resolvers this time:

const query = `query getProfile() {
  profile {
    displayName
    pfp
  }
  gallery {
    contract
    tokenId
  }
}

const { profile } = fetch("https://galaxy.rollup.id/graphql", {
  method: "post",
  headers: {
    "Authorization": "Bearer ${jwt}",
    "X-GALAXY-KEY": "...",
  },
  body: JSON.stringify({ query }),
})
  .then(r => r.json())
  .then(data => {
    return {
      ...data.profile,
      gallery
   }
  })
  .catch(err => {
    console.error(err) // something went wrong
    return { profile: null }
  })

In this example get two responses. One from "profile" and one from "gallery. Then we merge the response into one profile object. And here is one more example operation with variables:

const query = `query getProfileFromAlias($provider, $alias) {
  profile: profileFromAlias(provider: $provider, alias: $alias) {
    displayName
    pfp
  }
}

const { profile } = fetch("https://galaxy.rollup.id/graphql", {
  method: "post",
  headers: {
    "X-GALAXY-KEY": "...",
  },
  body: JSON.stringify({
    query,
    variables: {
      provider: "eth",
      alias: "vitalik.eth"
    }
  }),
})
  .then(r => r.json())
  .catch(err => {
    console.error(err) // something went wrong
    return { profile: null }
  })

Definitions

X-Galaxy-Key Header

This is the API Key that can be found in the dashboard of your Console App and is required to authenticate into the Galaxy API.

Authorization Header

This is where you provide the JWT received from your user sessions after the token exchange during user login.

API Playground

To see the entire API definition you can explore the entire Galaxy API at the GQL playground.

Last updated