Getting Started with the RedCore SDK
The RedCore SDK is the fastest way to integrate with the RedCore platform. It is available for Python, Node.js, Go, and Java, wraps every REST endpoint in a typed, idiomatic interface, and handles token refresh and retries automatically — so you focus on your product, not on HTTP plumbing.
How the SDK Fits In
flowchart LR
App["Your Application"]
SDK["RedCore SDK"]
Auth["Auth Server\n(OAuth 2.0)"]
API["RedCore REST API"]
App -->|"SDK method call"| SDK
SDK -->|"POST /oauth/token\n(auto-refresh)"| Auth
Auth -->|"access_token"| SDK
SDK -->|"HTTPS + Bearer token"| API
API -->|"JSON response"| SDK
SDK -->|"typed object / exception"| App
The SDK manages token acquisition and renewal transparently — you never touch raw HTTP or handle token expiry manually.
Prerequisites
Requirement |
Details |
|---|---|
RedCore account |
An active project in the RedCore Dashboard. |
Credentials |
An API Key or OAuth 2.0 |
Runtime |
Python ≥ 3.8 · Node.js ≥ 18 · Go ≥ 1.21 · Java ≥ 17 |
Installation
Python
We recommend using a virtual environment to isolate dependencies.
python3 -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install redcore-sdk
Node.js
npm install @redcore/sdk
Go
go get github.com/redcore/go-sdk@latest
Java (Maven)
<dependency>
<groupId>com.redcore</groupId>
<artifactId>sdk</artifactId>
<version>2.1.0</version>
</dependency>
Configuration
The SDK client accepts the following options. Supplying credentials via environment variables is strongly recommended so they never appear in source code or version control.
Option |
Required |
Description |
|---|---|---|
|
Yes * |
Static API key. Use for server-to-server calls without a user context. |
|
Yes * |
OAuth 2.0 client identifier. Required when using the OAuth flow. |
|
Yes * |
OAuth 2.0 client secret. Required when using the OAuth flow. |
|
No |
Override the API root. Default: |
|
No |
Request timeout in seconds. Default: |
|
No |
Automatic retries on 5xx responses. Default: |
|
No |
|
* Supply either api_key or the client_id + client_secret pair.
Important
Never hardcode credentials in source files or commit them to version control. Use environment variables or a secrets manager such as AWS Secrets Manager or HashiCorp Vault.
REDCORE_API_KEY=rk_live_abc123...
REDCORE_BASE_URL=https://api.redcore.com/v1
REDCORE_TIMEOUT=30
Initializing the Client
Python
1import os
2from redcore import Client
3
4client = Client(
5 api_key=os.environ["REDCORE_API_KEY"],
6 base_url=os.environ.get("REDCORE_BASE_URL"),
7 timeout=int(os.environ.get("REDCORE_TIMEOUT", 30)),
8)
Node.js
const { RedcoreClient } = require("@redcore/sdk");
const client = new RedcoreClient({
apiKey: process.env.REDCORE_API_KEY,
timeout: parseInt(process.env.REDCORE_TIMEOUT ?? "30", 10),
});
Go
import (
"os"
"github.com/redcore/go-sdk/redcore"
)
client := redcore.NewClient(
redcore.WithAPIKey(os.Getenv("REDCORE_API_KEY")),
redcore.WithTimeout(30),
)
Your First API Call
Retrieve your own profile to confirm the SDK and credentials are correctly configured.
from redcore.exceptions import AuthenticationError, RedcoreAPIError
try:
me = client.users.get_me()
print(f"Connected as: {me.name} <{me.email}>")
except AuthenticationError:
print("Invalid or expired API key — check REDCORE_API_KEY.")
except RedcoreAPIError as exc:
print(f"API error {exc.status_code}: {exc.message}")
try {
const me = await client.users.getMe();
console.log(`Connected as: ${me.name} <${me.email}>`);
} catch (err) {
if (err.status === 401) console.error("Invalid API key.");
else console.error(`API error ${err.status}: ${err.message}`);
}
Tip
Add this snippet as a health-check step in your CI pipeline to catch credential drift before it reaches production.
Error Handling
Every SDK method raises (or rejects with) a typed exception rather than
returning raw HTTP objects. All exceptions inherit from RedcoreError
so you can catch selectively or broadly.
Exception |
When it is raised |
|---|---|
|
API key or token is missing, invalid, or expired (HTTP 401). |
|
Credentials lack the required scope (HTTP 403). |
|
The requested resource does not exist (HTTP 404). |
|
Request body failed server-side validation (HTTP 400 / 422). |
|
Rate limit exceeded (HTTP 429). Carries a |
|
Any other 4xx / 5xx response. Carries |
|
Connection timeout or DNS failure (no HTTP response received). |
import time
from redcore.exceptions import RateLimitError, RedcoreAPIError
def safe_get_user(client, user_id: str, max_retries: int = 3):
for attempt in range(max_retries):
try:
return client.users.get(user_id)
except RateLimitError as exc:
time.sleep(exc.retry_after)
except RedcoreAPIError as exc:
if exc.status_code >= 500 and attempt < max_retries - 1:
time.sleep(2 ** attempt)
continue
raise
raise RuntimeError("Max retries exceeded.")
Next Steps
API Key, OAuth 2.0, and SAML authentication in depth. |
|
Full method reference with request / response schemas. |
|
REST-level OAuth 2.0 token lifecycle and revocation. |
|
Complete error-code catalogue and retry guidance. |
See also
RedCore Dashboard — manage API keys and OAuth credentials.
Changelog — release notes and migration guides.
System Architecture — system architecture diagrams.