https://github.com/poetic/drupal-services-api
A Node.js client for interacting with Drupal 7 Services
https://github.com/poetic/drupal-services-api
Last synced: 2 months ago
JSON representation
A Node.js client for interacting with Drupal 7 Services
- Host: GitHub
- URL: https://github.com/poetic/drupal-services-api
- Owner: poetic
- Created: 2015-01-20T21:16:49.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-03-27T10:44:07.000Z (about 9 years ago)
- Last Synced: 2024-10-19T10:04:44.753Z (7 months ago)
- Language: JavaScript
- Size: 312 KB
- Stars: 14
- Watchers: 7
- Forks: 4
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Drupal 7 Services API [](https://travis-ci.org/poetic/drupal-services-api)
An Node.js client for interacting with Drupal 7 Services 3.11.
## Installation
```sh
npm install --save drupal-services-api
```## Usage
You need to login before using any methods that require it.
```js
var client = new Drupal('http://drupal-site.com/api');client.login('username', 'password').then(function(user) { });
client.isLoggedIn(); // => Boolean
client.logout().then(function() { });
/* Nodes */
client.index().then(function(nodes) { });
client.index({limit: 10}).then(function(max10nodes) { });
client.index(null, {title: 'something'}).then(function(nodesWhereTitleIsSomething) { });
client.index({limit: 1}, {title: 'something'}).then(function(nodesWhereTitleIsSomethingButOnly1) { });
client.retrieve(2).then(function(nodeWithNid2) { });
client.create({
type: 'article',
title: 'something'
}).then(function(newArticle) { });client.update(2, {
title: 'something'
}).then(function(updatedNode) { });client.delete(2).then(function() { });
/* Taxonomy */
client.taxonomyVocabulary.index().then(function(vocabulary) { });
client.taxonomyVocabulary.getTree(vid).then(function(termsForVid) { });
/* File */
client.file.index().then(function(files) { });
client.file.index({limit: 10}).then(function(max10files) { });
client.file.index(null, {filename: 'something'}).then(function(filesWhereOrigNameIsSomething) { });
/* User */
client.user.create({
mail:'[email protected]',
name:'test',
password:'test',
}).then(function(users) { }
).catch(console.error);client.user.index().then(function(users) { });
client.user.retrieve(1).then(function(userWithIdOf1) { });
```