Installation
Install the Respectify SDK for your language and set up authentication.
Installation
- TypeScript
- Python
- PHP
- REST API
npm install @respectify/client
Or with yarn:
yarn add @respectify/client
Requirements: Node.js 18+
composer require respectify/respectify-php
Requirements: PHP 7.4+, ReactPHP
No installation needed. Use any HTTP client (curl, httpx, Guzzle, etc.)
Getting Your API Key
- Sign up at respectify.ai and verify your email
- Open your dashboard: your first API key is created and shown once, and brings 200 free comments with it
There is no card to add. The free plan allows one API key and 30 requests a minute until you add credit; once you do, you can create more keys at API Keys and the same first key keeps working.
Treat your API key like a password. Never hardcode it in source code. Use environment variables or a secrets manager.
Client Setup
- TypeScript
- Python
- PHP
- REST API
import { RespectifyClient } from "@respectify/client";
const client = new RespectifyClient({
email: process.env.RESPECTIFY_EMAIL!,
apiKey: process.env.RESPECTIFY_API_KEY!,
});
All methods are async and return promises.
Network calls take time. The async client lets your code do other things while waiting, via other coroutines. The blocking client is simpler for straightforward code where parallel requests, or waiting for network responses, isn't an issue. If you're unsure, start with the blocking client.
- Blocking Client
- Async Client
import os
from respectify import RespectifyClient
client = RespectifyClient(
email=os.environ['RESPECTIFY_EMAIL'],
api_key=os.environ['RESPECTIFY_API_KEY']
)
import os
from respectify import RespectifyAsyncClient
client = RespectifyAsyncClient(
email=os.environ['RESPECTIFY_EMAIL'],
api_key=os.environ['RESPECTIFY_API_KEY']
)
The PHP client is async, built on ReactPHP. API calls return promises; call $client->run() to execute the event loop.
use Respectify\RespectifyClientAsync;
$client = new RespectifyClientAsync(
getenv('RESPECTIFY_EMAIL'),
getenv('RESPECTIFY_API_KEY')
);
Include these headers in every request:
curl -X POST https://app.respectify.ai/v0.2/commentscore \
-H "X-User-Email: your@email.com" \
-H "X-API-Key: your-api-key-here" \
-H "Content-Type: application/json" \
-d '{"comment": "...", "article_context_id": "..."}'
Verifying Credentials
Test that your credentials work and check that your account can make calls. This call is free. active is true when the account has free comments left or a balance above $0; status says which, and plan_name describes it in words:
status | active | plan_name | Meaning |
|---|---|---|---|
free_plan | true | Free plan: 37 of 200 comments used | On the free plan, with comments left |
free_plan_exhausted | false | Free plan used up: all 200 comments used. Add credit to continue. | All 200 free comments used and no credit; moderation has stopped |
active | true | Credit Balance: $12.34 | Paid account with balance |
no_credit | false | Credit Balance: $0.00 | The balance has run out (an account that used up its free comments and then its balance reports free_plan_exhausted instead) |
An account that has used its free comments and then added credit reports active, like any paid account.
- TypeScript
- Python
- PHP
- REST API
const result = await client.checkUserCredentials();
console.log(`Active: ${result.active}`);
console.log(`Status: ${result.status}`);
console.log(result.plan_name); // e.g. "Credit Balance: $12.34"
- Blocking Client
- Async Client
result = client.check_user_credentials()
print(f"Active: {result.active}")
print(f"Status: {result.status}")
print(result.plan_name) # e.g. "Credit Balance: $12.34"
result = await client.check_user_credentials()
print(f"Active: {result.active}")
print(f"Status: {result.status}")
print(result.plan_name) # e.g. "Credit Balance: $12.34"
$client->checkUserCredentials()
->then(function ($result) {
echo "Active: " . ($result['active'] ? 'Yes' : 'No') . "\n";
echo $result['plan_name'] . "\n"; // e.g. "Credit Balance: $12.34"
});
$client->run();
curl -X GET https://app.respectify.ai/v0.2/usercheck \
-H "X-User-Email: your@email.com" \
-H "X-API-Key: your-api-key-here"
Response for a paid account:
{
"active": true,
"status": "active",
"expires": null,
"plan_name": "Credit Balance: $12.34",
"allowed_endpoints": null,
"error": null
}
Response for a new account on the free plan:
{
"active": true,
"status": "free_plan",
"expires": null,
"plan_name": "Free plan: 37 of 200 comments used",
"allowed_endpoints": null,
"error": null
}