API Documentation

If you'd prefer to use our existing API (offered at best effort) instead of building your own, you can use the endpoints shown below.

The API for WAX Mainnet is:

https://token-farms.waxdaobp.io

All endpoints return data in JSON format.

/get-farm

/get-farms

/get-stakers

/staked-only

Endpoint List

/get-farm

Method: POST

Returns details about a single token farm

Param
Type
Description

farm_name

string

The 1 to 12 character farm name to get the details for

// Example

const farm_name = "mywaxdaofarm";

const getFarmSingle = async (farm_name) => {
  for (const api of network.endpoints.tokenfarms) {
    try {
      const res = await axios.post(
        `${api}/get-farm`,
        {
          farm_name: farm_name,
          json: true,
        },
        {
          headers: {
            "Access-Control-Allow-Origin": "*",
            "Content-Type": "application/json",
          },
        }
      );

      if (res?.data?.farm) {
        return res.data.farm;
      }
    } catch (error) {
      console.log(`Failed getting single farm from ${api}. Error: ${error}`);
      return [];
    }

    return [];
  }
};

/get-farms

Method: POST

Returns data for multiple farms

Param
Type
Description

page

int (optional)

Which page of results you want to fetch. Default is 1

limit

int (optional)

The amount of farms you want to fetch. Default: 100, Min: 1, Max: 100

sort

string (optional)

How you want the farms sorted when they are returned. Options are newest and oldest. Default is newest

creator

string (optional)

The WAX address of the account that created the farms.

original_creator

string (optional)

The WAX address of the original creator of the farm, this is applicable if you are using our partner contract. Your partner contract would be creator since it acts as a proxy, but original_creator would be the end user who set up the farm on your platform.

// Example

const partner = "prtnr.waxdao";

export const getFarmsByPartner = async (
  page = 1,
  limit = 100,
  sort = "newest"
) => {
  for (const api of network.endpoints.tokenfarms) {
    try {
      const res = await axios.post(
        `${api}/get-farms`,
        {
          creator: partner,
          page: page,
          limit: limit,
          sort: sort,
          json: true,
        },
        {
          headers: {
            "Access-Control-Allow-Origin": "*",
            "Content-Type": "application/json",
          },
        }
      );

      if (res?.data?.farms) {
        return res.data.farms;
      }
    } catch (error) {
      console.log(`Failed getting farms from ${api}. Error: ${error}`);
      return [];
    }
    return [];
  }
};

/get-stakers

Method: POST

Returns a list of stakers (leaderboard) for a single farm. Sorted by most staked to least staked.

Param
Type
Description

page

int (optional)

Which page of results you want to fetch. Default is 1

limit

int (optional)

The amount of rows you want to fetch. Default: 100, Min: 1, Max: 100

farm_name

string

The 1-12 character name of the farm you want to get the stakers for

// Example

export const getStakersList = async (farm_name, page = 1, limit = 100) => {
  for (const api of network.endpoints.tokenfarms) {
    try {
      const res = await axios.post(
        `${api}/get-stakers`,
        {
          farm_name: farm_name,
          page: page,
          limit: limit,
          json: true,
        },
        {
          headers: {
            "Access-Control-Allow-Origin": "*",
            "Content-Type": "application/json",
          },
        }
      );

      if (res?.data?.stakers) {
        console.log(res.data.stakers);
        return res.data.stakers;
      }
    } catch (error) {
      console.log(`Failed getting stakers list from ${api}. Error: ${error}`);
      return [];
    }
    return [];
  }
};

/staked-only

Method: POST

Returns a list of farms that a user is staking in.

Param
Type
Description

page

int (optional)

Which page of results you want to fetch. Default is 1

limit

int (optional)

The amount of rows you want to fetch. Default: 100, Min: 1, Max: 100

sort

string (optional)

How you want the farms sorted when they are returned. Options are newest and oldest. Default is newest.

staker

string

The WAX address of the staker to get staked farms for.

// Example

const user = "waxdao";

export const getStakedOnly = async (
  user,
  page = 1,
  limit = 100,
  sort = "newest"
) => {
  for (const api of network.endpoints.tokenfarms) {
    try {
      const res = await axios.post(
        `${api}/staked-only`,
        {
          staker: user,
          page: page,
          limit: limit,
          sort: sort,
          json: true,
        },
        {
          headers: {
            "Access-Control-Allow-Origin": "*",
            "Content-Type": "application/json",
          },
        }
      );

      if (res?.data?.farms) {
        console.log(res.data.farms);
        return res.data.farms;
      }
    } catch (error) {
      console.log(`Failed getting staked only from ${api}. Error: ${error}`);
      return [];
    }
    return [];
  }
};

Last updated