Supporting pages, examples and technical details in a cleaner layout.
The official SDKs help you integrate the Militant API quickly into Python and JavaScript/Node.js projects.
requestsaxiosmkdir -p vendor/militant-sdk
curl -fsSLo vendor/militant-sdk/militant.py https://gitlab.com/militant1/militant-api/-/raw/main/sdk/python/militant.py
pip install requests
mkdir -p vendor/militant-sdk
curl -fsSLo vendor/militant-sdk/militant.js https://gitlab.com/militant1/militant-api/-/raw/main/sdk/javascript/militant.js
npm install axios
import syssys.path.append('./vendor/militant-sdk')
from militant import MilitantClient
const MilitantClient = require('./vendor/militant-sdk/militant');
If you prefer a very small project layout, place militant.py or militant.js directly at your project root.
from militant import MilitantClientclient = MilitantClient('https://militant.revlibertaire.com')
user = client.login('username', 'password')
timeline = client.get_timeline()
post = client.create_post('Hello from Python!')
const MilitantClient = require('./militant');(async () => {
const client = new MilitantClient('https://militant.revlibertaire.com');
const user = await client.login('username', 'password');
const timeline = await client.getTimeline();
const post = await client.createPost('Hello from JavaScript!');
})();
The two SDKs cover a large part of the API and act as the main integration layer for common use cases:
X-Flutter-App: militant-flutter-v1 headerNote:
The API and SDKs support:
client = MilitantClient('https://militant.revlibertaire.com')
client.login('bot_username', 'bot_password')
reports = client.get_reports()
for report in reports['data']:
if report['reason'] == 'spam':
client.vote_on_report(report['id'], 'approve')
const client = new MilitantClient('https://militant.revlibertaire.com');
await client.login(username, password);
const timeline = await client.getTimeline(1, 20);
displayPosts(timeline.posts);
client = MilitantClient('https://militant.revlibertaire.com')
client.login('username', 'password')
data = client.export_data()
Open an issue on GitLab:
Contributions are welcome: 1. Fork the project on GitLab 2. Create a feature branch 3. Commit your changes 4. Push the branch 5. Open a merge request
The SDKs are distributed under the same license as the Militant API. See LICENSE at the project root.