SDKs
There is no npm or PyPI package. Paste a thin client, or skip HTTP with MCP. Spec: openapi.json.
01JavaScript
Covers the live v1 surface. Article generate costs 1.5 credits. Social generate costs 0.6 per platform.
class BrainpercentClient {
constructor(apiKey) {
this.apiKey = apiKey;
this.baseUrl = 'https://www.brainpercent.app/api/v1';
}
async request(path, options = {}) {
const response = await fetch(`${this.baseUrl}${path}`, {
...options,
headers: {
Authorization: `Bearer ${this.apiKey}`,
'Content-Type': 'application/json',
...options.headers,
},
});
return response.json();
}
listProjects(params = {}) {
return this.request(`/projects?${new URLSearchParams(params)}`);
}
generateArticle({ topic, project_id, ...rest }) {
return this.request('/articles/generate', {
method: 'POST',
body: JSON.stringify({ topic, project_id, ...rest }),
});
}
getArticleStatus(id) {
return this.request(`/articles/${id}/status`);
}
generateSocial({ source_url, platforms, ...rest }) {
return this.request('/social/generate', {
method: 'POST',
body: JSON.stringify({ source_url, platforms, ...rest }),
});
}
publishSocial({ content_id, platforms, scheduled_at }) {
return this.request('/social/publish', {
method: 'POST',
body: JSON.stringify({ content_id, platforms, scheduled_at }),
});
}
getCredits() {
return this.request('/user/credits');
}
}02Python
import requests
class BrainpercentClient:
def __init__(self, api_key: str):
self.session = requests.Session()
self.session.headers.update({
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json",
})
self.base = "https://www.brainpercent.app/api/v1"
def _request(self, method: str, path: str, **kwargs):
response = self.session.request(method, f"{self.base}{path}", **kwargs)
response.raise_for_status()
return response.json()
def list_projects(self, **params):
return self._request("GET", "/projects", params=params)
def generate_article(self, topic: str, project_id: str, **kwargs):
return self._request(
"POST",
"/articles/generate",
json={"topic": topic, "project_id": project_id, **kwargs},
)
def generate_social(self, source_url: str, platforms: list, **kwargs):
return self._request(
"POST",
"/social/generate",
json={"source_url": source_url, "platforms": platforms, **kwargs},
)
def get_credits(self):
return self._request("GET", "/user/credits")There are no update or delete Bearer routes. Projects are created in the app.