Search by

membergate / membergate-api

AquaFusionMedia

Client for the Membergate API: signed requests, every API method, hosted sign-in helpers.

Package info

github.com/membergate/membergate-sdk

Documentation

Language:ColdFusion

pkg:composer/membergate/membergate-api

Statistics

Installs: 2

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.1 2026-11-27 19:16 UTC

This package is auto-updated.

Last update: 2026-11-27 19:17:27 UTC


README

Official clients for the Membergate API, for Python, JavaScript/TypeScript, PHP and ColdFusion (CFML).

Each one signs your requests, has a method for every API call, checks your arguments before anything is sent, and includes helpers for hosted sign-in. They have no dependencies.

Language Folder Install
Python 3.9+ python/ pip install "git+https://github.com/membergate/membergate-sdk.git#subdirectory=python"
JavaScript / TypeScript (Node 18+, Deno, Bun, Workers) javascript/ download the javascript folder, then npm install ./javascript
PHP 8.1+ php/ composer require membergate/membergate-api
ColdFusion 2021+ / Lucee 5.4+ cfml/ copy the cfml folder into your application, for example as /lib/membergate

Each folder's README has a quick start, the full list of calls, and examples.

Before you start

  1. On your Membergate site, open the API Keys page in the Control Panel and make a key pair for your app.
  2. Keep the secret key on your server. Never put it in a web page or a phone app. For a phone app, use hosted sign-in (below) and let your server make the API calls.

A first call

from membergate_api import Membergate

mg = Membergate('https://www.yoursite.com', public_key='...', secret_key='...')
r = mg.member.validate_member_login(userid='jdoe', password='...')
print(r.ok, r.status, r.message)
import { Membergate } from '@membergate/api';

const mg = new Membergate({ siteUrl: 'https://www.yoursite.com', publicKey: '...', secretKey: '...' });
const r = await mg.member.validateMemberLogin({ userid: 'jdoe', password: '...' });
console.log(r.ok, r.status, r.message);
$mg = new Membergate\Api\Client('https://www.yoursite.com', '...', '...');
$r = $mg->member->validateMemberLogin(['userid' => 'jdoe', 'password' => '...']);
echo $r->ok ? 'ok' : $r->message;
mg = new lib.membergate.Membergate(siteUrl="https://www.yoursite.com", publicKey="...", secretKey="...");
r = mg.member.validateMemberLogin(userid="jdoe", password="...");
writeOutput(r.ok ? "ok" : r.message);

Every call returns the API's answer: ok, status and subcode (for example 401 and 101 for a wrong password), message and data. A refusal from the API is an ordinary answer with ok set to false. The SDKs throw only when the API can't be reached.

Hosted sign-in

With hosted sign-in, members sign in on your Membergate site, by any method the site offers, and come back to your app with a one-time code. Your app never sees their password. Each SDK has helpers to make the PKCE pair and the sign-in address; then you swap the code with member.exchangeSignInCode. See ExchangeSignInCode in the API docs.

What's here

spec/membergate-api.json     the API: every method an app key can call, and its arguments
spec/signing-vectors.json    signing test cases worked out by the Membergate server
python/  javascript/  php/  cfml/

The methods in each SDK are generated from spec/membergate-api.json, so all four always cover the same calls.

How a request is signed

You don't need this to use the SDKs. It's here for anyone writing their own client.

  • Every argument is sent as a string.
    • Booleans become true/false, and numbers their decimal form.
    • Lists and objects become a compact JSON string.
    • Null is left out.
  • Argument names must be unique ignoring case, and may use only letters, digits, _, - and ..
  • The canonical form is {"name":"value",...}:
    • Names are sorted by their lower-case form.
    • Values are exactly as sent, with no escaping.
    • With no arguments, it's {}.
    • Query values are signed percent-encoded (RFC 3986), as they appear in the URL.
  • The signing key is an HMAC-SHA256 chain over the timestamp (UTC, YYYY-MM-DDTHH:MM:SS), the HTTP method, the component and the API method. It starts from "MGAPI" + secret key, and each step uses the previous step's upper-case hex digest as text.
  • The string to sign is these lines joined with \n:
    1. HMACSHA256
    2. the timestamp
    3. the HTTP method
    4. the component
    5. the API method
    6. the SHA-256 of the canonical query
    7. the SHA-256 of the canonical body
  • The headers are publickey, timestamp, component, method and signature. The request goes to https://<site>/api/request.cfm over https only.
  • Each signature is accepted once. The SDKs add a random mgnonce value to the query, so identical calls made in the same second are still accepted.

spec/signing-vectors.json has worked cases for every step.

Live tests

Each SDK has a live test that runs the same nine checks against a site, using a key pair you supply (MG_SITE, MG_PUBLIC_KEY, MG_SECRET_KEY). Use a test site, not your live one.

Support and license

Report problems at github.com/membergate/membergate-sdk/issues. The SDKs are released under the MIT License.