SDK & Quick Start
Versions and scope
Service 1.8.0 · Engine 1.7.8 · API 1.0.0 · SDK 1.0.1. The SDK patch preserves the memory HTTP contract. These are the recorded contract versions; production compatibility must be checked before integration.
Credentials and authorization
Management requests use Authorization: Bearer <GIS access_token>. Memory requests use Authorization: Bearer <Personal/App/Service Key>. Keys cannot create Apps, keys, Brains or grants through management endpoints. Keep all credentials on your server. Treat brain_id and user_id as identifiers, never proof of permission. Resolve scope from trusted authentication and server-side mappings.
Errors and retries
401: invalid credentials; 403: denied scope or operation; 404 NOT_FOUND: absent or inaccessible object; 409 APP_DISABLED / KEY_NOT_ACTIVE: inactive App/key; 422: invalid parameters; 503 GIS_UNAVAILABLE: identity cannot be verified. Management creation has no new idempotency guarantee: inspect existing objects before retrying. Memory writes retain Idempotency-Key; memory pagination retains pagination.next_cursor.
Python
import os
from era_service_sdk import EraMemoryApiClient
with EraMemoryApiClient(os.environ['ERA_API_URL'],os.environ['ERA_BRAIN_ID'],os.environ['ERA_USER_ID'],
headers={'Authorization':'Bearer '+os.environ['ERA_API_KEY']},timeout=300) as client:
print(client.version())
event=client.add(C='SDK quickstart: Alice visited Paris.',P={'protocol':'sdk-demo'},idempotency_key='sdk-python-demo-v1')
print(client.get(event['event_id']))
print(client.history(event['event_id']))
TypeScript / Node.js
import {EraClient} from '@era-labs/client';
const client=new EraClient({baseUrl:process.env.ERA_API_URL,brainId:process.env.ERA_BRAIN_ID,userId:process.env.ERA_USER_ID,apiKey:process.env.ERA_API_KEY});
console.log(await client.version());
const event=await client.add({C:'SDK quickstart: Alice visited Paris.',P:{protocol:'sdk-demo'}},{idempotencyKey:'sdk-typescript-demo-v1'});
console.log(await client.get(event.event_id));
console.log(await client.history(event.event_id));
HTTP
import os,json
from urllib.request import Request,urlopen
from urllib.parse import quote
base=os.environ['ERA_API_URL'].rstrip('/')
scope='/v1/brains/'+quote(os.environ['ERA_BRAIN_ID'],safe='')+'/users/'+quote(os.environ['ERA_USER_ID'],safe='')
def call(method,path,body=None):
headers={'Authorization':'Bearer '+os.environ['ERA_API_KEY'],'Content-Type':'application/json'}
if method=='POST':headers['Idempotency-Key']='sdk-http-demo-v1'
data=json.dumps(body).encode() if body is not None else None
with urlopen(Request(base+path,data=data,headers=headers,method=method),timeout=300) as response:return json.load(response)
print(call('GET','/version'))
event=call('POST',scope+'/memories',{'C':'SDK HTTP quickstart: Alice visited Paris.','P':{'protocol':'sdk-demo'}})
print(call('GET',scope+'/memories/'+event['event_id']))
print(call('GET',scope+'/memories/'+event['event_id']+'/history'))