Monitor
Monitor quickstart
Create a monitor, let it run, and read what changed.
Copy as MarkdownOpen in ChatGPT (opens in a new tab)Open in Claude (opens in a new tab)
1. Watch a search
Example
Shell
curl https://api.millionshort.com/v1/monitors \
-H "Authorization: Bearer $MILLIONSHORT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"kind": "query",
"name": "bridge tenders",
"query": "bridge inspection",
"source": "contracts",
"top_n": 10,
"interval_minutes": 1440
}'Python
import os
import requests
r = requests.post(
"https://api.millionshort.com/v1/monitors",
headers={"Authorization": "Bearer " + os.environ["MILLIONSHORT_API_KEY"]},
json={
"kind": "query",
"name": "bridge tenders",
"query": "bridge inspection",
"source": "contracts",
"top_n": 10,
"interval_minutes": 1440
},
timeout=30,
)
r.raise_for_status()
print(r.json()["data"])TypeScript
const res = await fetch('https://api.millionshort.com/v1/monitors', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.MILLIONSHORT_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"kind": "query",
"name": "bridge tenders",
"query": "bridge inspection",
"source": "contracts",
"top_n": 10,
"interval_minutes": 1440
}),
});
if (!res.ok) throw new Error(`POST /v1/monitors failed: ${res.status}`);
const { data } = (await res.json()) as { data: unknown };
console.log(data);The answer is the monitor, with its id. The first check records a baseline and sends nothing, unless notify_on_create is true. After that, an event is made whenever a result appears among the first top_n that this monitor has not seen.
2. Or watch a page
Example
Shell
curl https://api.millionshort.com/v1/monitors \
-H "Authorization: Bearer $MILLIONSHORT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"kind": "url",
"url": "https://example.org/pricing",
"mode": "live",
"ignore": ["numbers", "dates"],
"min_change_chars": 40,
"interval_minutes": 60
}'Python
import os
import requests
r = requests.post(
"https://api.millionshort.com/v1/monitors",
headers={"Authorization": "Bearer " + os.environ["MILLIONSHORT_API_KEY"]},
json={
"kind": "url",
"url": "https://example.org/pricing",
"mode": "live",
"ignore": [
"numbers",
"dates"
],
"min_change_chars": 40,
"interval_minutes": 60
},
timeout=30,
)
r.raise_for_status()
print(r.json()["data"])TypeScript
const res = await fetch('https://api.millionshort.com/v1/monitors', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.MILLIONSHORT_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"kind": "url",
"url": "https://example.org/pricing",
"mode": "live",
"ignore": [
"numbers",
"dates"
],
"min_change_chars": 40,
"interval_minutes": 60
}),
});
if (!res.ok) throw new Error(`POST /v1/monitors failed: ${res.status}`);
const { data } = (await res.json()) as { data: unknown };
console.log(data);ignore and min_change_chars keep a counter or a date in the page from making an event every hour.
3. Read the events
Example
Shell
curl "https://api.millionshort.com/v1/monitors/$MONITOR_ID/events?limit=50" \
-H "Authorization: Bearer $MILLIONSHORT_API_KEY"Python
import os
import requests
r = requests.get(
f"https://api.millionshort.com/v1/monitors/{os.environ['MONITOR_ID']}/events?limit=50",
headers={"Authorization": "Bearer " + os.environ["MILLIONSHORT_API_KEY"]},
timeout=30,
)
r.raise_for_status()
print(r.json()["data"])TypeScript
const res = await fetch(`https://api.millionshort.com/v1/monitors/${process.env.MONITOR_ID}/events?limit=50`, {
headers: { Authorization: `Bearer ${process.env.MILLIONSHORT_API_KEY}` },
});
if (!res.ok) throw new Error(`GET /v1/monitors/…/events failed: ${res.status}`);
const { data } = (await res.json()) as { data: unknown };
console.log(data);Pass the id of the last event you handled as after to get only newer ones. Pulling is free.
4. Or have them delivered
Register a webhook, verify it, and pass its id as webhook_id when you create the monitor. Events then arrive signed, and can still be pulled.
Next
- Parameters: every field, the shortest interval each plan and source allows, and the events.
- Pricing and limits: what a check costs.
- News monitoring: the same job with a monitor or with a scheduled search.