Skip to main content

GraphQL API Usage

Majora provides a powerful GraphQL API that allows developers to query and interact with the protocol's data. This document outlines how to use the API effectively.

Endpoint​

The GraphQL API endpoint is:

https://api.majora.finance/graphql

Authentication​

Currently, the API does not require authentication for read operations. However, this may change in the future, so please check back for updates.

Making Requests​

You can make requests to the API using any GraphQL client or by sending POST requests to the endpoint with your query in the request body.

Example using our client​

We have a Typescript client for our API. The NPM package is here

To install it:

npm install @majora-finance/graphql
import { createClient } from "@majora-finance/graphql";

const majoraApi = createClient({
url: 'https://api.majora.finance/graphql'
})

const request = await majoraApi.query({
getVaultListFiltered: {
__args: {
search: '',
offset: 0,
limit: 50
},
resultsCount: true,
vaults: {
chainId: true,
address: true,
name: true,
asset: true,
protocols: true
}
}
})

console.log(request.getVaultListFiltered)

Example using fetch​

fetch('https://api.majora.finance/graphql', {
method: 'POST',
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
query: `
query {
getVaultListFiltered(search: "", offset: 0, limit: 50) {
resultsCount,
vaults {
chainId,
address,
name,
asset,
protocols
}
}
}
`
})
})
.then(res => res.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));

You can check the available queries and mutations in the GraphQL API Reference.

Error Handling​

If an error occurs, the API will return a JSON object with an errors field containing details about the error. Always check for this field in your responses and handle errors appropriately.

Rate Limiting​

Currently, there is strict rate limits in place of 30 requests per minute. However, please be considerate and avoid making excessive requests in short periods of time.