aMember Pro Web API (REST)
Since 4.2.6 release aMember Pro provides web api based on REST principles. It allows to fetch and submit information about users, products and payments. It is easy to extend and use, and we expect that list of interfaces will be extended soon.
Enabling of REST API
Go to aMember CP -> Setup -> Plugins, and enable "api" module. If your aMember installation has no "api" module available, you can get it for free in the members area
Once the module is enabled, scroll down and find an admin menu item Remote Api Permissions. Click New Record. You will see a form to fill - your comment about the access key, a generated access key itself, and list of checkboxes describing what system calls is available for given access key. Check necessary calls and Save.
Fetching list of users via Web API
To try it out, open in your browser http://example.com/amember/api/users?_key=APIKEY
You will see first 20 user records in JSON format and total number of users in _total variable
You can pass additional parameters to control output:
- Either: json (default), xml or serialize
- Number of records per page (default: 20, max: 100)
- Page of output (default: 0 - the first page)
- Adds a WHERE condition for FIELDNAME. If search value contains % it is considered as pattern for SQL LIKE expression, else SQL = condition is used. If several filters provided, it will be concatenated in SQL AND expression.
- Requests to include nested records into dataset. For example, if you are accessing users database via REST, you can do it like this: http://example.com/amember/api/users?_key=APIKEY&format=xml&_nested=invoices&_nested=access This will include user's invoices and access records into output. List of available nested tables is unique to each record type.
Adding users via Web API
To add a customer via Web API, you have to use HTTP POST method. There is a sample call to add a user to database:
POST /amember/api/users _key=APIKEYemail@example.com&name_f=John&name_l=Smith&_format=xml
in case of success it will return added user record.
Updating users via Web API
To add a customer via Web API, you have to either use HTTP PUT method, or make POST and pass _method=PUT parameter with your request. There is a sample call to add a user to database:
PUT /amember/api/users/22 _key=APIKEY&name_f=NewName&pass=1111
in case of success it will return added user record with first name set to "NewName" and the password set to 1111. Other user fields will be kept untouched. The following call gives the same result:
POST /amember/api/users/22 _method=PUT&_key=APIKEY&name_f=NewName&pass=1111
Deleting users via Web API
To add a customer via Web API, you have to either use HTTP DELETE method, or make POST and pass _method=DELETE parameter with your request. There is a sample call to add a user to database:
DELETE /amember/api/users/22 _key=APIKEY
in case of success it will return deleted user record as look like before deletion.
Available REST Controllers
Available Nested controllers