API keys
Making requests
Call Lanesra from a script: send a JSON-RPC request as a POST to the MCP endpoint, with your API key as a bearer token.
The request#
| Part | Value |
|---|---|
| Method | POST |
| URL | https://app.lanesra.ai/mcp |
Authorization |
Bearer lns_live_… |
Content-Type |
application/json |
Accept |
application/json, text/event-stream (both are required) |
Each request stands alone. There is no session to open, keep alive or close.
Your first request#
This returns your headline numbers:
curl -X POST https://app.lanesra.ai/mcp \
-H "Authorization: Bearer lns_live_your_key_here" \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"get_visibility_overview","arguments":{}}}'
List the tools#
tools/list returns every tool with a description and the schema of its arguments:
{ "jsonrpc": "2.0", "id": 1, "method": "tools/list" }
The tools are described on the MCP tools page.
Call a tool with arguments#
Put the tool's name in name and its arguments in arguments:
{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/call",
"params": {
"name": "get_visibility_history",
"arguments": { "project": "acme", "from": "2026-09-01", "to": "2026-09-28" }
}
}
If your key reads more than one project, pass project on every call. list_projects gives the slugs of the projects it reads.
Reading the response#
The response can come in either of two forms:
- Plain JSON: the body is the JSON-RPC response.
- An event stream: the body is a single frame,
event: messagefollowed by adata: {…}line. Read the JSON afterdata:.
The data itself is text inside the result: result.content[0].text is a JSON string. Parse it to get the numbers.
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"content": [
{ "type": "text", "text": "{\"project\":\"acme\",\"brand\":\"Acme\",\"capturedAt\":\"…\",\"own\":{…}}" }
]
}
}
If the tool couldn't answer, result.isError is true and the text says why. See Errors.
Example: Python#
import json, os, requests
URL = "https://app.lanesra.ai/mcp"
HEADERS = {
"Authorization": f"Bearer {os.environ['LANESRA_API_KEY']}",
"Content-Type": "application/json",
"Accept": "application/json, text/event-stream",
}
def call_tool(name, arguments=None):
body = {"jsonrpc": "2.0", "id": 1, "method": "tools/call",
"params": {"name": name, "arguments": arguments or {}}}
res = requests.post(URL, headers=HEADERS, json=body, timeout=60)
res.raise_for_status()
text = res.text
# An event-stream reply carries the JSON on its "data: " line.
for line in text.splitlines():
if line.startswith("data: "):
text = line[len("data: "):]
break
result = json.loads(text)["result"]
if result.get("isError"):
raise RuntimeError(result["content"][0]["text"])
return json.loads(result["content"][0]["text"])
overview = call_tool("get_visibility_overview")
print(overview["capturedAt"], overview["own"])
Example: Node.js#
const URL = "https://app.lanesra.ai/mcp"
async function callTool(name, args = {}) {
const res = await fetch(URL, {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.LANESRA_API_KEY}`,
"Content-Type": "application/json",
Accept: "application/json, text/event-stream",
},
body: JSON.stringify({ jsonrpc: "2.0", id: 1, method: "tools/call", params: { name, arguments: args } }),
})
if (!res.ok) throw new Error(`HTTP ${res.status}: ${await res.text()}`)
let text = await res.text()
// An event-stream reply carries the JSON on its "data: " line.
const data = text.split("\n").find((l) => l.startsWith("data: "))
if (data) text = data.slice(6)
const { result } = JSON.parse(text)
if (result.isError) throw new Error(result.content[0].text)
return JSON.parse(result.content[0].text)
}
const rankings = await callTool("get_brand_rankings")
console.log(rankings.capturedAt, rankings.brands)
Keep the capture date#
Answers are re-captured on a schedule, not live. Project results carry capturedAt. Store it with the numbers, so a report always says how current it is.