Side note: We're working on a new version of Memberstack that's 10x more powerful for developers. Join the Developer Program for early access.

At Memberstack, we’re continuously working hard to make the platform more accessible to both designers and developers. We’ve recently launched a new RESTful API that makes it possible for developers to interact with their website’s member data! The new API allows developers to programmatically query, update, and delete their members.

In order to authorize the requests, a developer needs to obtain an API key through the Memberstack dashboard. This API key is linked to the website from which you generated it and is used by the API to identify your selected website.

Getting members

The API makes it possible to query all members that are associated with the website your API key is linked to! Developers can use any HTTP request library or a simple cURL command to request the member data. Rate limit is 60 requests per second.

const fetch = require('node-fetch')


async function getMembers() {
const res = await fetch("https://api.memberstack.com/v1/members", {
headers: { "X-API-KEY": "..." }
});

const data = await res.json();
console.log(data);
}

The member's endpoint returns an object containing:

  • A numeric `count field, which represents the total amount of members that are associated with that website,

  • A boolean has_more field, which indicates whether there are more members to be queried besides the members that have currently been returned. By default, the maximum amount of members that get returned from the endpoint is 100.

  • A members array, which contains the queried member objects.

Developers can choose how they want the members to be queried by adding a skip or limit query parameter.

The limit query parameter adds the possibility to decide how many members should get returned.

---

The skip query parameters make it possible to skip a certain amount of members, which by default start from the very first member.

---

Both query parameters can be combined in order to skip a certain amount of members and limit the amount of members that get returned!

---

Interacting with a member

The API allows developers to get, update, and delete a specific member. Each member has a unique identifier that is used in order to make these actions possible.

Getting a member

In order to get a member, a developer can make a GET request to the API member’s endpoint with the corresponding member’s id. Rate limit is 60 requests per second.

Note: It’s not possible to retrieve a member by email – you’ll need to retrieve by ID.

---

A member object containing the data of the member with that unique identifier gets returned.

const fetch = require('node-fetch')


async function updateMember() {
const res = await fetch("https://api.memberstack.com/v1/members/3jk90", {
method: "GET",
headers: { "X-API-KEY": "..." }
});

const data = await res.json();
console.log(data);
}

Updating a member

Developers can update a member by making a POST request to the API member’s endpoint with the corresponding member’s id and the data which they want to update the member with. A member’s email, password, customFields, and metaData are all able to be updated. Rate limit is 60 requests per second.

const fetch = require('node-fetch')


async function updateMember() {
const res = await fetch("https://api.memberstack.com/v1/members/3jk90", {
method: "POST",
headers: { "X-API-KEY": "..." },
body: JSON.stringify({
metaData: { username: "johndoe1990" }
})
});

const data = await res.json();
console.log(data);
}

  • The metaData has a limit of 3kB, so make sure you’re not updating the metaData with an object that’s too large.

Updating a member returns the updated member’s object.

Deleting a member

Developers can delete a member by making a DELETE request to the API member’s endpoint with the corresponding member’s id. Rate limit is 60 requests per second.

const fetch = require('node-fetch')


async function deleteMember() {
const res = await fetch("https://api.memberstack.com/v1/members/3jk90", {
method: "DELETE",
headers: { "X-API-KEY": "..." }
});

const data = await res.json();
console.log(data);
}

If a member has been deleted successfully, a status code of 200 with a { success: true } gets returned.

The beta API is only the first step in making Memberstack more developer-friendly! Over time, we’ll add more endpoints and possibilities to programmatically interact with your websites, members, and plans.

We're working on a new version of Memberstack that's 10x more powerful for developers. Join the Developer Program for early access.

Keywords: Back-end API, backend, etc.

Did this answer your question?